Skip to main content

Python client library for Dagu - A cron alternative with a Web UI

Project description

pydagu

PyPI version Tests codecov Python Versions License: MIT

A Python client library for Dagu - providing type-safe DAG creation and HTTP API interaction with Pydantic validation.

Features

  • 🎯 Type-safe: Built with Pydantic models for full type safety and validation
  • 🏗️ Builder Pattern: Fluent API for constructing DAGs and steps
  • 🔌 HTTP Client: Complete client for Dagu's HTTP API
  • 🔄 Webhook Support: Built-in patterns for webhook integration
  • Well-tested: Comprehensive test suite with 95%+ coverage
  • 📝 Examples: Production-ready integration examples

Installation

pip install pydagu

Prerequisites

You need a running Dagu server to run the tests. Install Dagu:

# macOS
brew install dagu-org/brew/dagu

# Linux
curl -L https://github.com/dagu-org/dagu/releases/latest/download/dagu_linux_amd64.tar.gz | tar xz
sudo mv dagu /usr/local/bin/

# Start the server
dagu server

Quick Start

Create and Run a Simple DAG

from pydagu.builder import DagBuilder, StepBuilder
from pydagu.http import DaguHttpClient
from pydagu.models.request import StartDagRun

# Initialize client
client = DaguHttpClient(
    dag_name="my-first-dag",
    url_root="http://localhost:8080/api/v2/"
)

# Build a DAG
dag = (
    DagBuilder("my-first-dag")
    .description("My first DAG with pydagu")
    .add_step_models(
        StepBuilder("hello-world")
        .command("echo 'Hello from pydagu!'")
        .build()
    )
    .build()
)

# Post the DAG to Dagu
client.post_dag(dag)

# Start a run
dag_run_id = client.start_dag_run(StartDagRun(dagName=dag.name))

# Check status
status = client.get_dag_run_status(dag_run_id.dagRunId)
print(f"Status: {status.statusLabel}")

HTTP Executor with Retry

from pydagu.builder import StepBuilder

step = (
    StepBuilder("api-call")
    .command("POST https://api.example.com/webhook")
    .http_executor(
        headers={
            "Content-Type": "application/json",
            "Authorization": "Bearer ${API_TOKEN}"
        },
        body={"event": "user.created", "user_id": "123"},
        timeout=30
    )
    .retry(limit=3, interval=5)
    .build()
)

Chained Steps with Dependencies

from pydagu.builder import DagBuilder, StepBuilder

dag = (
    DagBuilder("data-pipeline")
    .add_step_models(
        StepBuilder("extract")
        .command("python extract_data.py")
        .output("EXTRACTED_FILE")
        .build(),

        StepBuilder("transform")
        .command("python transform_data.py ${EXTRACTED_FILE}")
        .depends_on("extract")
        .output("TRANSFORMED_FILE")
        .build(),

        StepBuilder("load")
        .command("python load_data.py ${TRANSFORMED_FILE}")
        .depends_on("transform")
        .build()
    )
    .build()
)

Development

# Clone the repository
git clone https://github.com/yourusername/pydagu.git
cd pydagu

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests (requires Dagu server running)
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=pydagu --cov-report=html

Documentation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Related Projects

  • Dagu - The underlying DAG execution engine
  • Airflow - Alternative workflow orchestration platform
  • Fluvial Diligence - TPRM Platform with customisable workflows

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

pydagu-0.2.4.tar.gz (115.2 kB view details)

Uploaded Source

Built Distribution

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

pydagu-0.2.4-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file pydagu-0.2.4.tar.gz.

File metadata

  • Download URL: pydagu-0.2.4.tar.gz
  • Upload date:
  • Size: 115.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydagu-0.2.4.tar.gz
Algorithm Hash digest
SHA256 47bfb0b62ea578ca1c28cf9a558ff0bb4c4f92dc93c7a9cda373a826346ce6f5
MD5 cc2eaa836ff559c709191e47a3732b58
BLAKE2b-256 1190a38d8471090e9169f39fc176822fc215d24fe1fee4787b36daf05a6abbb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydagu-0.2.4.tar.gz:

Publisher: publish.yml on patrickcd/pydagu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydagu-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: pydagu-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydagu-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bd2b0850c568c84d389fdc64b3695e18cfd17200ebf2ebe0f2b3be94e22998eb
MD5 015eb3fd7914984fbc0c309b582f45cc
BLAKE2b-256 dbda2972b3acd889762dc9bf145599da85b222f10597cb2348988f3a7690d432

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydagu-0.2.4-py3-none-any.whl:

Publisher: publish.yml on patrickcd/pydagu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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