Skip to main content

dagron Python SDK

Author dagron workflows in Python and drive the whole dagron control plane — trigger runs, manage workflows and schedules, hold environments and secrets, redrive dead letters, wire up GitOps — without writing REST calls by hand.

  • Zero dependencies. Standard library only (json + urllib).
  • Two layers: Dag (a validating spec builder) and Client (a typed wrapper over the authenticated dagron-api gateway).
  • Full coverage. 0.12.0 covers the client-facing dagron-api HTTP surface and the engine's authoring TaskSpec — see ROADMAP.md for the endpoint matrix, what is deliberately left out, and what's next. The SDK's version tracks the API version it speaks to, so 0.12.x means "covers the 0.12 gateway".

Install

pip install dagron-sdk    # or: pip install -e .   (from sdks/python)

Author a DAG

from dagron import Dag

dag = Dag("etl", parameters={"day": "today"}, tags=["nightly"], result_from="load")
extract = dag.task("extract", image="alpine", command=["echo", "{{ day }}"])
dag.task("load", image="alpine", command=["true"], depends_on=[extract])

print(dag.to_json())    # valid dagron input (YAML is a JSON superset)

task() maps onto the engine's full TaskSpec: the basics (image, command, depends_on, input, env, resources, service_account), the retry policy (max_attempts, retry_delay_secs, retry_max_delay_secs, retry_on_timeout, retry_budgets, timeout_secs), flow control (when, trigger_rule, hook, allow_failure), fan-out (with_items, with_param, instance_key), scheduling (runner_class, pool, priority, gang), containers beside the task (services, secrets included), variables from earlier tasks (env_from, with_output_of), its workspace and image (workspace, image_pull_policy, docker_daemon, privileged) and the rest (cache, repeat, produces, isolation). Dag(...) takes the spec-level block: parameters, tags, environment, task_defaults, run_timeout_secs, max_active_runs (with concurrency_key and when_full), result_from, budget, deadline, notify, on_datasets.

Beyond leaf tasks, a task can be a call into a template, a chain into another saved workflow, or one of the command-less kinds:

dag = Dag("release")
build = dag.template("build", parameters={"target": "release"})
build.task("compile", command=["make", "{{ target }}"])

dag.task("run-build", template="build", arguments={"target": "debug"})
dag.approval("sign-off", depends_on=["run-build"], timeout_secs=3600)
dag.sensor("settle", duration="5m", depends_on=["sign-off"])
dag.trigger("publish", "publish-artifacts", depends_on=["settle"])

A step task runs a step dagron knows (csv-clean, sql-export, http-extract, file-fetch, connector), which supplies the command and image; with_ configures it (emitted as with:). Client.list_steps() says what a server knows, and Client.check_step() checks a with_ by the step's own rules before anything is saved:

dag = Dag("orders")
raw = dag.step("extract", "sql-export", with_={
    "engine": "postgres",
    "dsn": "postgres://shop@db:5432/shop",   # the password comes from SQL_PASSWORD
    "query": "SELECT id, email FROM orders",
    "output": "s3://raw/orders/{{ day }}.csv",
}, env=[{"name": "SQL_PASSWORD", "value_from": "shop-db-password"}])
dag.step("clean", "csv-clean@1", depends_on=[raw], with_={
    "input": "s3://raw/orders/{{ day }}.csv",
    "output": "s3://clean/orders/{{ day }}.csv",
    "recipe": {"steps": [{"filter": {"email": "not_null"}}]},
})

# A database beside a test task, its password a secret:
dag.task("test", image="rust:1", command=["cargo", "test"], services=[{
    "name": "db", "image": "postgres:16-alpine", "ready": "pg_isready -h localhost",
    "env": [{"name": "POSTGRES_PASSWORD", "value_from": "db-password"}],
}])

to_spec()/to_json() validate the graph client-side — unique names, known deps, one kind per task, valid trigger rules and runner classes, resolvable template calls, a result_from that names a real task, acyclicity — mirroring the server so a bad DAG fails fast instead of costing a 400 round-trip.

Drive the control plane

import os
from dagron import Client

api = Client("http://localhost:8080")
api.login("admin@example.com", os.environ["DAGRON_PASSWORD"])   # stores the token

# For automation, mint a token once — this response is the only one that ever
# carries it — and put it in the CI job's environment, not a password.
token = api.create_token("ci", expires_in_days=90)["token"]
# Then, in that job: Client.from_env() reads DAGRON_API_URL + DAGRON_TOKEN.
ci = Client("http://localhost:8080", token=token)

