<@ULVA73B9P> how can I migrate from v2 sdk to v3? ...
# ask-marvin
d
@Marvin how can I migrate from v2 sdk to v3? I’m currently creating deployments from my flows then applying each deployment
m
Migrating from Prefect 2.x to 3.x involves several key changes, particularly in how you handle deployments. Here's a concise guide to help you transition: 1. Deployment Changes: In Prefect 3.x, the
Deployment.build_from_flow()
method has been removed. Instead, you should use the
from_source()
method to create deployments. Here's a basic example of how you might do this:
Copy code
python
   from prefect import flow
   from prefect.deployments import Deployment

   @flow
   def my_flow():
       # Your flow logic here

   deployment = my_flow.from_source().deploy(name="my_deployment")
2. Agents to Workers: Prefect 3.x replaces agents with workers. You'll need to configure your infrastructure using work pools instead of the previous infrastructure blocks. More details can be found here. 3. Pydantic V2: Prefect 3.x uses Pydantic V2, which might require adjustments if your flows rely on Pydantic models. 4. Handling Futures: In Prefect 3.x, futures returned by
.map
or
.submit
are synchronous. You must resolve them by passing them to another task, returning them, or manually calling
.result()
or
.wait()
. 5. Upgrade Guide: For more detailed information on upgrading, refer to the upgrade guide. These changes should help you adjust your workflow with minimal disruption. If you have specific questions about your code or setup, feel free to ask!