Thomas Stack
04/25/2024, 8:00 PMMarvin
04/25/2024, 8:00 PMschedules
section to your deployment .yaml
file. Here is an example of how to define multiple schedules:
yaml
deployments:
...
schedules:
- cron: "0 0 * * *"
timezone: "America/Chicago"
active: false
- cron: "0 12 * * *"
timezone: "America/New_York"
active: true
- cron: "0 18 * * *"
timezone: "Europe/London"
active: true
The cron
expression defines the recurrence pattern for the deployment, the timezone
indicates which timezone the cron
expression should be interpreted in, and the active
key determines whether the schedule is currently active.
Additionally, Prefect's Scheduler service, automatically started with Prefect Cloud or with prefect server start
, evaluates each deployment's schedules and creates new runs according to these configurations.
For more details, check out Prefect Schedules Documentation.Thomas Stack
04/25/2024, 9:49 PMMarvin
04/25/2024, 9:49 PMprefect cancel
command with the appropriate run ID.
- Python Client: Use the client.cancel_flow_run()
function.
- REST API: Send a request to Prefect's REST API to cancel the flow run.
Here is an example using the Python client to cancel a flow run:
python
from prefect import Client
client = Client()
client.cancel_flow_run(flow_run_id="your-flow-run-id")
If you want to disable the entire schedule for a deployment so that no new runs will be created, you can modify the deployment's .yaml
file and set the active
flag to false
. Here is an example snippet:
yaml
deployments:
...
schedules:
- cron: "0 0 * * *"
timezone: "America/Chicago"
active: false
After updating the .yaml
file, you will need to apply it using the Prefect CLI or UI for the changes to take effect.
For more in-depth information, refer to the Prefect Schedules Documentation. To learn about cancelling flow runs, see the Flows documentation.Thomas Stack
04/25/2024, 9:50 PMMarvin
04/25/2024, 9:50 PM