pip install dagster dagster-webserver★dagsteris the library;dagster-webserverserves the UI. Python 3.9+. Scaffold a project withdg(card 10).import dagster as dg @dg.asset def raw_users() -> list[dict]: return fetch_users()★An asset is a function that produces a persistent object (a table/file/model). The function name is the asset key; its return value is the data.@dg.asset(group_name="ingest", kinds={"python", "s3"}, description="raw user records")Organize the graph withgroup_name, tag technologies withkinds(icons in the UI), and document withdescription.dagster dev # UI at http://127.0.0.1:3000★Launches the webserver + daemon. Click an asset → Materialize to run it and see lineage, runs, and metadata.
@dg.asset def clean_users(raw_users): # arg name = upstream asset return [normalize(u) for u in raw_users]★Depend on another asset by naming it as a parameter — Dagster passes the upstream's loaded value and draws the edge automatically. This is the core idea.@dg.asset(deps=[raw_events]) # dependency without loading the value def report(): ...Usedeps=for an ordering dependency when you don't need the upstream's Python value (e.g. it wrote to a DB the SQL reads).@dg.multi_asset(specs=[dg.AssetSpec("a"), dg.AssetSpec("b")]) def both(): ...Produce several assets from one computation with@multi_asset.dg.load_assets_from_modules([my_pkg.assets])Auto-collect every asset in a module/package instead of listing them by hand.
return dg.MaterializeResult(metadata={ "rows": len(df), "preview": dg.MetadataValue.md(df.head().to_markdown())})★Attach run metadata (row counts, previews, plots, links) to a materialization — it shows on the asset in the UI over time.@dg.asset_check(asset=clean_users) def no_nulls(clean_users): return dg.AssetCheckResult(passed=all(u["id"] for u in clean_users))★Asset checks are data-quality tests bound to an asset (nulls, ranges, freshness, row counts) — they run with the asset and gate downstreams.@dg.asset(check_specs=[dg.AssetCheckSpec("rowcount", asset="t")])Emit checks from inside the asset function too (yieldAssetCheckResults).