Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Dagster io Dagster AutomationCondition API

From Leeroopedia


Knowledge Sources
Domains Data_Engineering, Scheduling
Last Updated 2026-02-10 00:00 GMT

Overview

Concrete tool for defining declarative materialization conditions provided by the Dagster core library.

Description

AutomationCondition is an abstract base class that defines the interface for declarative automation policies. It provides static factory methods for common conditions (eager(), on_cron(), on_missing(), any_deps_updated()) and supports boolean composition via &, |, and ~ operators.

Each condition is evaluated by the Dagster daemon at regular intervals. When a condition evaluates to True for an asset (or a subset of its partitions), the daemon emits a materialization request. Conditions are attached to assets via the automation_condition parameter of the @asset decorator.

Usage

Import and use when you want an asset to be automatically materialized based on declarative conditions. Pass the condition to the automation_condition parameter of @dg.asset. The Dagster daemon must be running for conditions to be evaluated.

Code Reference

Source Location

  • Repository: dagster
  • File: python_modules/dagster/dagster/_core/definitions/declarative_automation/automation_condition.py:L64

Signature

class AutomationCondition(ABC, Generic[T_EntityKey]):
    @staticmethod
    def eager() -> AndAutomationCondition:
        """Materialize when any dependency updates."""
        ...

    @staticmethod
    def on_cron(cron_schedule: str, cron_timezone: str = "UTC") -> AndAutomationCondition:
        """Materialize on cron after all deps updated since last tick."""
        ...

    @staticmethod
    def on_missing() -> AndAutomationCondition:
        """Materialize new partitions that are added after this condition is applied."""
        ...

    @staticmethod
    def any_deps_updated() -> AutomationCondition:
        """True when any upstream dependency has been updated."""
        ...

Import

from dagster import AutomationCondition

I/O Contract

Inputs

Name Type Required Description
cron_schedule str Yes (for on_cron) A cron expression defining the schedule (e.g., "0 0 * * 1" for every Monday).
cron_timezone str No IANA timezone for cron evaluation (default "UTC").

Outputs

Name Type Description
condition AutomationCondition An automation condition object passed to @asset(automation_condition=...). Evaluated by the Dagster daemon to determine when materialization should occur.

Usage Examples

Weekly Report with Cron Condition

import dagster as dg

@dg.asset(
    automation_condition=dg.AutomationCondition.on_cron("0 0 * * 1"),  # Every Monday
    kinds={"duckdb"},
)
def weekly_report(duckdb: DuckDBResource) -> dg.MaterializeResult:
    ...

Eager Derived Data

import dagster as dg

@dg.asset(
    automation_condition=dg.AutomationCondition.eager(),  # On any dep update
    deps=["raw_data"],
)
def derived_data(duckdb: DuckDBResource) -> None:
    ...

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment