Declarative DAG runner with pipelining and concurrency control.
Project description
dagrun
A small, dependency-free DAG runner for Python where you never declare an edge. Annotate your functions with the columns they read and produce, and dagrun will figure out the rest.
Example
from collections.abc import Iterable
from dagrun import Dag, DagRunner
from dagrun.model import PK, FK, Column, Entity
class Site(Entity):
site_id = PK[str]
name = Column[str | None]
class File(Entity):
file_id = PK[str]
site = FK[Site]
name = Column[str | None]
title = Column[str | None]
dag = Dag()
@dag.fn
def discover_sites(sp: Sharepoint) -> Iterable[Site[Site.name]]:
for raw in sp.list_sites():
yield Site(site_id=raw["id"], name=raw["name"])
@dag.fn
def discover_files(site: Site, sp: Sharepoint) -> Iterable[File[File.name]]:
for raw in sp.list_files(site.site_id):
yield File(file_id=raw["id"], site=site, name=raw["name"])
@dag.fn
def extract_title(file: File[File.name]) -> File[File.title]:
return File(file_id=file.file_id, title=file.name.removesuffix(".txt"))
runner = DagRunner()
runner.provide(Sharepoint, Sharepoint)
runner.execute(dag)
Parameter annotations declare what a function reads (File[File.name]), return
annotations declare what it produces, and the dependency graph is built from
those. Reads and writes are keyed per column, so functions that enrich different
columns of the same entity run independently.
What you get
- Compile-time checks.
compile()fails on a missing dependency, a column produced twice, or a cycle, before anything runs. - Incremental reruns. The store records when each
(function, input)pair last ran. Passmax_age=timedelta(hours=6)to skip anything still fresh. - Deferred nodes. A node can
raise Defer()to skip the current input at runtime, writing and recording nothing so the next run reconsiders it. - Pipelining. Tasks are scheduled and gated per input, so
extract_titlestarts on the first file whilediscover_filesis still finding the rest. - Concurrency control. Each function declares a
costagainst named pools to bound resource usage and respect rate limits. - Blob columns. A
Blobcolumn stashes bytes in a dedicated backend and keeps only a reference in the row.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dagrun-0.1.0.tar.gz.
File metadata
- Download URL: dagrun-0.1.0.tar.gz
- Upload date:
- Size: 46.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
085f170e1ba5096f461e97245cf49680829df627dedbc561c2a28df40dd290cb
|
|
| MD5 |
2b1e63f00f2572ebe3665e1a2ca3f47d
|
|
| BLAKE2b-256 |
3640c922ba125b4f4219813f9a80e1a40ac213c521c7a34c0157bdf864c987b0
|
File details
Details for the file dagrun-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dagrun-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe4b3523c01cb0dd8177d03f065e676d6de5278c972781ae8fc17922e2b122e5
|
|
| MD5 |
ed48838a75e4223d7f8c092b5ba4de2c
|
|
| BLAKE2b-256 |
2583eb9e3171e0220d8efc17c8e14de170f459db2366d599f702f01c8ea95235
|