Matias Godoy

10/07/2020, 3:47 PM
Hi guys! I wanted to ask a question about *flow labels*; Right now I have two environments (DEV and PROD) and I have 2 different Kubernetes Agents (one with label
and the other with label
), which also means that I'm using Docker Storage for the flows. Inside my flow I set the labels like this:
flow.environment = LocalEnvironment(labels=['dev'])
The thing is that I'd like the flow label to be "dynamic" in the sense that if I register that flow from a development environment, the label is automatically set to
, but if I want to register it for production, I'd like the flow label to be
. For now I register the flows from my own laptop, which automatically generates the Docker image and uploads it to my ECR for the Agents to use. Maybe I'm wrong with this, but I guess that if I set an environment variable in my local computer, and make the flow code something like
flow.environment = LocalEnvironment(labels=[my_env_var])
it will not work, because that variable will not exist in the container that runs the flow. Is this correct? Another alternative would be to be able to set flow labels when registering the flow using the CLI. Something like
prefect register flow --file --name My-Flow --label dev
, but according to the CLI help,
is not a valid parameter when registering flows. Do you have any recommendations for setting flow labels dynamically depending on the environment they where registered? Thanks!


10/07/2020, 4:08 PM
Hey @Matias Godoy these are all great questions! ā€¢ If you set your
then it will work because that variable is retrieved and set at registration time (aka on the machine you are registering from) ā€¢ I agree that we should definitely expose a way to set the labels through the CLI command! Would you mind opening an enhancement request on the repo for this? There is actually a new feature coming out very soon (most likely next week) where you can actually edit/adjust labels for your flows after they are registered! Meaning if you wanted to you could register a flow to dev, ensure it works, then update its label for prod. Stay tuned for that šŸ™‚
šŸ‘ 1

Matias Godoy

10/08/2020, 8:31 AM
That is a really good feature! I'll definitely open an enhancement request. Thanks a lot for your answer!