Subchapter 2.6
references/automation/choosing-automation.mdMarkdown2 KBView on GitHub
Dagster provides three main approaches to automation: schedules for time-based execution, sensors for event-driven triggers, and declarative automation for asset-centric condition-based orchestration.
Choose your automation approach based on your use case:
A job is a selection of assets to execute together. Jobs are the unit of execution that schedules and sensors trigger.
import dagster as dg
# Define a job that selects specific assets
analytics_job = dg.define_asset_job(
name="analytics_job", selection=["sales_data", "customer_metrics"]
)Jobs can also select assets by tags, groups, or patterns:
# Select all assets with a specific tag
tagged_job = dg.define_asset_job(
name="daily_job", selection=dg.AssetSelection.tag("priority", "high")
)
# Select all assets in a group
group_job = dg.define_asset_job(name="etl_job", selection=dg.AssetSelection.groups("etl"))Schedules: Time-based execution with cron expressions. Best for predictable, recurring tasks.
Sensors: Poll for external events and trigger runs. Best for file arrivals, API events, or custom conditions.
Declarative Automation: Set conditions directly on assets. Best for complex dependency logic and asset-centric workflows. Automatic handling of asset and partition state and dependencies.