Hey Everyone, Im currently trying to get a better grasp on how to best interact with past results of flows. Something similar to what metaflow has https://docs.metaflow.org/metaflow/tagging would be great. Is there some preferred way to do this?
Something like:
Copy code
with Flow("A Flow") as my_flow:
task_res = my_task()
task.run()
Hi @Moritz Rocholl - if I understand correctly, you should be able to do this:
Copy code
with Flow("A Flow") as my_flow:
task_res = my_task()
last_flow_state = task.run()
print(last_flow_state)
# <Success: "All reference tasks succeeded.">
the return of
flow.run
will contain the state of the run and all its associated tasks 🙂
👍 1
m
Moritz Rocholl
03/08/2021, 3:38 PM
Hey. thanks for the reply. You are right that is the obvious solution, especially if I have caching in place and can simply use the results of the last run.
Nevertheless, if I am not mistaken, that only works for local runs triggered directly when called from within the same process locally. It does not work for server triggered runs, or does it?
n
nicholas
03/08/2021, 3:40 PM
That's correct, to access runs created through the API (Prefect Server or Cloud), you'll need to make a query to the API, something like:
Copy code
query {
flow_run(where: { flow_id: { _eq: "<<YOUR FLOW ID>>" } } ) {
id
state
# any other data you're interested in
}
}
m
Moritz Rocholl
03/08/2021, 3:47 PM
Thank you! Il look into that.
On another note, do you know of any resource on how to best structure result storage? Does prefect have a stance regarding that?
n
nicholas
03/08/2021, 4:33 PM
Hm, I think we typically structure results according to flow run id, which ensures they're unique; otherwise the structure is largely up to how you need to parse the data later.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.