Hey <@ULXMV9SD7> (sorry for tagging you again, thi...
# prefect-cloud
n
Hey @Jenny (sorry for tagging you again, this seems to be the best way to get messages seen in this channel, lmk if there is a better option) I'm stuck on trying to figure out a reliable way to cancel a flow with subflows with python. I can cancel a parent flow via the api, via the cli, and via the UI, and in all three cases, my subflows are left in the running state. I can cancel each of them via the CLI, when i copy and paste their id's. I haven't been able to figure out how to get the subflow id's from the api response of the parent flow. Do you think you could help me figure out a solution for this? flow and subflow cancellation is a must for our app
j
Hi! I'm in back to back meetings so sorry for the short reply. I did a draft PR to the docs which I think should answer you question: https://github.com/PrefectHQ/prefect/pull/9753 Basically, there are two types of sub-flow-run. One is kicked off from inside your flow (let's call them standard sub-flow-runs) and the other is kicked off by calling run_deployment. We are working on improving the flow-run/sub-flow-run cancellation experience so that standard sub-flow-runs are deleted when their parent is deleted. If you prefer to be able to cancel sub-flow-runs independently, I recommend using run_deployment.
n
ah, so I call my subflows within my parent flow with the run_deployment func?
that allows for cancellation to work correctly?
wait, does that mean I have to create deployments for each of the flows I want to create as subflows?
yess 1
sorry, just re-read. when you have the chance, can you share the PR that is working on the cancellation of standard subflow runs?
j
Here's one: https://github.com/PrefectHQ/prefect/pull/9731 The others are cloud specific so not open source.