Shubham
10/10/2025, 4:54 AMMarvin
10/10/2025, 4:54 AMMarvin
10/10/2025, 5:02 AMprefect deployment schedule ls "<flow-name>/<deployment-name>"
- Create/pause/resume/delete schedules:
prefect deployment schedule create "<flow-name>/<deployment-name>"
prefect deployment schedule pause "<flow-name>/<deployment-name>" --id <schedule-id>
prefect deployment schedule resume "<flow-name>/<deployment-name>" --id <schedule-id>
prefect deployment schedule delete "<flow-name>/<deployment-name>" --id <schedule-id>
- Docs: Schedules concepts and Create schedules for deployments
If you share how you’re managing schedules today (UI vs CLI vs code) and what kind of code changes you anticipate (parameter renames, new required params, etc.), I can suggest a concrete migration plan.Shubham
10/10/2025, 5:10 AMMarvin
10/10/2025, 5:10 AMMarvin
10/10/2025, 5:13 AMfrom prefect import flow
from prefect.storage import GitRepository
@flow
def my_flow(): ...
my_flow.from_source(
GitRepository(
url="<https://github.com/org/repo>",
branch="main", # floating branch = latest
# commit_sha=None # leave unset
),
entrypoint="flows/my_flow.py:my_flow",
).deploy(name="my-deployment", work_pool_name="my-pool")
- Example (prefect.yaml):
deployments:
- name: my-deployment
entrypoint: flows/my_flow.py:my_flow
source:
git:
url: <https://github.com/org/repo>
branch: main
- With this setup, you do not need to redeploy after every commit; future runs will pick up the latest on that branch.
- Pin to a commit (immutable, reproducible)
- If your deployment is pinned to a specific commit_sha
, you’ll need to update it after you push new code:
- Update the commit in code (Python or prefect.yaml as above) and run prefect deploy
again, or
- Edit the deployment in the UI to point to the new commit SHA and save.
- This gives deterministic rollbacks and reproducibility.
Does this affect existing schedules?
- No. Updating the deployment’s source/commit does not remove or pause schedules. They continue to trigger runs for that deployment.
- Caveat: if your code change breaks the flow’s parameter schema or entrypoint path, scheduled runs may fail at runtime. Keep parameter names backward compatible or phase changes carefully.
Related docs
- Schedules: Schedules concepts
- Creating schedules: Create schedules for deployments
- prefect.yaml and source config: prefect.yaml guide
If you share how your current deployment is configured (prefect.yaml vs Python from_source
, branch vs commit), I can give exact steps to switch to “latest” or update the commit safely.Shubham
10/10/2025, 5:23 AMMarvin
10/10/2025, 5:23 AMMarvin
10/10/2025, 5:23 AMShubham
10/10/2025, 5:33 AMMarvin
10/10/2025, 5:33 AMMarvin
10/10/2025, 5:37 AMprefect work-pool create "host-a-pool" --type process
prefect work-pool create "host-b-pool" --type process
- Start a worker on each host:
prefect worker start --pool host-a-pool
prefect worker start --pool host-b-pool
- Docs/background: Work pools and workers and Upgrade to workers
Create deployments from Git
- Track a branch (always latest) or pin to a commit for reproducibility. Example (Python):
from prefect import flow
from prefect.storage import GitRepository
@flow
def my_flow(param: str = "hello"):
...
my_flow.from_source(
GitRepository(
url="<https://github.com/org/repo>",
branch="main",
),
entrypoint="flows/my_flow.py:my_flow",
).deploy(name="my-flow@host-a", work_pool_name="host-a-pool")
my_flow.from_source(
GitRepository(
url="<https://github.com/org/repo>",
branch="main",
),
entrypoint="flows/my_flow.py:my_flow",
).deploy(name="my-flow@host-b", work_pool_name="host-b-pool")
- Or with prefect.yaml, set source.git.url
and branch
and run prefect deploy
.
Trigger runs from Next.js (server-side)
- Store a Prefect service account API key in Next.js server env (never expose to the browser). Service accounts: Service accounts
- Create flow runs by calling the REST endpoint:
- POST /deployments/{deployment_id}/create_flow_run
- Docs: Create flow run from deployment
Example Next.js API route to trigger a run
```
export default async function handler(req, res) {
try {
const { deploymentId, parameters } = JSON.parse(req.body);
const resp = await fetch(${process.env.PREFECT_API_URL}/deployments/${deploymentId}/create_flow_run
, {
method: "POST",
headers: {
"Authorization": Bearer ${process.env.PREFECT_API_KEY}
,
"Content-Type": "application/json",
},
body: JSON.stringify({
parameters: parameters ?? {},
// optional: name, tags, and scheduled start time
// name: "run-from-nextjs",
// tags: ["from-nextjs"],
// state: { type: "SCHEDULED", state_details: { scheduled_time: new Date().toISOString() } }
}),
});Marvin
10/10/2025, 5:37 AMMonitor runs in your UI
- List runs (filter by deployment, state, time) via REST:
- GET `/flow-runs` with filters
- Docs: <https://docs-3.prefect.io/v3/advanced/api-client|API client overview> (REST endpoints are linked from here)
- Deep link to Prefect UI for a specific run for rich logs/debugging.
- Optionally poll run status or build a small background job to sync statuses into your own DB for dashboards.
Control runs (cancel)
- Cancel a run from your Next.js backend by setting the run state to Cancelled (REST endpoint documented under flow runs state management).
- You can also expose buttons in your UI that call your Next.js API route to cancel a run.
- CLI for local testing:
prefect deployment run "<flow>/<deployment>" --param key=value
```
Help: prefect deployment run --help
Putting it together
- If you need strict host selection:
- One deployment per host (my-flow@host-a, my-flow@host-b), each targeting a different pool.
- Your Next.js backend chooses which deployment ID to run.
- If host agnostic is OK:
- One deployment and one shared pool with workers on each host. Runs will land wherever capacity exists.
Open questions to tailor this for you
- Do you need to target a specific host per job, or can runs execute on any available host?
- Roughly how many hosts and distinct flows will you manage? If many hosts, we can discuss patterns to stay within the 20-deployment limit.
- Are you comfortable tracking the latest Git branch for rapid iteration, or do you need pinned commits/releases for reproducibility?
References
- Create flow run from deployment (REST): API reference
- Service accounts: Service accounts
- Work pools and workers: Background article
- Prefect API client overview: API clientShubham
10/10/2025, 8:17 AMMarvin
10/10/2025, 8:17 AMMarvin
10/10/2025, 8:18 AMShubham
10/10/2025, 3:39 PMMarvin
10/10/2025, 3:45 PMMarvin
10/10/2025, 3:46 PMprefect ... --help
(with optional extras via uv run --with 'prefect[<extra>]'
) to ensure commands and flags I suggest actually exist.
- Release notes: I can fetch the latest changes when behavior differs across versions.
- Lightweight memory: I can store/delete helpful facts about your environment on request to tailor guidance.
- Defaults and guardrails
- I assume Prefect 3.x unless you tell me otherwise, and I avoid deprecated 2.x patterns (for example, I won’t suggest Deployment.build_from_flow()
or prefect deployment build
in 3.x).
- I include links to sources I used so you can verify or go deeper.
- If I can’t find a definitive answer, I’ll say so and ask for more info rather than guess.
What this means in practice:
- For CLI questions, I validate with --help
before recommending syntax.
- For code, I check available APIs and signatures before sharing examples.
- For behavior or bugs, I search open/closed issues and discussions and link the most relevant threads.
If it helps, I can demo this on a concrete ask (e.g., “What’s the correct way to deploy a flow from GitHub in Prefect 3?”) and show the verification steps and sources I’d use. Would you like me to walk through an example?