mondras05/23/2023, 3:51 PM
Marvin05/23/2023, 3:53 PM
command[^2^]. For example:
After registering the flow, you can deploy it using the
project register-flow ./path/to/file.py:flow_func
command with the
flag, referencing the flow by its name[^2^]:
So, to answer your question: yes, one must register a flow before creating a deployment. [^1^]: Prefect Deployments Overview [^2^]: Prefect Projects Documentation I hope this clears up the fog of confusion. Now, go forth and deploy those flows, brave human!
prefect deploy -f 'My Flow Name'
mondras05/23/2023, 3:56 PM
i set up a scheduled flow without registering. what is best practice? seems like you're saying register first then deploy unless i am mistaken
Marvin05/23/2023, 3:58 PM
function allows you to create a deployment object from a flow without registering it first. This can be useful in certain scenarios where you want to create a deployment directly from a flow object[^1^]. However, it's important to note that this method bypasses the registration process, which means the flow won't be tracked by the Prefect API. The best practice for deploying flows with Prefect is to register the flow first, as this ensures that the flow is tracked and managed by the Prefect API. Once the flow is registered, you can then create a deployment using the
command, as I mentioned in my previous response[^2^]. In summary, while it's possible to create a deployment directly from a flow object using
, the recommended best practice is to register the flow first and then deploy it. This ensures that your flow is properly tracked and managed by the Prefect API. [^1^]: Prefect Deployment.build_from_flow Documentation [^2^]: Prefect Projects Documentation I hope this clears up any lingering confusion. May your flows be ever smooth and your deployments ever successful, dear human.
mondras05/23/2023, 4:01 PM
Marvin05/23/2023, 4:03 PM
function in the Prefect documentation. You can create a deployment directly from a flow object using this method[^1^]. Here's an example of how to use it:
This method allows you to create a deployment without explicitly registering the flow. However, it's important to note that this approach bypasses the registration process, which means the flow won't be tracked by the Prefect API. In summary, you can indeed create a deployment directly from a flow object using
python from my_project.flows import my_flow from prefect.deployments import Deployment deployment = Deployment.build_from_flow( flow=my_flow, name="example-deployment", version=1, work_queue_name="demo", work_pool_name="default-agent-pool", ) deployment.apply()
. However, registering the flow first is still the recommended best practice to ensure proper tracking and management by the Prefect API. [^1^]: Prefect Deployment.build_from_flow Documentation I hope this clears up any confusion. May your deployments be ever successful, and your flows ever smooth, dear human.
mondras05/23/2023, 4:42 PM
and i queried the api and i see the flow id, so it does register the flow? what am i missing
Nate05/23/2023, 5:09 PM
• prefect projects, and its
command, which will call
for you (beta, no well-supported pythonic interface) though each can produce a valid deployment, they are distinct
mondras05/23/2023, 5:12 PM
Nate05/23/2023, 5:12 PM
should work for you without needing to worry about registering any flows - did you encounter an issue with that?
mondras05/23/2023, 5:15 PM
. in 1.0, we registered the flows. i was just trying to make the best decision to implement this. seems like i can go down the register path too in 2.0
Nate05/23/2023, 5:17 PM
mondras05/23/2023, 5:54 PM
mondras05/23/2023, 5:59 PM
Nate05/23/2023, 6:00 PM