# Trigger an ad-hoc run and block on it server-side.
run_id = api.submit_run(dag, parameters={"day": "2026-01-01"}, idempotency_key="etl-2026-01-01")
result = api.wait_run(run_id, timeout_secs=600)
print(result["status"], result["result"])      # succeeded | failed | cancelled
if result["failure"]:
    print(result["failure"]["message"])         # why, without a second call

# Save it as a reusable workflow and schedule it nightly in a real timezone.
wf = api.create_workflow(dag, description="nightly ETL")
api.create_schedule(wf["id"], "0 0 2 * * *", timezone="Europe/Berlin", catchup=True)

# Observe.
for ev in api.stream_events():                 # every run, one connection
    print(ev["event"], ev["data"])

Every method maps one dagron-api endpoint to one call and returns the server's JSON. Non-2xx responses raise DagronError(status, message):

from dagron import DagronError

try:
    api.submit_run({"name": "x", "tasks": []})
except DagronError as e:
    print(e.status, e.message)             # e.g. 400 "DAG 'x' contains a cycle"

What Client covers

Auth & identity — login · logout · me · from_env · create_user · list_users · list_tokens · create_token · revoke_token

Runs — submit_run · list_runs · iter_runs · get_run · get_run_spec · get_run_graph · get_run_logs · get_task_logs · cancel_run · rerun_run · resubmit_run · retry_task · clear_task · approve_task · reject_task · list_approvals · stream_run · stream_events · follow_run_logs · follow_task_logs · get_task_attempts · get_task_output · read_task_output · wait_run · wait_for_run · set_triage · clear_triage · archive_run · list_archived_runs · get_archived_run

Workflows — list_workflows · get_workflow · create_workflow · update_workflow · delete_workflow · run_workflow · list_workflow_runs · list_workflow_versions · set_workflow_state · apply_bundle · workflow_badge · sync_workflow_to_git

Schedules & backfills — list_schedules · create_schedule · update_schedule · delete_schedule · backfill_schedule · create_backfill · list_backfills · get_backfill · cancel_backfill

Environments & settings — list_environments · create_environment · update_environment · delete_environment · set_environment_secret · delete_environment_secret · get_notification_settings · set_notification_settings · test_notifications · get_dead_letter_settings · set_dead_letter_settings

Data & artifacts — list_datasets · list_dataset_events · put_artifact · get_artifact · artifact_exists · list_run_artifacts · sync_artifacts

Steps — list_steps · check_step

Dead letters & GitOps — list_dead_letters · redrive_dead_letter · discard_dead_letter · list_git_repos · connect_git_repo · set_git_repo_auth · clear_git_repo_auth · sync_git_repo · disconnect_git_repo

Observability — metrics · metrics_timeseries · search · health · healthz · readyz

Test

python -m unittest          # from sdks/python

The suite validates the builder and runs Client against a threaded in-process fake gateway (real sockets), so request construction is exercised end-to-end.

Release

dagron-sdk is published to PyPI, the Python Package Index. The version is the single literal in dagron.__version__, which pyproject.toml reads statically at build time — bump it there and nowhere else.

Metadata

Release files for dagron-sdk 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dagron-sdk 0.12.0
File Size Uploaded Provenance Actions
dagron_sdk-0.12.0.tar.gz 60.2 kB With provenance Details for dagron_sdk-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dagron-sdk 0.12.0
File Interpreter ABI Platform Actions
dagron_sdk-0.12.0-py3-none-any.whl Python 3 none any Details for dagron_sdk-0.12.0-py3-none-any.whl

Total release size: 117.4 kB

Release files / dagron_sdk-0.12.0.tar.gz

Download URL dagron_sdk-0.12.0.tar.gz
Size 60.2 kB
Tags Source
SHA-256 checksum
How to use checksums
374cf9edffabaf439eee348b4b782bdae33072382b773bb883bee18da1e34782
BLAKE2b-256 checksum
How to use checksums
212e9973f3ad2b0d3d44d484f5825aa595749f0b449d58b4565083ff9dda2c1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / dagron_sdk-0.12.0-py3-none-any.whl

Download URL dagron_sdk-0.12.0-py3-none-any.whl
Size 57.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e054ded41e007eb142d820ec5141e16cd0c5b41ad9eb66feab66f8729cf8f912
BLAKE2b-256 checksum
How to use checksums
e7057436b3e35f736cd568efbdd8b15725143d0bdd4f6e022e7334fd8849171e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for dagron-sdk 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dagron_sdk-0.12.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page