Create scheduled jobs
Skill cnolanminich/dagster-demo-skills/skills/create-scheduled-jobs
Create a ScheduledJobComponent and add multiple scheduled job instances using asset selection syntax (tags, groups, owners, keys) for flexible scheduling patterns. Demonstrates cron scheduling with various selection criteria.From its SKILL.md
npx -y skills add cnolanminich/dagster-demo-skills --skill create-scheduled-jobsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
5.1 KB, as published. Nobody here has run it
Create Scheduled Jobs Component and Instances
Overview
This skill creates a ScheduledJobComponent that enables flexible scheduling of assets using Dagster's asset selection syntax. Instead of hardcoding asset keys, this approach uses selection strings (tags, groups, owners, kinds) to dynamically select which assets to run on each schedule.
When invoked, this skill will:
- Create a ScheduledJobComponent using
dg scaffold component ScheduledJobComponent - Fill in the component with scheduling logic that accepts cron schedules and asset selections
- Create 3-5 scheduled job instances with different selection patterns
- Validate that all schedules load correctly using
dg check defsanddg list schedules
Asset Selection Syntax Reference
| Pattern | Description | Example |
|---|---|---|
tag:key=value | Assets with specific tag | tag:schedule=daily |
group:name | Assets in a group | group:marketing |
kind:type | Assets of a kind | kind:dbt |
owner:email | Assets with owner | owner:[email protected] |
*pattern* | Key pattern match | *customers* |
tag:a=1 tag:b=2 | Multiple tags (AND) | tag:schedule=daily tag:priority=high |
group:a | group:b | Multiple groups (OR) | group:finance | group:ops |
*asset*+ | Asset + downstream | *revenue*+ |
+*asset* | Asset + upstream | +*orders* |
sel1 - sel2 | Exclusion | tag:daily - tag:test=true |
(a | b) c | Complex combinations | (tag:domain=finance | tag:domain=ops) tag:priority=high |
Skill Workflow
Step 1: Ask User for Scheduling Requirements
Ask what scheduling patterns they need, what asset tags/groups/kinds exist in their project, and whether they want example assets created for demonstration.
Step 2: Create ScheduledJobComponent
uv run dg scaffold component ScheduledJobComponent
This creates defs/components/scheduled_job_component.py. Fill in the component:
"""Scheduled job component for flexible asset scheduling."""
import dagster as dg
from dagster.components import Component, ComponentLoadContext, Resolvable
from dataclasses import dataclass
@dataclass
class ScheduledJobComponent(Component, Resolvable):
"""Component for scheduling assets using flexible selection syntax.
Adds a Dagster schedule for a given asset selection string and cron schedule.
"""
# These fields define the YAML schema via Resolvable
job_name: str
cron_schedule: str
asset_selection: str
def build_defs(self, context: ComponentLoadContext) -> dg.Definitions:
"""Build a scheduled job with flexible asset selection."""
job = dg.define_asset_job(
name=self.job_name,
selection=self.asset_selection,
)
schedule = dg.ScheduleDefinition(
job=job,
cron_schedule=self.cron_schedule,
)
return dg.Definitions(
schedules=[schedule],
jobs=[job],
)
Important: Use @dataclass decorator (required for Resolvable). All dataclass fields automatically become the YAML schema.
Step 3: Create Scheduled Job Instances
For each schedule, scaffold an instance and edit its defs.yaml:
uv run dg scaffold defs <project_name>.components.ScheduledJobComponent daily_finance_job
# defs/daily_finance_job/defs.yaml
type: <project_name>.components.ScheduledJobComponent
attributes:
job_name: "daily_finance_job"
cron_schedule: "0 6 * * *" # 6 AM UTC daily
asset_selection: "tag:schedule=daily tag:domain=finance"
Create 3-5 instances with varied selection patterns (by tag, group, kind, owner) and cron schedules. Use meaningful job names that indicate purpose and timing.
Step 4: Create Example Assets (Optional)
If the user doesn't have assets yet, scaffold example assets with appropriate tags, groups, kinds, and owners so the scheduled jobs have something to select.
Step 5: Validate
# Check definitions load correctly
uv run dg check defs
# Verify all schedules were created
uv run dg list schedules
# Verify jobs and their asset selections
uv run dg list jobs
uv run dg list assets --job daily_finance_job
Success Criteria
- ScheduledJobComponent is created and implemented
- 3-5 scheduled job instances use asset selection syntax (not hardcoded keys)
uv run dg check defspasses without errorsuv run dg list schedulesshows all expected schedulesuv run dg list assets --job <job_name>shows correct asset selections
Additional Resources
- Dagster Schedules: https://docs.dagster.io/concepts/partitions-schedules-sensors/schedules
- Asset Selection Syntax: https://docs.dagster.io/concepts/assets/software-defined-assets#asset-selection-syntax
- Component Guide: https://docs.dagster.io/guides/build/components
- Cron Reference: https://crontab.guru/