Skip to main content

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

  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_task_graph-0.1.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_task_graph-0.1.4-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_task_graph-0.1.4.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_task_graph-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9e3efaee27efe23c20a8e0f978c42a758430f42d2a534fcc00e3cde2e831382f
MD5 395f12ed8b6b510690ad4acface2114b
BLAKE2b-256 79d4b6e511c48993a761acacf466bce9bac79d7222978b621fe5908c3667f93f

See more details on using hashes here.

File details

Details for the file philiprehberger_task_graph-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_task_graph-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 42acbe24e32fcf2a79f52f8f01dea3e55fe74e61714c7bb3fddff0c51715c3c9
MD5 d41576e2a67e2b9a89d89a853f072b28
BLAKE2b-256 a45b4d420991f9e27eef1b457fa966e9a58e650140f24d38397fc386c4de59d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page