tadween-core 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tadween_core-0.1.0a1/.github/workflows/_tests.yml +37 -0
- tadween_core-0.1.0a1/.github/workflows/ci.yml +11 -0
- tadween_core-0.1.0a1/.github/workflows/publish.yml +52 -0
- tadween_core-0.1.0a1/.gitignore +29 -0
- tadween_core-0.1.0a1/.python-version +1 -0
- tadween_core-0.1.0a1/AGENTS.md +313 -0
- tadween_core-0.1.0a1/LICENSE +202 -0
- tadween_core-0.1.0a1/NOTICE +4 -0
- tadween_core-0.1.0a1/PKG-INFO +342 -0
- tadween_core-0.1.0a1/README.md +114 -0
- tadween_core-0.1.0a1/benchmark/README.md +118 -0
- tadween_core-0.1.0a1/benchmark/__init__.py +0 -0
- tadween_core-0.1.0a1/benchmark/automatic_testing.py +112 -0
- tadween_core-0.1.0a1/benchmark/memory_collector.ipynb +77 -0
- tadween_core-0.1.0a1/benchmark/memory_collector.py +54 -0
- tadween_core-0.1.0a1/benchmark/results/RAM_100mb.log +380 -0
- tadween_core-0.1.0a1/benchmark/results/bottleneck_CPU_native.log +549 -0
- tadween_core-0.1.0a1/benchmark/results/bottleneck_CPU_numpy.log +366 -0
- tadween_core-0.1.0a1/benchmark/runtime_monitor.ipynb +64 -0
- tadween_core-0.1.0a1/benchmark/runtime_monitor.py +179 -0
- tadween_core-0.1.0a1/benchmark/task_queue_ram_monitor.ipynb +110 -0
- tadween_core-0.1.0a1/benchmark/task_queue_ram_monitor.py +51 -0
- tadween_core-0.1.0a1/examples/README.md +6 -0
- tadween_core-0.1.0a1/examples/broker/README.md +5 -0
- tadween_core-0.1.0a1/examples/broker/ex1.py +18 -0
- tadween_core-0.1.0a1/examples/broker/ex2.py +65 -0
- tadween_core-0.1.0a1/examples/broker/ex3.py +101 -0
- tadween_core-0.1.0a1/examples/cache/README.md +6 -0
- tadween_core-0.1.0a1/examples/cache/ex1.py +55 -0
- tadween_core-0.1.0a1/examples/cache/ex2.py +29 -0
- tadween_core-0.1.0a1/examples/handler/README.md +4 -0
- tadween_core-0.1.0a1/examples/handler/ex1.py +58 -0
- tadween_core-0.1.0a1/examples/handler/ex2.py +36 -0
- tadween_core-0.1.0a1/examples/repo/README.md +11 -0
- tadween_core-0.1.0a1/examples/repo/ex1.py +28 -0
- tadween_core-0.1.0a1/examples/repo/ex2.py +25 -0
- tadween_core-0.1.0a1/examples/repo/ex3.py +55 -0
- tadween_core-0.1.0a1/examples/repo/ex4.py +25 -0
- tadween_core-0.1.0a1/examples/repo/ex5.py +0 -0
- tadween_core-0.1.0a1/examples/repo/my_artifact.py +115 -0
- tadween_core-0.1.0a1/examples/stage/README.md +8 -0
- tadween_core-0.1.0a1/examples/stage/ex1.py +22 -0
- tadween_core-0.1.0a1/examples/stage/ex2.py +56 -0
- tadween_core-0.1.0a1/examples/stage/ex3.py +88 -0
- tadween_core-0.1.0a1/examples/stage/ex4.py +0 -0
- tadween_core-0.1.0a1/examples/stage/ex5.py +0 -0
- tadween_core-0.1.0a1/examples/stage/ex6.py +0 -0
- tadween_core-0.1.0a1/examples/task_queue/README.md +7 -0
- tadween_core-0.1.0a1/examples/task_queue/ex1.py +23 -0
- tadween_core-0.1.0a1/examples/task_queue/ex2.py +53 -0
- tadween_core-0.1.0a1/examples/task_queue/ex3.py +42 -0
- tadween_core-0.1.0a1/examples/task_queue/ex4.py +64 -0
- tadween_core-0.1.0a1/examples/task_queue/ex5.py +62 -0
- tadween_core-0.1.0a1/examples/workflow/README.md +2 -0
- tadween_core-0.1.0a1/examples/workflow/ex1.py +130 -0
- tadween_core-0.1.0a1/experiments/__init__.py +0 -0
- tadween_core-0.1.0a1/experiments/boilerplate.py +61 -0
- tadween_core-0.1.0a1/experiments/bottleneck.py +166 -0
- tadween_core-0.1.0a1/experiments/cache.py +34 -0
- tadween_core-0.1.0a1/noxfile.py +49 -0
- tadween_core-0.1.0a1/pyproject.toml +86 -0
- tadween_core-0.1.0a1/src/tadween_core/__init__.py +33 -0
- tadween_core-0.1.0a1/src/tadween_core/_logging.py +37 -0
- tadween_core-0.1.0a1/src/tadween_core/broker/README.md +49 -0
- tadween_core-0.1.0a1/src/tadween_core/broker/__init__.py +5 -0
- tadween_core-0.1.0a1/src/tadween_core/broker/base.py +196 -0
- tadween_core-0.1.0a1/src/tadween_core/broker/listeners.py +223 -0
- tadween_core-0.1.0a1/src/tadween_core/broker/memory.py +452 -0
- tadween_core-0.1.0a1/src/tadween_core/cache/README.md +59 -0
- tadween_core-0.1.0a1/src/tadween_core/cache/__init__.py +38 -0
- tadween_core-0.1.0a1/src/tadween_core/cache/adapter.py +114 -0
- tadween_core-0.1.0a1/src/tadween_core/cache/base.py +57 -0
- tadween_core-0.1.0a1/src/tadween_core/cache/cache.py +480 -0
- tadween_core-0.1.0a1/src/tadween_core/cache/policy.py +56 -0
- tadween_core-0.1.0a1/src/tadween_core/cache/proxy.py +163 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/__init__.py +6 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/__init__.py +11 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/collectors/__init__.py +0 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/collectors/memory.py +310 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/collectors/ram.py +265 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/collectors/runtime.py +101 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/loaders.py +116 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/plot.py +408 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/processors.py +199 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/analytics/schemas.py +287 -0
- tadween_core-0.1.0a1/src/tadween_core/devtools/utils.py +60 -0
- tadween_core-0.1.0a1/src/tadween_core/exceptions.py +76 -0
- tadween_core-0.1.0a1/src/tadween_core/handler/README.md +73 -0
- tadween_core-0.1.0a1/src/tadween_core/handler/__init__.py +3 -0
- tadween_core-0.1.0a1/src/tadween_core/handler/base.py +71 -0
- tadween_core-0.1.0a1/src/tadween_core/handler/defaults/__init__.py +0 -0
- tadween_core-0.1.0a1/src/tadween_core/handler/defaults/downloader.py +88 -0
- tadween_core-0.1.0a1/src/tadween_core/handler/defaults/s3_downloader.py +92 -0
- tadween_core-0.1.0a1/src/tadween_core/handler/dummy.py +504 -0
- tadween_core-0.1.0a1/src/tadween_core/py.typed +0 -0
- tadween_core-0.1.0a1/src/tadween_core/repo/README.md +51 -0
- tadween_core-0.1.0a1/src/tadween_core/repo/__init__.py +20 -0
- tadween_core-0.1.0a1/src/tadween_core/repo/base.py +214 -0
- tadween_core-0.1.0a1/src/tadween_core/repo/fs.py +241 -0
- tadween_core-0.1.0a1/src/tadween_core/repo/json.py +248 -0
- tadween_core-0.1.0a1/src/tadween_core/repo/s3.py +403 -0
- tadween_core-0.1.0a1/src/tadween_core/repo/sqlite.py +377 -0
- tadween_core-0.1.0a1/src/tadween_core/stage/README.md +78 -0
- tadween_core-0.1.0a1/src/tadween_core/stage/__init__.py +13 -0
- tadween_core-0.1.0a1/src/tadween_core/stage/decorators.py +223 -0
- tadween_core-0.1.0a1/src/tadween_core/stage/policy.py +415 -0
- tadween_core-0.1.0a1/src/tadween_core/stage/stage.py +300 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/README.md +45 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/__init__.py +126 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/base.py +61 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/base_policy.py +27 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/base_queue.py +238 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/dynamic.py +105 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/policy.py +17 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/process_queue.py +87 -0
- tadween_core-0.1.0a1/src/tadween_core/task_queue/thread_queue.py +40 -0
- tadween_core-0.1.0a1/src/tadween_core/types/__init__.py +0 -0
- tadween_core-0.1.0a1/src/tadween_core/types/artifact/README.md +48 -0
- tadween_core-0.1.0a1/src/tadween_core/types/artifact/__init__.py +4 -0
- tadween_core-0.1.0a1/src/tadween_core/types/artifact/base.py +210 -0
- tadween_core-0.1.0a1/src/tadween_core/types/artifact/part.py +68 -0
- tadween_core-0.1.0a1/src/tadween_core/types/s3_config.py +28 -0
- tadween_core-0.1.0a1/src/tadween_core/workflow/README.md +47 -0
- tadween_core-0.1.0a1/src/tadween_core/workflow/__init__.py +4 -0
- tadween_core-0.1.0a1/src/tadween_core/workflow/router.py +195 -0
- tadween_core-0.1.0a1/src/tadween_core/workflow/workflow.py +636 -0
- tadween_core-0.1.0a1/tests/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/artifact/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/artifact/test_create_artifact.py +289 -0
- tadween_core-0.1.0a1/tests/broker/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/broker/test_memory.py +243 -0
- tadween_core-0.1.0a1/tests/cache/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/cache/test_cache_basic.py +405 -0
- tadween_core-0.1.0a1/tests/cache/test_cache_eviction_manual.py +105 -0
- tadween_core-0.1.0a1/tests/cache/test_cache_policy.py +416 -0
- tadween_core-0.1.0a1/tests/conftest.py +177 -0
- tadween_core-0.1.0a1/tests/handler/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/repo/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/repo/test_contract.py +191 -0
- tadween_core-0.1.0a1/tests/repo/test_fs.py +9 -0
- tadween_core-0.1.0a1/tests/repo/test_json.py +15 -0
- tadween_core-0.1.0a1/tests/repo/test_s3.py +9 -0
- tadween_core-0.1.0a1/tests/repo/test_sqlite.py +9 -0
- tadween_core-0.1.0a1/tests/shared_types.py +104 -0
- tadween_core-0.1.0a1/tests/stage/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/stage/test_policy.py +302 -0
- tadween_core-0.1.0a1/tests/stage/test_stage.py +325 -0
- tadween_core-0.1.0a1/tests/task_queue/__init__.py +1 -0
- tadween_core-0.1.0a1/tests/task_queue/test_base_queue.py +217 -0
- tadween_core-0.1.0a1/tests/task_queue/test_process.py +47 -0
- tadween_core-0.1.0a1/tests/task_queue/test_thread.py +179 -0
- tadween_core-0.1.0a1/tests/test_error_handling.py +126 -0
- tadween_core-0.1.0a1/tests/workflow/__init__.py +0 -0
- tadween_core-0.1.0a1/tests/workflow/test_workflow.py +354 -0
- tadween_core-0.1.0a1/uv.lock +2052 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_call:
|
|
5
|
+
jobs:
|
|
6
|
+
lint:
|
|
7
|
+
timeout-minutes: 5
|
|
8
|
+
name: Lint & format
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v6
|
|
12
|
+
- uses: astral-sh/setup-uv@v7
|
|
13
|
+
- run: uv tool install nox
|
|
14
|
+
- name: Run lint
|
|
15
|
+
timeout-minutes: 3
|
|
16
|
+
run: nox -s lint
|
|
17
|
+
|
|
18
|
+
tests:
|
|
19
|
+
timeout-minutes: 30
|
|
20
|
+
name: Tests / Python ${{ matrix.python-version }}
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
strategy:
|
|
23
|
+
fail-fast: false
|
|
24
|
+
matrix:
|
|
25
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v6
|
|
29
|
+
- uses: astral-sh/setup-uv@v7
|
|
30
|
+
with:
|
|
31
|
+
enable-cache: true
|
|
32
|
+
cache-dependency-glob: "uv.lock"
|
|
33
|
+
python-version: ${{ matrix.python-version }}
|
|
34
|
+
- run: uv tool install nox
|
|
35
|
+
- name: Run tests
|
|
36
|
+
timeout-minutes: 5
|
|
37
|
+
run: nox -s "tests-${{ matrix.python-version }}"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- v*
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
run-tests:
|
|
10
|
+
uses: ./.github/workflows/_tests.yml
|
|
11
|
+
|
|
12
|
+
publish:
|
|
13
|
+
needs: run-tests
|
|
14
|
+
name: Build
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment:
|
|
17
|
+
name: pypi
|
|
18
|
+
permissions:
|
|
19
|
+
id-token: write
|
|
20
|
+
contents: read
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v6
|
|
24
|
+
- uses: astral-sh/setup-uv@v7
|
|
25
|
+
|
|
26
|
+
- name: Verify tag matches pyproject.toml version
|
|
27
|
+
run: |
|
|
28
|
+
TAG="${GITHUB_REF_NAME}"
|
|
29
|
+
VERSION="${TAG#v}"
|
|
30
|
+
TOML_VERSION=$(grep '^version' pyproject.toml | sed 's/.*= *"\(.*\)"/\1/')
|
|
31
|
+
if [ "$VERSION" != "$TOML_VERSION" ]; then
|
|
32
|
+
echo "ERROR: tag $TAG does not match pyproject.toml version $TOML_VERSION"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
- name: Build
|
|
37
|
+
run: uv build
|
|
38
|
+
|
|
39
|
+
- name: Publish
|
|
40
|
+
run: uv publish
|
|
41
|
+
|
|
42
|
+
- name: Create GitHub release
|
|
43
|
+
uses: actions/github-script@v7
|
|
44
|
+
with:
|
|
45
|
+
script: |
|
|
46
|
+
await github.rest.repos.createRelease({
|
|
47
|
+
owner: context.repo.owner,
|
|
48
|
+
repo: context.repo.repo,
|
|
49
|
+
tag_name: context.ref.replace('refs/tags/', ''),
|
|
50
|
+
name: context.ref.replace('refs/tags/', ''),
|
|
51
|
+
generate_release_notes: true
|
|
52
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
.venv
|
|
11
|
+
/data
|
|
12
|
+
/models
|
|
13
|
+
|
|
14
|
+
# graphs are high-resolution. use notebooks to generate again
|
|
15
|
+
benchmark/results/*.png
|
|
16
|
+
*.db
|
|
17
|
+
examples/repo/temp
|
|
18
|
+
# notebooks in the root dir
|
|
19
|
+
/*.ipynb
|
|
20
|
+
|
|
21
|
+
/.pytest_cache
|
|
22
|
+
/.nox
|
|
23
|
+
/.ruff_cache
|
|
24
|
+
|
|
25
|
+
commit_message.md
|
|
26
|
+
.coverage
|
|
27
|
+
# local test
|
|
28
|
+
.actrc
|
|
29
|
+
.github/workflows/*.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This document provides guidelines for AI coding agents working in the tadween-core repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
tadween-core is a modular, embedded micro-orchestrator for building complex, stateful processing pipelines. It uses Python 3.11+ with Pydantic for type-safe data models and supports both thread and process-based concurrency.
|
|
8
|
+
|
|
9
|
+
## Build, Lint, and Test Commands
|
|
10
|
+
|
|
11
|
+
### Setup
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install dependencies (requires uv package manager)
|
|
15
|
+
uv sync
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Running Tests
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Run all tests
|
|
22
|
+
uv run pytest
|
|
23
|
+
|
|
24
|
+
# Run tests with verbose output
|
|
25
|
+
uv run pytest -v -s
|
|
26
|
+
|
|
27
|
+
# Run a single test file
|
|
28
|
+
uv run pytest tests/path/to/test_file.py
|
|
29
|
+
|
|
30
|
+
# Run a specific test function
|
|
31
|
+
uv run pytest tests/path/to/test_file.py::test_function_name
|
|
32
|
+
|
|
33
|
+
# Run tests matching a pattern
|
|
34
|
+
uv run pytest -k "pattern_name"
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Linting and Formatting
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Run ruff linter
|
|
42
|
+
ruff check .
|
|
43
|
+
|
|
44
|
+
# Run ruff formatter (check mode)
|
|
45
|
+
ruff format --check .
|
|
46
|
+
|
|
47
|
+
# Auto-fix lint issues
|
|
48
|
+
ruff check . --fix
|
|
49
|
+
|
|
50
|
+
# Auto-format code
|
|
51
|
+
ruff format .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Running Tests Across Python Versions (Nox)
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Run all test sessions (Python 3.11, 3.12, 3.13, 3.14)
|
|
58
|
+
nox -s tests
|
|
59
|
+
|
|
60
|
+
# Run lint session
|
|
61
|
+
nox -s lint
|
|
62
|
+
|
|
63
|
+
# Run examples session
|
|
64
|
+
nox -s examples
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Code Style Guidelines
|
|
68
|
+
|
|
69
|
+
### Imports
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
# Standard library imports first
|
|
73
|
+
from abc import ABC, abstractmethod
|
|
74
|
+
from dataclasses import dataclass
|
|
75
|
+
from typing import Generic, TypeVar
|
|
76
|
+
|
|
77
|
+
# Third-party imports second
|
|
78
|
+
import numpy as np
|
|
79
|
+
from pydantic import BaseModel
|
|
80
|
+
|
|
81
|
+
# Local imports last
|
|
82
|
+
from tadween_core.broker import Message
|
|
83
|
+
from tadween_core.exceptions import StageError
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Type Annotations
|
|
87
|
+
|
|
88
|
+
- Use Python 3.11+ syntax for type hints (e.g., `X | None` instead of `Optional[X]`)
|
|
89
|
+
- Use `Generic` with `TypeVar` for generic classes
|
|
90
|
+
- TypeVar naming convention: suffix `T` (e.g., `InputT`, `OutputT`, `ArtifactT`)
|
|
91
|
+
- Bound TypeVars to appropriate base classes: `TypeVar("T", bound=BaseModel)`
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from typing import Generic, TypeVar
|
|
95
|
+
|
|
96
|
+
InputT = TypeVar("InputT", bound=BaseModel)
|
|
97
|
+
OutputT = TypeVar("OutputT", bound=BaseModel)
|
|
98
|
+
|
|
99
|
+
class BaseHandler(ABC, Generic[InputT, OutputT]):
|
|
100
|
+
def run(self, inputs: InputT) -> OutputT:
|
|
101
|
+
pass
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Dataclasses and Models
|
|
105
|
+
|
|
106
|
+
- Use `@dataclass(slots=True)` for performance-critical data structures
|
|
107
|
+
- Use Pydantic `BaseModel` for data validation and serialization
|
|
108
|
+
- Use `Field(default_factory=...)` for mutable defaults
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from dataclasses import dataclass
|
|
112
|
+
|
|
113
|
+
@dataclass(slots=True)
|
|
114
|
+
class TaskMetadata:
|
|
115
|
+
task_id: str
|
|
116
|
+
start_time: float
|
|
117
|
+
end_time: float
|
|
118
|
+
|
|
119
|
+
from pydantic import BaseModel, Field
|
|
120
|
+
|
|
121
|
+
class MyModel(BaseModel):
|
|
122
|
+
name: str
|
|
123
|
+
created_at: float = Field(default_factory=time.time)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Naming Conventions
|
|
127
|
+
|
|
128
|
+
- **Classes**: PascalCase (e.g., `BaseHandler`, `TaskEnvelope`, `InMemoryBroker`)
|
|
129
|
+
- **Functions/Methods**: snake_case (e.g., `submit_message`, `resolve_inputs`)
|
|
130
|
+
- **Private methods**: prefix with `_` (e.g., `_detect_input_type`, `_enforce_input_type`)
|
|
131
|
+
- **Constants**: UPPER_SNAKE_CASE (e.g., `S3_TEST_BUCKET`)
|
|
132
|
+
- **Type aliases**: PascalCase (e.g., `BaseRepo`, `PartNameT`)
|
|
133
|
+
|
|
134
|
+
### Error Handling
|
|
135
|
+
|
|
136
|
+
- Inherit from `TadweenError` base exception
|
|
137
|
+
- Include context as keyword arguments
|
|
138
|
+
- Use `raise ... from e` to preserve exception chain
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from tadween_core.exceptions import StageError, PolicyError
|
|
142
|
+
|
|
143
|
+
class CustomError(StageError):
|
|
144
|
+
def __init__(self, message: str, stage_name: str, **context: Any):
|
|
145
|
+
super().__init__(message, stage_name=stage_name, **context)
|
|
146
|
+
|
|
147
|
+
raise PolicyError(
|
|
148
|
+
message="Policy resolution failed",
|
|
149
|
+
stage_name=self.name,
|
|
150
|
+
policy_name=self.policy.__class__.__name__,
|
|
151
|
+
method="resolve_inputs",
|
|
152
|
+
) from e
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### ABC Pattern
|
|
156
|
+
|
|
157
|
+
Use Abstract Base Classes for interfaces:
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from abc import ABC, abstractmethod
|
|
161
|
+
|
|
162
|
+
class BaseHandler(ABC, Generic[InputT, OutputT]):
|
|
163
|
+
@abstractmethod
|
|
164
|
+
def run(self, inputs: InputT) -> OutputT:
|
|
165
|
+
pass
|
|
166
|
+
|
|
167
|
+
def warmup(self) -> None:
|
|
168
|
+
pass
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Docstrings
|
|
172
|
+
|
|
173
|
+
- Use triple-quoted docstrings for classes and public methods
|
|
174
|
+
- Document parameters, returns, and raises
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
def load(
|
|
178
|
+
self,
|
|
179
|
+
artifact_id: str,
|
|
180
|
+
include: Iterable[PartNameT] | Literal["all"] | None = None,
|
|
181
|
+
**options: Any,
|
|
182
|
+
) -> ART | None:
|
|
183
|
+
"""
|
|
184
|
+
Load an artifact.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
artifact_id: The unique identifier
|
|
188
|
+
include: Parts to include
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
artifact object or None if not found
|
|
192
|
+
|
|
193
|
+
Raises:
|
|
194
|
+
ValueError: if any name in ``include`` is not valid.
|
|
195
|
+
"""
|
|
196
|
+
pass
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Ruff Configuration
|
|
200
|
+
|
|
201
|
+
The project uses ruff with the following rules enabled:
|
|
202
|
+
|
|
203
|
+
- `UP` - pyupgrade
|
|
204
|
+
- `E` - pycodestyle errors
|
|
205
|
+
- `F` - pyflakes
|
|
206
|
+
- `W` - pycodestyle warnings
|
|
207
|
+
- `I` - isort
|
|
208
|
+
- `B` - flake8-bugbear
|
|
209
|
+
- `C4` - flake8-comprehensions
|
|
210
|
+
- `ARG001` - unused arguments
|
|
211
|
+
- `F401` - unused imports
|
|
212
|
+
|
|
213
|
+
**Ignored rules:**
|
|
214
|
+
- `E501` - line too long (handled by formatter)
|
|
215
|
+
- `B008` - function calls in argument defaults
|
|
216
|
+
- `W191` - indentation contains tabs
|
|
217
|
+
- `B904` - raise without `from e`
|
|
218
|
+
|
|
219
|
+
## Pytest Configuration
|
|
220
|
+
|
|
221
|
+
- Test paths: `tests/`
|
|
222
|
+
- Test file pattern: `test_*.py`
|
|
223
|
+
- Test class pattern: `Test*`
|
|
224
|
+
- Test function pattern: `test_*`
|
|
225
|
+
- Python path includes `src/`
|
|
226
|
+
- Environment variable `TESTING=1` is set
|
|
227
|
+
|
|
228
|
+
## Testing Patterns
|
|
229
|
+
|
|
230
|
+
### Test Structure
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
import pytest
|
|
234
|
+
from pydantic import BaseModel
|
|
235
|
+
|
|
236
|
+
from tadween_core.handler.base import BaseHandler
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class TestInput(BaseModel):
|
|
240
|
+
value: int
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class TestOutput(BaseModel):
|
|
244
|
+
result: str
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class TestHandler(BaseHandler[TestInput, TestOutput]):
|
|
248
|
+
def run(self, inputs: TestInput) -> TestOutput:
|
|
249
|
+
return TestOutput(result=str(inputs.value))
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def test_handler_execution():
|
|
253
|
+
handler = TestHandler()
|
|
254
|
+
result = handler(TestInput(value=42))
|
|
255
|
+
assert result.result == "42"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Using Fixtures
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
@pytest.fixture
|
|
262
|
+
def handler():
|
|
263
|
+
return MyHandler()
|
|
264
|
+
|
|
265
|
+
def test_something(handler):
|
|
266
|
+
result = handler.run(MyInput(value=1))
|
|
267
|
+
assert result.success
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Contract Tests
|
|
271
|
+
|
|
272
|
+
Use base classes for shared test contracts:
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
class RepoContract:
|
|
276
|
+
def test_basic(self, repo):
|
|
277
|
+
repo.save(artifact)
|
|
278
|
+
assert repo.exists(artifact.id)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Project Structure
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
src/tadween_core/
|
|
285
|
+
├── __init__.py
|
|
286
|
+
├── exceptions.py # Custom exception hierarchy
|
|
287
|
+
├── broker/ # Message bus implementations
|
|
288
|
+
├── cache/ # Type-safe caching
|
|
289
|
+
├── handler/ # Computational handlers
|
|
290
|
+
├── repo/ # Persistence layer
|
|
291
|
+
├── stage/ # Stage orchestration
|
|
292
|
+
├── task_queue/ # Thread/process queues
|
|
293
|
+
├── types/ # Core type definitions
|
|
294
|
+
├── utils.py # Utility functions
|
|
295
|
+
└── workflow/ # DAG orchestration
|
|
296
|
+
|
|
297
|
+
tests/
|
|
298
|
+
├── conftest.py # Shared fixtures
|
|
299
|
+
├── shared_types.py # Test type definitions
|
|
300
|
+
├── repo/ # Repository tests
|
|
301
|
+
├── task_queue/ # Queue tests
|
|
302
|
+
└── test_*.py # Integration tests
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Comments Policy
|
|
306
|
+
|
|
307
|
+
Do not add comments to code unless explicitly requested. Keep code self-documenting through clear naming and structure.
|
|
308
|
+
|
|
309
|
+
## Python Version Support
|
|
310
|
+
|
|
311
|
+
- Minimum: Python 3.11
|
|
312
|
+
- Maximum: Python 3.14 (exclusive)
|
|
313
|
+
- Use modern Python features: `match`, `|` for unions, `TypeAlias`, etc.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Abdulrahman Hedya
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|