Hello everyone, is there any code to help with monitoring the state of a flow from code running within the flow? I know how to do it if you have a flow run id already, but I’m not sure how to get this from within that flow. Thanks.
k
Kevin Kho
02/23/2022, 8:23 PM
I think that requires GraphQL queries, can you tell me the use case?
d
Daniel Komisar
02/23/2022, 8:35 PM
Yes that is what I figured, I’m just not sure how to craft the query. I don’t have any info on the flow run except that it’s the one that the code is being executed in.
Some of the code are executing needs to be explicitly cancelled during some error conditions, otherwise it will run forever. We can cancel the task, but this doesn’t actually stop the processes we’ve kicked off. What I thought I’d do is monitor the task or flow state and when it is cancelled and then use that to stop and cleanup after the subprocesses.
z
Zanie
02/23/2022, 8:35 PM
The flow run id is available in the context
prefect.context.get("flow_run_id")
d
Daniel Komisar
02/23/2022, 8:35 PM
Great this is just what I needed.
k
Kevin Kho
02/23/2022, 8:38 PM
Oh I misread the first question. Yes just use Michael’s suggestion inside a task or state handler
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.