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

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.1.1.tar.gz (111.3 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.1.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pydagu-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e8bb3bfc9a55e71a1fb1728932032b75bc61b4305be4b408923c034a6c7af055
MD5 8fb62603c6dacf6d1047a6cff25559a7
BLAKE2b-256 7a430c95fb4936583d7664f020c376994df0c6734367ebc599044761a411023b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pydagu-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.5 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 831a9572ac23123f2f6d9362e9fbda91399058e7d8687e290a488f37be6bdcdf
MD5 bf6ef0b5c28d0a803262be7b8a9d66c6
BLAKE2b-256 1cdf68f3e2cdb8825ef708e04d02584808b4c265d4401151d747a02f4690935f

See more details on using hashes here.

Provenance

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