Lightweight task dependency engine with topological execution
Project description
philiprehberger-task-graph
Lightweight task dependency engine with topological execution.
Installation
pip install philiprehberger-task-graph
Usage
from philiprehberger_task_graph import TaskGraph
graph = TaskGraph()
@graph.task()
def fetch_data():
return download()
@graph.task(depends_on=["fetch_data"])
def process_data():
return transform()
@graph.task(depends_on=["process_data"])
def save_results():
return store()
# Run tasks in dependency order
results = graph.run()
# Or run with parallelism
results = graph.run_parallel(max_workers=4)
Programmatic API
graph = TaskGraph()
graph.add_task("fetch", fetch_fn)
graph.add_task("process", process_fn, depends_on=["fetch"])
graph.add_task("save", save_fn, depends_on=["process"])
# Preview execution order
order = graph.dry_run()
# ["fetch", "process", "save"]
Cycle Detection
from philiprehberger_task_graph import CycleError
# Raises CycleError if dependencies form a cycle
graph.run()
API
| Function / Class | Description |
|---|---|
TaskGraph() |
Create a new task graph |
@graph.task(depends_on=None) |
Decorator to register a task |
graph.add_task(name, fn, depends_on=None) |
Add a task programmatically |
graph.run() |
Execute tasks in topological order |
graph.run_parallel(max_workers=4) |
Execute with thread parallelism |
graph.dry_run() |
Return execution order without running |
Development
pip install -e .
python -m pytest tests/ -v
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_task_graph-0.1.6.tar.gz.
File metadata
- Download URL: philiprehberger_task_graph-0.1.6.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d567f4b03b9e8072137376ebd9fbf6ed5f52a25d9b3c6ac58cdca64098594b27
|
|
| MD5 |
2653af1a4750de6f829cd3331b2b229a
|
|
| BLAKE2b-256 |
765254c16072fe5b3bf39a1bdbdd2b6f433713c360878125267c6110686fdf1d
|
File details
Details for the file philiprehberger_task_graph-0.1.6-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_task_graph-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0709849697524dc9f7e6932195834236f76556d983a69d169e7ce10bb86b877e
|
|
| MD5 |
49d4331ea4afea455ae6cf44fd2fa1d7
|
|
| BLAKE2b-256 |
934accc08ccd0df7ba2125366b379fd71b8c07ce16bd1c93cfe0d9fc53dec22a
|