Andrew
12/01/2023, 2:38 AMMarvin
12/01/2023, 2:38 AMKubernetesJob
infrastructure that you can use to automatically generate a manifest that runs your flow as a Kubernetes deployment. You can find more details in the Prefect Release Notes.
For managing concurrency, Prefect also provides a feature called concurrency limits. You can configure the concurrency capacity within a specific concurrency limit. The rate at which these slots "decay" or refresh is controlled by the slot_decay_per_second
parameter. Higher values for this parameter result in slots becoming available more quickly. You can read more about this in the Prefect Concurrency Limits Guide.
Regarding Dask and Ray task runners, they provide an execution environment for tasks. In a flow decorator, you can specify a task runner to run the tasks called in that flow. The default task runner is the ConcurrentTaskRunner
. To run tasks asynchronously, use the .submit
method when you call them. More details can be found in the Prefect Dask and Ray Task Runners Guide.Andrew
12/01/2023, 3:04 AMMarvin
12/01/2023, 3:04 AM.submit
method when you call them.
For long-running tasks, such as a training step, you can use subflows. Subflows are essentially flows called from within a flow. This allows you to run multiple tasks or child flows in parallel. You can use something like asyncio.gather
to call the flow object itself in a parent flow.
The pod running the original flow does not necessarily have to keep running the entire time training is happening. Once the training task or subflow is kicked off, it can run independently. The original flow can then continue on to evaluation, deployment, etc., without waiting for the training to finish.
However, the best practice would depend on your specific use case and requirements. For example, if the evaluation and deployment steps depend on the results of the training, then you would need to ensure that the training has completed before moving on to these steps. On the other hand, if these steps are independent, they can be run in parallel with the training.Andrew
12/01/2023, 3:07 AMMarvin
12/01/2023, 3:07 AMAndrew
12/01/2023, 3:01 PMMarvin
12/01/2023, 3:02 PM