Geoff Irons
07/09/2025, 10:52 PMtest_flow.py
defining my_flow
and a code file prod_flow.py
defining my_flow
, I then deploy them using:
prefect deploy test_flow.py --name test
prefect deploy prod_flow --name prod
Now in the prefect UI I have one flow and two deployments. If I execute the test deployment, does it run the flow in test_flow.py
?
ie: how does prefect handle the case where the deployments have the same flow name, but differing deployments and flow implementation code?Marvin
07/09/2025, 10:52 PMMarvin
07/09/2025, 10:53 PMtest_flow.py
2. When you execute the "prod" deployment, it will run the flow implementation from prod_flow.py
Each deployment maintains its own reference to its source code location, so even though the flows share the same name, they execute their respective implementations correctly.
However, this setup isn't recommended because:
1. It can lead to confusion in the UI since both deployments appear under the same flow
2. It makes it harder to track which implementation is actually being run
3. It could cause issues with flow run history and monitoring
Better Practices:
1. Give your flows different names to clearly distinguish them:
python
# test_flow.py
@flow(name="test_my_flow")
def my_flow():
...
# prod_flow.py
@flow(name="prod_my_flow")
def my_flow():
...
2. Or keep the flows in the same file with clear naming:
python
@flow(name="my_flow_test")
def test_version():
...
@flow(name="my_flow_prod")
def prod_version():
...
This way, you'll have clear separation in the UI and better traceability of which version is running.
For more information about deployment best practices, you can refer to the Prefect deployment documentation.