Skip to content

How do I write a sensor or schedule that requests a run for every partition on every tick? #15532

Answered by sryza
sryza asked this question in Q&A
Discussion options

You must be logged in to vote

Below is an example that launches a separate run for every partition. To launch a single run that covers a range of partitions, refer to #14622.

from dagster import (
    schedule,
    DynamicPartitionsDefinition,
    asset,
    define_asset_job,
    Definitions,
    RunRequest,
)

partitions_def = DynamicPartitionsDefinition(name="fruits")


@asset(partitions_def=partitions_def)
def asset1():
    ...


@schedule(job=define_asset_job("job1", selection=[asset1]), cron_schedule="@daily")
def schedule1(context):
    partition_keys = partitions_def.get_partition_keys(dynamic_partitions_store=context.instance)
    return [
        RunRequest(
            partition_key=partition_key,
            

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@sryza
Comment options

@yashafromrussia
Comment options

@sryza
Comment options

@somiandras
Comment options

@sryza
Comment options

Answer selected by sryza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: partitions Related to Partitions
4 participants