<@ULVA73B9P> If I have a code file `test_flow.py` ...
# ask-marvin
g
@Marvin If I have a code file
test_flow.py
defining
my_flow
and a code file
prod_flow.py
defining
my_flow
, I then deploy them using:
Copy code
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?
m
thought for 42.7 seconds
Based on the research, here's how Prefect handles your scenario: When you deploy flows with the same name from different files, Prefect will treat them as the same flow definition but with different deployments. This means: 1. When you execute the "test" deployment, it will run the flow implementation from
test_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:
Copy code
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:
Copy code
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.