Kledia
12/05/2025, 4:42 PMMarvin
12/05/2025, 4:42 PMMarvin
12/05/2025, 4:46 PMflow.deploy() (or from a remote source with Flow.from_source(...).deploy(...)).
Quick setup (once):
- Create a work pool and start a worker that will pick up your scheduled runs:
prefect work-pool create --type process my-pool
prefect worker start --pool my-pool
Option A: Deploy a flow from local code
from prefect import flow
@flow(log_prints=True)
def my_flow(name: str = "world"):
print(f"Hello, {name}!")
if __name__ == "__main__":
my_flow.deploy(
name="hello-deployment",
work_pool_name="my-pool",
cron="0 9 * * *", # run every day at 9 AM
parameters={"name": "Prefect"}, # default params
tags=["demo"]
)
Option B: Deploy a flow from a remote source (e.g., GitHub)
from prefect import Flow
Flow.from_source(
source="<https://github.com/your-org/your-repo.git>",
entrypoint="flows/etl.py:my_flow", # "path/to/file.py:function_name"
).deploy(
name="etl-from-github",
work_pool_name="my-pool",
cron="0 2 * * *" # 2 AM daily
)
Notes and common args
- Required:
- `name`: the deployment name
- `work_pool_name`: which work pool runs the flow
- Scheduling: use one of cron="...", interval=..., rrule="...", or pass a `Schedule`/`schedules` list
- Parameters: parameters={"k": "v"}
- Infra customization: job_variables={...} (varies by pool type, e.g., env vars for Docker/Kubernetes)
- Container image: If you use containerized pools (e.g., Docker/Kubernetes), you can pass image="your/image:tag" and control build=True/False, push=True/False
Important 2.x → 3.x difference
- Deployment.build_from_flow() was removed. Use flow.deploy(...) or Flow.from_source(...).deploy(...) instead.
- The old prefect deployment build CLI is also gone; use prefect deploy or the Python APIs above.
Docs to dive deeper
- Create deployments via Python: Deploy via Python
- Deployment overview: Create deployments
- Work pools: Work pools
- Schedules: Schedules
Want me to tailor an example for your setup? Let me know:
- Which work pool type you’re using (process, Docker, Kubernetes, etc.)
- Whether your code runs locally or from a remote repo
- Your desired schedule and default parameters