Skip to main content

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

Project description

pydagu

PyPI version Tests 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.3.tar.gz (114.7 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.3-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydagu-0.2.3.tar.gz
  • Upload date:
  • Size: 114.7 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.3.tar.gz
Algorithm Hash digest
SHA256 c3a1a845f5496a1fb0d54160dfd6a4304c5cf65372d947502e3fe401fb6d1721
MD5 46fb0e03563a900f160151970e59bf75
BLAKE2b-256 a9f201be7d5f7e3b419c06bc6c5891f6b8b71920b60d41d950ecc4d66fb9fdb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydagu-0.2.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: pydagu-0.2.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ffb393bd4b4ef8244cd1c56ab045286b1a761c4679e53a8ccb0d04d9f0f37005
MD5 b89cbc659d969396c02e24532aa0ddc3
BLAKE2b-256 131a80108e00b5a020e05457003f6937755c6c624c47154fc6686d71ad7e0fb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydagu-0.2.3-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