Hello, When we build a deployment, the deployment ...
# prefect-community
h
Hello, When we build a deployment, the deployment gets the name of either the function that starts the flow, or the flow name argument in the function itself. But it doesn't take the deployment name itself that we specify with the
--name
argument, and there isn't an argument to specify the flow name in the CLI (unless we do it by hand after the creation of the file). I believe that's not a good behaviour since it complicates managing lot of flows. For instance let's assume we have this structure:
Copy code
- Flows
--| - flow_1.py
--| - flow_2.py
If both files look like this
Copy code
@task
def test_task():
   return 'hello'
@flow
def main():
   message = test_task()
   print(message)
if __name__= '__main__':
  main()
The flow name in the yaml file will be the same (main), and that will put confusion on the prefect UI. As we'll have the same flow but with different deployment names, but it's not the same flow code under the hood. Is there a better way to handle this apart from changing the name after the creation of the yaml file ?
1
k
You can add
--output custom-name
to your
deployment build
. Learn more here
h
Yeah but that's for the name of the file of the deployment, not the name of the flow that's going to show into the UI
k
That is true. You can set a custom name for your flow using:
@flow(name='main-1')
. It is a good practice not to have two flows with the same name
h
Yes, but I believe it's better to have it as an option on a deployment process (CI/CD) so that mistakes in the dev process don't impact already existing flows. Especially if we have shared repos with big teams (10 developers or more).
k
I’m not sure if I understood your use case. Have you considered using different work queues for different flows (like
dev
and
prod
)?
h
Yes I did that. I think to explain better, I will have to manage multiple flows (in the hundreds). So I wanted to make sure that naming mistakes don't happen so I have to manage it on the CI/CD part and not delegate it to the developers. That's why I think it's better to be able to alter the flow name at build CLI so that you can force a unique name for flows on the UI.
k
Thanks for the feedback. @Anna Geller , @Zanie What do you think?