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.
Metadata
Release files for dagrun 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dagrun-0.1.0.tar.gz | 46.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dagrun-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.7 kB
Release files / dagrun-0.1.0.tar.gz
| Download URL | dagrun-0.1.0.tar.gz |
|---|---|
| Size | 46.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
085f170e1ba5096f461e97245cf49680829df627dedbc561c2a28df40dd290cb
|
|
BLAKE2b-256 checksum How to use checksums |
3640c922ba125b4f4219813f9a80e1a40ac213c521c7a34c0157bdf864c987b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / dagrun-0.1.0-py3-none-any.whl
| Download URL | dagrun-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe4b3523c01cb0dd8177d03f065e676d6de5278c972781ae8fc17922e2b122e5
|
|
BLAKE2b-256 checksum How to use checksums |
2583eb9e3171e0220d8efc17c8e14de170f459db2366d599f702f01c8ea95235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|