https://prefect.io logo
Title
l

Lawrence Finn

08/03/2021, 8:30 PM
If I have a flow run in scheduled state with one parameter, then i try to run that flow again with a different param, why does it cancel the first flow run?
k

Kevin Kho

08/03/2021, 8:32 PM
I’ll try to replicate. Is the process doing a Run with one parameter, and then clicking the Run button and queueing another one with a different value?
l

Lawrence Finn

08/03/2021, 8:33 PM
im playing with having a lambda trigger a flow run, and my code looks something like
flow_run = StartFlowRun(flow_name="ingest-refresher-single", project_name="meow")
    flow_run.run(parameters=dict(id=id))
where id is some parameter the lambda get. I didn’t have my agent running, and I saw that invoking this lambda multiple times with different lambdas caused the prior ones to cancel
k

Kevin Kho

08/03/2021, 8:38 PM
Ah I see.
StartFlowRun
uses an idempotency key. It uses the current task-id. From the docs:
Duplicate flow runs with the same idempotency key will only create a single flow run. This is useful for ensuring that only one run is created if this task is retried. If not provided, defaults to the active task_run_id.
So if you want multiple calls, you need to supply unique idempotency keys to each of those (like a timestamp with second resolution) as a string.
l

Lawrence Finn

08/03/2021, 8:39 PM
ahhh got it
k

Kevin Kho

08/03/2021, 8:43 PM
Btw the new task
create_flow_run
in 0.15.0 provides a better interface than
StartFlowRun
l

Lawrence Finn

08/03/2021, 8:44 PM
oh? i think im on 0.14
what’s different?
k

Kevin Kho

08/03/2021, 8:45 PM
Mainly consistent return values. If you do
StartFlowRun(wait=True)
, it does not return the
id
but if you do
StartFlowRun(wait=False)
it does. So the new paradigm is
create_flow_run
and
wait_for_flow_run
so that the return is consistent
l

Lawrence Finn

08/03/2021, 8:46 PM
ah
if im doing interflow dependency, would i then call create_flow_run then wait_for_flow_run? how would i set upstreams?
k

Kevin Kho

08/03/2021, 8:47 PM
See this
l

Lawrence Finn

08/03/2021, 8:48 PM
ah cool
k

Kevin Kho

08/03/2021, 8:49 PM
And this for the two ways to set upstream tasks in general