<@ULVA73B9P> is it possible to change the tags on ...
# ask-marvin
j
@Marvin is it possible to change the tags on a sub-flow based on the parent flow's parameters? For example, I want to run a parent flow in debug mode by passing a "debug" parameter and then have all the sub-flows get tagged as "debug", too.
m
In Prefect 2.x, assigning tags to flows and sub-flows is a deployment concern rather than at the code level of tasks and flows. You can assign tags when you create a deployment that specifies the entry point to your flow code. To answer your question about dynamically changing tags based on the parameters of a parent flow, the documentation excerpts provided do not explicitly explain how to modify tags based on parameters. However, generally in Prefect, flow parameters are used within the flow definition to control its behavior. Since the deployment is what determines the tags for a particular run of a flow, you would need to have some logic to determine the tags at deployment time based on the input parameters if it's possible to dynamically set deployment configurations. Typically, when creating deployments via Prefect's CLI or Python client, you would specify static configurations, including tags. To have dynamic tags based on parameters from a parent flow, you might need to implement custom logic outside of Prefect's standard deployment flow that can interpret parameters from an initiating parent flow run and then, perhaps through an API call or cli command, trigger sub-flow deployments with the appropriate tags. For a more detailed solution or to understand if there's direct support for such a feature in Prefect, I would recommend looking into the latest Prefect documentation or reaching out to their support/community channels for advice. If you need me to further search GitHub issues to check if this feature has been discussed or requested, I can assist with that as well.
j
@Marvin So the standard way of doing this is to create production and development deployments for the same code but with potentially different entry points?
m
In Prefect 2.x, deployment patterns have changed from Prefect 1.x. Prefect 2.x no longer requires flow pre-registration. Instead, you create deployments that specify the entry point to your flow code. For each deployment of the same flow, you can specify different details such as: - Where to run your flow (your Infrastructure, such as a Docker Container, Kubernetes Job, or ECS Task). - When to run your flow (a schedule like Interval, Cron, or RRule). - How to run your flow (execution details such as parameters, task concurrency, etc.). Creating different deployments for the same flow with potentially different entry points, schedules, infrastructures, and execution details is a standard way to handle various environments, like development and production, within Prefect 2.x. You can tailor each deployment to meet the requirements of its intended environment (development, testing, staging, production) by varying these details. This makes it flexible for users to manage their flows across different stages of development and different runtime environments. You can have core logic shared across these deployments while tweaking only specific details relevant to each environment.
👍 1