Theonymfi Anogeianaki
12/17/2025, 9:02 AMMarvin
12/17/2025, 9:02 AMMarvin
12/17/2025, 9:09 AMschedules: from prefect.yaml and running prefect deploy will not delete existing schedules. In Prefect 3.x, schedules are only changed if you explicitly send new schedules; otherwise, existing schedules are retained.
Ways to get the behavior you want:
- If you want the deployment to have exactly the schedules in your prefect.yaml
- Keep a schedules: section in the YAML with the schedules you want. When present, prefect deploy will replace existing schedules with the ones in the file.
- Docs: Create deployment schedules, prefect.yaml reference
- If you want no schedules (i.e., you removed schedules: from the file)
- You must explicitly clear them, since prefect deploy won’t delete schedules when the section is absent.
- Useful commands:
# See current schedules
prefect deployment schedule ls "<flow-name>/<deployment-name>"
# Clear all schedules
prefect deployment schedule clear "<flow-name>/<deployment-name>" -y
- CLI reference: Prefect deployment CLI (see the schedule subcommands)
- If you want to remove one schedule but keep others
- List the schedules to get IDs, then delete by ID:
prefect deployment schedule ls "<flow-name>/<deployment-name>"
prefect deployment schedule delete "<flow-name>/<deployment-name>" <schedule-id>
Tip: If you’re automating deployments, you can add a step that runs prefect deployment schedule clear "<flow>/<deployment>" -y when your prefect.yaml has no schedules: section, so the deployment ends up with zero schedules.
Would you like me to help craft a small script/CI step that clears schedules when the YAML has none? If you share your deployment name (<flow-name>/<deployment-name>), I can give exact commands.Theonymfi Anogeianaki
12/17/2025, 9:20 AMcommand: |
uv sync --all-extras
uv run prefect deploy --all
Is there a command to clear every schedule before deploying and then deploy? So instead of writing every job here do something like:
command: |
uv sync --all-extras
uv run prefect schedules clear --all
uv run prefect deploy --all
Is this possible? What do you suggest?Marvin
12/17/2025, 9:20 AMMarvin
12/17/2025, 9:24 AMprefect deploy will not clear schedules when the schedules: section is absent. The supported way is per-deployment:
- Clear schedules: prefect deployment schedule clear "<flow>/<deployment>" -y
- Then deploy: prefect deploy --all
If you truly want to clear schedules for every deployment in the workspace before deploying, you can loop over them. For CircleCI, something like this works:
command: |
uv sync --all-extras
uv run bash -eo pipefail <<'BASH'
set -euo pipefail
# Clear schedules for ALL deployments in the workspace — be careful if you share the workspace!
mapfile -t deployments < <(prefect deployment ls | awk 'NR>2 {print $1}')
for d in "${deployments[@]}"; do
echo "Clearing schedules for $d"
prefect deployment schedule clear "$d" -y
done
BASH
uv run prefect deploy --all
Safer (recommended) variants:
- If your project’s deployments share a naming convention, filter to those:
PROJECT_PREFIX="myproject-" # adjust to your naming scheme
uv run bash -eo pipefail <<'BASH'
set -euo pipefail
prefect deployment ls | awk 'NR>2 {print $1}' | grep "$PROJECT_PREFIX" | xargs -n1 -I{} prefect deployment schedule clear "{}" -y
BASH
uv run prefect deploy --all
- Or explicitly enumerate known deployment names (most robust if you have a short list):
DEPLOYMENTS=("flow-a/deploy-a" "flow-b/deploy-b")
uv run bash -eo pipefail <<'BASH'
set -euo pipefail
for d in "${DEPLOYMENTS[@]}"; do
prefect deployment schedule clear "$d" -y
done
BASH
uv run prefect deploy --all
Notes:
- Clearing first is fine: deployments that have schedules in your prefect.yaml will recreate them on deploy; those without will remain unscheduled (your goal).
- There is no --all flag for `prefect deployment schedule clear`; it’s per-deployment.
- Verify with:
prefect deployment schedule ls "<flow>/<deployment>"
CLI reference for these commands: Prefect deployment CLI (see the schedule clear, schedule ls, schedule delete subcommands).
Quick question to tailor the script: do you want to clear schedules for every deployment in the entire workspace, or only for deployments from this repo? If the latter, do your deployment names share a common prefix? I can provide an exact CircleCI snippet based on that.Theonymfi Anogeianaki
12/17/2025, 9:33 AMMarvin
12/17/2025, 9:33 AMMarvin
12/17/2025, 9:33 AMschedules: section will not clear it. The schedule still exists (and remains paused) because prefect deploy only updates schedules if you explicitly provide new ones.
To remove schedules, clear them explicitly:
prefect deployment schedule clear "<flow-name>/<deployment-name>" -y
Then deploy:
prefect deploy --all
If you want deployments to always reflect exactly what’s in prefect.yaml, keep a schedules: section in the file. When present (and non-empty), Prefect replaces existing schedules with the ones you provide. If you want zero schedules, you must clear them via CLI (an empty schedules: [] won’t clear).
CLI reference: Prefect deployment CLI (see schedule clear, schedule ls, schedule delete).