Skip to content

How to use run_requests and dynamic_partitions_requests with SensorResult #23248

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

You must be logged in to vote

here's a code snippet

dynamic_colors = DynamicPartitionsDefinition(name="dynamic_colors")

@asset(
    partitions_def=dynamic_colors,
)
def colors_asset(context: AssetExecutionContext):
    context.log.info(context.partition_key)


@sensor(asset_selection=[colors_asset])
def run_colors():
    colors = ["purple", "orange"]
    run_requests = []
    for color in colors:
        run_requests.append(RunRequest(run_key=color, partition_key=color))

    return SensorResult(
        run_requests=run_requests,
        dynamic_partitions_requests=[AddDynamicPartitionsRequest(partitions_def_name="dynamic_colors", partition_keys=colors)]
    )

defs = Definitions(assets=[colors_asset], sensors=[run_…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by garethbrickman
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: sensor Related to Sensors
2 participants
Converted from issue

This discussion was converted from issue #23211 on July 25, 2024 21:58.