Skip to content

Lightweight Python task runner with dependency resolution, topological sort and CLI

License

Notifications You must be signed in to change notification settings

ama228/pytaskrunner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTaskRunner

A lightweight Python task runner with dependency resolution, execution tracking, and CLI support.

Features

  • Dependency Resolution - Topological sort with cycle detection
  • Decorator API - Register tasks with @runner.task(deps=[...])
  • Dry Run - Preview execution order without running
  • Execution Tracking - Duration, success/failure, output capture
  • Statistics - Track runs, successes, and failures
  • CLI Interface - Run tasks from the command line

Quick Start

from pytaskrunner import TaskRunner

runner = TaskRunner()

@runner.task()
def clean():
    """Remove build artifacts."""
    import shutil
    shutil.rmtree("build", ignore_errors=True)
    return "cleaned"

@runner.task(deps=["clean"])
def build():
    """Compile the project."""
    return "built"

@runner.task(deps=["build"])
def test():
    """Run the test suite."""
    return "tested"

# Run with dependencies resolved automatically
results = runner.run("test")
# Executes: clean -> build -> test

CLI Usage

# Run a task
pytaskrunner -f tasks.py build

# List all tasks
pytaskrunner -f tasks.py --list

# Dry run
pytaskrunner -f tasks.py --dry-run test

Error Handling

from pytaskrunner import TaskRunner, TaskError

runner = TaskRunner()

try:
    runner.run("build")
except TaskError as e:
    print(f"Task '{e.task_name}' failed: {e.reason}")
    print(f"Duration before failure: {e.duration:.3f}s")

Running Tests

pytest

About

Lightweight Python task runner with dependency resolution, topological sort and CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages