I am wondering how I would trigger 1 RunRequest fo...
# ask-community
d
I am wondering how I would trigger 1 RunRequest for a MultiPartitioned asset running on a schedule built from that MultiPartition composed of a time window partition and a static partition definition. The code below triggers 3 run requests (1 for each static partition), and I'd only like to trigger 1 RunRequest for the date tick, with the partition_key_range returning the
start=a|start_date, end=c|end_date
. It doesn't look like there's native support, but I'd appreciate if anyone has done a quick workaround before. I'd like to keep the asset multi-partitioned so I can trigger backfills on specific static partitions, and I do not wish to trigger a job run for each partition because I'm running on Spark. Example code below:
Copy code
daily_multi_partitions_definition = MultiPartitionsDefinition(
    {
        "static": StaticPartitionsDefinition(["a", "b", "c"]),
        "date": DailyPartitionsDefinition(start_date=TEST_DATE),
    }
)

@asset(partitions_def=daily_multi_partitions_definition)
def daily_multi_partitions_asset(context: AssetExecutionContext) -> int:
    return 3


daily_multi_partitions_job = define_asset_job(
    name="daily_multi_partitions_job",
    selection=daily_multi_partitions_asset.key.path,
    partitions_def=daily_multi_partitions_definition,
)

daily_multi_partitions_job_schedule = build_schedule_from_partitioned_job(
    job=daily_multi_partitions_job
)
🤖 1
s
Hi Daniel, you can skip
build_schedule_from_partitioned_job
and use the lower-level
@schedule
API:
Copy code
date_partitions = daily_multi_partitions_definition.partitions_defs[1]

@schedule(date_partitions.get_cron_schedule())
def daily_multi_partitions_job_schedule(context):
    ... return desired run request
d
Thanks @sean! Let me try this out in a little bit.