Abhishek Patel
01/09/2025, 6:13 PM@flow
decorator and adds specific functionalities tailored to my use cases, such as deploying to Prefect cloud. One issue I am running into is creating multiple deployments for a single flow. Since I cannot stack multiple decorators on my method, the other way I thought of accomplishing this is by creating multiple variable references to my custom @flow
wrapper, for example:
from toolkit import custom_flow
from prefect import serve, settings, flow
def test_flow():
print("hello")
deploy1 = custom_flow(
deployment_name="prod",
image_name="<http://custom.azurecr.io/app/project:1|custom.azurecr.io/app/project:1>"
)(test_flow)
deploy2 = custom_flow(
deployment_name="dev",
image_name="<http://custom.azurecr.io/app/project:2|custom.azurecr.io/app/project:2>"
)(test_flow)
However, when I run the deployments (locally and in the cloud), I get the following error
prefect.exceptions.MissingFlowError: Function with name 'test_flow' is not a flow. Make sure that it is decorated with '@flow'.
(running prefect 2.20.10
)
I suspect this is because the entrypoint for the deployment is set to be test_flow
, but in reality it should be deploy1
and deploy2
(depending on the deployment we're running). I tested this theory by manually configuring the entrypoint to for each deployment runner and this worked!
However, to create a robust solution in my custom flow decorator, I thought I would add a custom to_deployment
function to that dynamically sets the correct entrypoint based on the flow object name (e.g., deploy1
or deploy2
) instead of the base function name (test_flow
). Is this the right approach or should I be handling this differently? I know we can define the entrypoint in the deployment yaml config but I want to handle this programmatically within my custom decorator to make the solution more dynamic and reusable, especially when managing multiple deployments for the same flow.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by