Tom Matthews
11/06/2023, 11:44 AMNate
11/07/2023, 1:57 AMrun_deployment
as needed within your parent flow, the flows you invoke with this will be treated / tracked as a subflow of the calling parent (however you can also put this call in a task, if you wanted to leverage the .map
/ .submit
interface of tasks with deployments) - here's a run_deployment example where we distribute work over child flows
• create deployments for each of these flows that point at the appropriate work pool
◦ in your prefect.yaml, you can set your work pool like this (or make things DRY with yaml defs) and then when this deployment runs, the worker will use that work pools job template when submitting to the infrastructure
◦ you can override work pool config (like cpu, mem req etc) on a per deployment basis like this (this examples happens to override env on the work pool, for just this deployment)Tom Matthews
11/15/2023, 7:44 AMAndrew
12/02/2023, 4:58 AMNate
12/02/2023, 10:32 PMrun_deployment(..., timeout=0)
to trigger the deployment and return immediately ("fire and forget") if you want to avoid blocking the parent flow. one consequence being that if your parent flow needs the result of that deployment you triggered, you'll have to otherwise poll the API to see when it finished and you'll have to persist_result=True
(with something like result_storage=S3.load("my-s3-bucket")
) on that deployment you triggered so you can fetch that result in the parent via the api ( e.g. (await client.read_flow_run(...)).state.result()
). but lots of times, you can just use events to react to the completion of whatever you triggered with run_deployment
so that you don't have worry about polling logic (instead of gathering child results back in the parent)
secondly, we have some work in flight now that will make this easier, basically you'll be able to .submit
native tasks / subflows from the parent flow as backgrounds processes, without blocking the main process - more to come on that soon!Andrew
12/03/2023, 5:49 AMTom Matthews
12/04/2023, 2:43 PMsecondly, we have some work in flight now that will make this easier, basically you'll be able toReally looking forward to this, i'm fighting with asyncio in running flows concurrently at the moment. Any idea when this might be released?native tasks / subflows from the parent flow as backgrounds processes, without blocking the main process - more to come on that soon!.submit
Nate
12/04/2023, 2:47 PMTom Matthews
12/04/2023, 2:48 PMNate
12/04/2023, 3:00 PMI guess with tasks you don't need to worry as much as if they're IO bound you can just make them synchronous and just use the ConcurrentTaskRunner and submit them?with tasks, we can already sort of "background" them with
.submit
(how exactly you decide to do that, yeah, depends on the details of your use case) but not so much with subflows (they're part of the main process historically). so the plan is to allow you to submit stuff (tasks, subflows etc) as a sort of sidecar process to avoid blocking the main process, we'll share details on how that'll look later on 🙂