<@ULVA73B9P> how do i set a timer on my deployment
# marvin-in-the-wild
t
@Marvin how do i set a timer on my deployment
m
To set a timer on your deployment in Prefect, you need to add a
schedules
section to your deployment
.yaml
file. Here is an example of how to define multiple schedules:
Copy code
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.
t
@Marvin how do i stop a flow from continuing on a schedule i made?
m
To stop a flow from continuing on a schedule you made, you need to either cancel any scheduled flow runs or disable the schedule for the deployment. You may cancel a scheduled or in-progress flow run using one of the following methods: - Prefect UI: Go to your flow run page and hit the cancel button. - CLI: Use
prefect 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:
Copy code
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:
Copy code
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.
t
@Marvin can i do this cancellation using the UI?
m
Yes, you can cancel a scheduled or in-progress flow run using the Prefect UI. To do so, follow these steps: 1. Log into the Prefect UI. 2. Navigate to the "Flows" page within the UI. 3. Find the flow that has the run you want to cancel. 4. Click on the flow to see a list of its flow runs. 5. Identify the run that you want to cancel. 6. Click on the specific flow run to open the run details. 7. In the flow run details page, you should see a "Cancel" button that you can click to cancel the run. Please note that after you cancel the run, the Prefect UI will reflect the updated state as "Cancelled" once the cancellation request has been processed. Keep in mind that it may take a short period for the flow run to transition to the "Cancelled" state. For the latest information on how to cancel flows from the UI, you should rely on the Prefect UI documentation or any guidance available within the UI itself, as interfaces and functionalities may evolve over time. If you need more help with the UI, you can typically find a help or documentation section within the UI itself.