https://prefect.io logo
Title
h

Hamza Naanani

09/06/2022, 11:53 AM
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:
- Flows
--| - flow_1.py
--| - flow_2.py
If both files look like this
@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

Khuyen Tran

09/06/2022, 2:57 PM
You can add
--output custom-name
to your
deployment build
. Learn more here
h

Hamza Naanani

09/06/2022, 3:10 PM
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

Khuyen Tran

09/06/2022, 3:16 PM
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

Hamza Naanani

09/06/2022, 3:42 PM
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

Khuyen Tran

09/06/2022, 3:58 PM
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

Hamza Naanani

09/07/2022, 12:56 PM
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

Khuyen Tran

09/07/2022, 2:56 PM
Thanks for the feedback. @Anna Geller , @Zanie What do you think?