Jeremy Tee
03/29/2021, 8:56 AMfrom prefect import Task, Flow
from prefect.tasks.prefect import StartFlowRun
class ExtractSomeData(Task)
def run(self):
return {"param-key": "some-random-piece-of-data"}
extract_some_data = ExtractSomeData(name="extract_some_data")
# assumes you have registered a flow named "exampled" in a project named "examples"
flow_run = StartFlowRun(flow_name="example", project_name="examples")
with Flow("parent-flow") as flow:
flow_run.set_upstream(extract_some_data, key="parameters")
but i am wondering what is the parameters
? and whether the param-key
from ExtractSomeData
is passed into the example flow
emre
03/29/2021, 11:09 AMparameters
input for StartFlowRun
accepts a dictionary, and passes each key-value pair as a parameter to the triggered flow.
So this StartFlowRun
call will trigger a flow run for the flow with name example
. The flow run will have a single Parameter
set up. Its name will be "param-key"
, value will be "some-random-piece-of-data"
. Its value can be accessed with the parameter task: Parameter("param-key")
within the flow named "example"
.
In essence, this is analogous to setting inputs in the flow run page of the prefect UI.emre
03/29/2021, 11:11 AMflow.run(parameters={"param-key": "some-random-piece-of-data"})
for the same effect.Dylan
StartFlowRun
Task does not return data, it only kicks off the child Flow Run. If you need to send data back to the parent Flow, put that data in a known place, either by passing a parameter or using the Flow Run ID.Jeremy Tee
03/30/2021, 1:56 AM