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.0.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.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydagu-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 8048e4d3f5bcab227c50ee336bcf7472a66519de737e9c5a8ded376b8a5e31cd
MD5 0a27452ac69b6a549ef572d76138c57b
BLAKE2b-256 96c993200b05c922897a84dfcac44e68f7735640a5737a372620b41875a6b04d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pydagu-0.1.0-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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3bacac12d022965cdf3ed84bc1f263d327368c44dc4d3185633e37c4f2a75e9
MD5 3fdbff55c98ca1414f3b9e9649df7727
BLAKE2b-256 9571049e808fe02f1fd80ab252e46e8f7dabf1261441ede6dcbc9f3b965ebd53

See more details on using hashes here.

Provenance

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