Chip Foundry Services Request Assessment

Dagster

Dagster is an open-source data orchestrator built around software-defined assets. Instead of scheduling a chain of tasks, you declare the data products that should exist (tables, files, ML models, reports) and the dependencies between them, and Dagster decides what to run, tracks what has been produced, and shows whether each asset is fresh and passing its checks.

What Is Dagster?

  • Origin. Dagster was created by Nick Schrock (a co-creator of GraphQL) and first released in 2018 by the company then called Elementl, now Dagster Labs. The core is open source under the Apache 2.0 license, with a hosted commercial offering called Dagster+.
  • Asset-centric model. The central question changes from "which computations should run, in what order?" to "which data products should exist, and are they up to date?" A pipeline becomes a graph of assets, each defined by a Python function that produces it and by the upstream assets it reads.
  • Software-defined asset (SDA). An asset is a function decorated with `@asset`. Dagster records its lineage, materialization history, metadata, and check results, which produces a catalog of data products without separate documentation.
  • Types and I/O separation. Asset functions can use Python type annotations, and Dagster can validate typed run-time config and, through I/O managers, control how an asset's value is stored and loaded. Resources hold the connections to external systems, so the business logic does not contain connection code and can be tested with a substitute resource.
  • Other building blocks. Ops and jobs (the task-style layer underneath), schedules and sensors (time-based and event-based triggers), partitions, asset checks, and a web UI with an asset catalog and lineage graph.
An Asset Graph in Dagster Each box is a software-defined asset; arrows are dependencies taken from function parameters raw_transactions group: raw clean_transactions group: features customer_features group: features check: no_null_features resource: warehouse Dagster records lineage, materialization history, metadata, and check results for every asset

Why Dagster Is Used for Data and ML Pipelines

  • Models as assets. A trained model is a data product like a table. With the training data, parameters, and code modeled as upstream assets and metadata, the lineage of each model version can be recorded by the platform and not reconstructed by hand. Reproducibility still depends on pinning code and data versions.
  • Quality gates. Asset checks run against an asset and report pass or fail. Blocking checks can stop downstream assets from running when an upstream asset fails them.
  • Partitions. Daily, weekly, static, or multi-dimensional partitions let Dagster track which slices of an asset exist, which are missing, and which can be backfilled.
  • Catalog and observability. The UI shows asset status, last materialization, metadata, and lineage in one place, for engineers and ML users alike.
  • Event-driven runs. Sensors react to external events such as a new file in object storage, and automation conditions can materialize assets when upstream assets update.
  • Integrations. Libraries exist for dbt, Spark, Snowflake, BigQuery, Airbyte, Fivetran, and other tools, so existing jobs can appear as assets.

Core Concepts in Code

The labs run against Dagster 1.13 with an in-memory resource that stands in for a warehouse. Lab 1 defines three assets, a resource, and an asset check, then materializes them in one process.

# Software-defined assets, a resource, and an asset check, run in memory.
import pandas as pd
import dagster as dg

class WarehouseResource(dg.ConfigurableResource):
    """I/O boundary. In production this would wrap a database engine."""
    seed: int = 7

    def transactions(self) -> pd.DataFrame:
        import numpy as np
        rng = np.random.default_rng(self.seed)
        n = 200
        return pd.DataFrame({
            "customer_id": rng.integers(1, 21, n),
            "amount": rng.gamma(2.0, 30.0, n).round(2),
            "date": pd.date_range("2024-01-01", periods=n, freq="6h"),
        })

@dg.asset(group_name="raw", description="Raw transactions from the warehouse")
def raw_transactions(warehouse: WarehouseResource) -> pd.DataFrame:
    return warehouse.transactions()

@dg.asset(group_name="features", description="Transactions without extreme outliers")
def clean_transactions(raw_transactions: pd.DataFrame) -> pd.DataFrame:
    df = raw_transactions.dropna()
    return df[df["amount"] < df["amount"].quantile(0.99)]

@dg.asset(group_name="features", description="Per-customer features for ML training")
def customer_features(clean_transactions: pd.DataFrame) -> pd.DataFrame:
    return (clean_transactions.groupby("customer_id")
            .agg(transaction_count=("amount", "count"), total_spend=("amount", "sum"),
                 avg_spend=("amount", "mean"), last_transaction=("date", "max"))
            .reset_index())

@dg.asset_check(asset=customer_features)
def no_null_features(customer_features: pd.DataFrame) -> dg.AssetCheckResult:
    nulls = int(customer_features.isnull().sum().sum())
    return dg.AssetCheckResult(passed=nulls == 0, metadata={"null_count": nulls})

if __name__ == "__main__":
    result = dg.materialize(
        [raw_transactions, clean_transactions, customer_features, no_null_features],
        resources={"warehouse": WarehouseResource()},
    )
    print("run succeeded:", result.success)
    df = result.output_for_node("customer_features")
    print("customer_features:", df.shape, "columns:", list(df.columns))
    print("checks:", [(c.check_name, c.passed) for c in result.get_asset_check_evaluations()])
    print("materialized assets:", sorted(e.asset_key.to_user_string() for e in result.get_asset_materialization_events()))

