I am stuck on how to use the new Definitions API t...
# ask-community
m
I am stuck on how to use the new Definitions API to include a schedule definition for a partitioned asset to be rematerialized daily.
Copy code
ScheduleDefinition(
    job=define_asset_job(
        "partitioned_assets_job",
        selection=AssetSelection.all(),
        partitions_def=StaticPartitionsDefinition(["red", "blue"]),
    ),
    cron_schedule="45 0 * * *",
    execution_timezone="America/Chicago",
),
This is close, but not right because the partition key is not making its way into the asset.
j
Hi @marcos for static partitioned jobs, you’ll need to write out the schedule using the
schedule
decorator so that you can specify which partitions should be materialized yours would look something like this
Copy code
my_job = define_asset_job(
        "partitioned_assets_job",
        selection=AssetSelection.all(),
        partitions_def=StaticPartitionsDefinition(["red", "blue"]),
    )

@schedule(cron_schedule="45 0 * * *", job=my_job)
def red_schedule():
    request = my_job.run_request_for_partition(
        partition_key="red", run_key=None
    )
    yield request
this docs section goes over how to set this up https://docs.dagster.io/concepts/partitions-schedules-sensors/schedules#static-partitioned-jobs
m
Ahhh I had read that section so many times, but makes it land. Thank you @jamie!