Custom Prefect Flow Decorator: Handling Multiple Deployments with Dynamic Entrypoint Assignment #16682
Unanswered
abhishek815
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hey @abhishek815! I think you should be able to get this to work, but you'll need to ensure that the object returned by |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I created a custom flow decorator that wraps around the Prefect
@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:However, when I run the deployments (locally and in the cloud), I get the following error
(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 bedeploy1
anddeploy2
(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
ordeploy2
) 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.Beta Was this translation helpful? Give feedback.
All reactions