Lab 1 returns a successful run. `customer_features` has 20 rows (one per customer) and 5 columns, the check `no_null_features` passes, and `raw_transactions`, `clean_transactions`, and `customer_features` are each materialized once. The dependency graph comes from the function parameters, because `clean_transactions` takes a parameter named `raw_transactions`. When an upstream asset has a different name than the parameter, `ins={"name": AssetIn("upstream")}` maps them. The resource shows the separation of logic and I/O: swapping `WarehouseResource` for a different class changes the data source without changing the asset code.

In a deployment, the assets, checks, and resources are collected in a `Definitions` object, for example `Definitions(assets=[...], asset_checks=[...], resources={"warehouse": WarehouseResource(...)})`, which the Dagster webserver and daemon load.

Lab 2 shows a partitioned asset. The function receives `context.partition_key` and produces one slice of data per call.

# Daily partitions: the same asset, materialized one partition at a time.
import pandas as pd
import dagster as dg

daily = dg.DailyPartitionsDefinition(start_date="2024-01-01")

@dg.asset(partitions_def=daily)
def daily_features(context: dg.AssetExecutionContext) -> pd.DataFrame:
    day = context.partition_key                      # "YYYY-MM-DD"
    return pd.DataFrame({"date": [day], "feature": [len(day)]})

if __name__ == "__main__":
    for key in ["2024-01-01", "2024-01-02"]:
        r = dg.materialize([daily_features], partition_key=key)
        print(key, "->", r.success, r.output_for_node("daily_features").to_dict("records"))
    # unmaterialized partitions are a property of the instance, so show the key set instead
    print("partition keys on 2024-01-05:",
          daily.get_partition_keys(current_time=pd.Timestamp("2024-01-05").to_pydatetime()))

Two partitions materialize independently, and the partition set for a given date is computed from the definition. In a running deployment the instance stores which partitions exist, so the UI can show missing or stale ones and launch backfills.

Declare assets
@asset functions, upstream assets as parameters
Attach the surroundings
Resources
connections and I/O kept out of asset logic
Asset checks
blocking checks protect downstream assets
Partitions
time or static slices with backfills
Collect in Definitions
assets, checks, resources, schedules, and sensors
Trigger materialization
Schedule
time based
Sensor
external event such as a new file
Manual or backfill
from the UI or the CLI
Observe
catalog, lineage, freshness, and check results in the UI

Dagster Compared with Other Orchestrators

The comparison depends on version and on how each tool is used, so treat it as a summary of defaults.

AspectDagsterApache AirflowPrefect
Primary modelAssets with dependencies, plus ops and jobsDAGs of tasks, with assets (formerly datasets) for data-aware schedulingPython flows and tasks
Data lineageNative for assetsAvailable through assets and external toolsMostly through external tools and artifacts
Data qualityAsset checks in the asset graphOperators and external frameworksTask logic and external frameworks
Local testingDirect function calls, `materialize()`, substitute resourcesPossible, with more setupDirect flow and task calls
Backfills and partitionsBuilt in for assetsBuilt in for DAG runsParameterized runs and schedules
StrengthsData-product view, lineage, checksLargest ecosystem, mature schedulingPython-native simplicity, hybrid execution

Pick Dagster when the data-product view (lineage, freshness, checks) is what the team needs to manage. Existing large Airflow estates are commonly migrated gradually, not replaced at once.

Practical Guidance

  • Start with assets, not ops. Model the data products first. Use ops and jobs only for work that is not a data product.
  • Keep I/O in resources. Assets that read and write through resources can be tested with a stand-in resource.
  • Make checks blocking where it matters. A check that only logs does not protect downstream assets.
  • Name metadata deliberately. Row counts, schema, and data version in materialization metadata make the catalog useful.
  • Partition by the natural time grain. It makes backfills and late-data handling routine.
  • Pin versions. Pin Dagster and library versions per code location, because APIs such as automation conditions have changed between releases.

Key Takeaways

  • Dagster orchestrates data assets, not just tasks, and records lineage, freshness, and check results for each one.
  • Dependencies come from function parameters, and resources keep I/O out of the business logic.
  • Asset checks and partitions turn quality and backfill handling into part of the pipeline definition.
  • Lab 1 and Lab 2 are runnable examples against Dagster 1.13.

References

Dagster documentation: Software-defined assets, asset checks, partitions, and resources. https://docs.dagster.io
Dagster Labs. Dagster open-source repository. https://github.com/dagster-io/dagster
Apache Airflow documentation: Assets and data-aware scheduling. https://airflow.apache.org/docs/
Prefect documentation: Flows and tasks. https://docs.prefect.io