https://prefect.io logo
Title
s

Sandeep Aggarwal

07/09/2020, 9:22 AM
Hi all, Is there a way to pass-on current context to next flow run triggered using
FlowRunTask
task? Basically, I am sending some context parameter while creating a flow run using python client's
create_flow_run
method. The flow upon completion triggers other downstream flows. Now, I want the context that I originally sent, available to downstream flows but I haven't had any success so far.
👀 1
l

Laura Lorenz (she/her)

07/09/2020, 2:49 PM
Hi @Sandeep Aggarwal, looks like no since
FlowRunTask
doesn’t accept
context
right now (would eventually expect it to get passed along here https://github.com/PrefectHQ/prefect/blob/master/src/prefect/tasks/prefect/flow_run.py#L109), but I think that is a feature we can add pretty quick! I can make an issue from this ticket but first let me check if that fixes your issue. I think in that situation then your Flow A (kicked off with the python client) would have in it a node of
FlowRunTask
to kick off Flow B. You want to send context from Flow A (lets say
prefect.context.foo=bar
) to that Flow B. I just want to clarify that in practice, Flow A would need to have, or be able to re-derive just the added context (just
foo=bar
) since we probably don’t want to send the entire context object from Flow A straight into the
FlowRunTask
to ship to Flow B (as it has a bunch of other prefect sutff in it too). Would that achieve your use case?
s

Sandeep Aggarwal

07/09/2020, 3:08 PM
Thanks @Laura Lorenz (she/her) for your reply. Yes exactly this is what my use case is and selectively passing the required context to Flow B will work.
l

Laura Lorenz (she/her)

07/09/2020, 3:34 PM
@Marvin open “Expose context arg in FlowTaskRun task”
m
k

karteekaddanki

07/20/2020, 3:34 PM
@Laura Lorenz (she/her) I have a very similar use-case. I am trying to implement backfill functionality on a flow that uses result caching using templated targets. Passing the context to that flow from
FlowRunTask
would be quite a useful feature.