Aric Huang
07/01/2025, 5:37 PMload_flow_from_script
is no longer available in the Python SDK. is there an equivalent function in 3?Marvin
07/01/2025, 5:37 PMMarvin
07/01/2025, 5:38 PMload_flow_from_script
function has been replaced with a more streamlined approach using the from_source()
method. Instead of loading a flow directly from a script, you'll want to use the following pattern:
python
from prefect import flow
# Deploy a flow from a local script
flow.from_source(
source="path/to/your/script.py",
entrypoint="script.py:flow_function_name"
).deploy(name="your-deployment-name")
This new approach is part of Prefect 3.x's broader redesign that emphasizes more robust deployment mechanisms and better integration with modern infrastructure patterns. The from_source()
method is more flexible and can handle both local scripts and remote sources.
For example, if you previously had:
python
# Prefect 2.x (old way)
from prefect.utilities.load import load_flow_from_script
flow = load_flow_from_script(path="path/to/script.py", flow_name="my_flow")
You would now use:
python
# Prefect 3.x (new way)
from prefect import flow
deployment = flow.from_source(
source="path/to/script.py",
entrypoint="script.py:my_flow"
).deploy(name="my-deployment")
This change aligns with Prefect 3.x's shift toward work pools and workers (replacing the older agent-based system) and provides a more consistent way to handle flow deployments.Aric Huang
07/01/2025, 6:13 PMprefect deployment build
CLI command, which also seem to be removed in 3. Is there an equivalent in 3?