Skip to main content

Lightweight task dependency engine with topological execution

Project description

philiprehberger-task-graph

Tests PyPI version License

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=["fetch_data"])
def process_data():
    return transform()

@graph.task(depends=["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=["fetch"])
graph.add_task("save", save_fn, depends=["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=None) — Decorator to register a task
  • graph.add_task(name, fn, depends=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

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.3.tar.gz (4.8 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.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_task_graph-0.1.3.tar.gz
Algorithm Hash digest
SHA256 073a63a41e7ce2e9398d6232a5a288b1a0cf29d25338550611545e27014c5c47
MD5 26e7a98b91a9738259e3ec74c42de1f3
BLAKE2b-256 072859a2df06291892bd96677130877a9879acdf43552b2a5b7ac0ac31be6478

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_task_graph-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a804db6c677c5878bbb04277dbc399a5b84a45491520cf7f840f597998b372ba
MD5 88e521e2c828c922a7b8a57e91b38331
BLAKE2b-256 1da82ae9ae929c9bfb5f937b9f89e44068d318c0f901641b8b0a7361da5c9c87

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