Florian Giroud
10/01/2024, 1:10 PMMarvin
10/01/2024, 1:11 PMactive
state of a schedule.
Example:
python
from prefect.deployments import Deployment
from prefect.orion.schemas.schedules import CronSchedule
# Define your deployment with the schedule
deployment = Deployment(
name="example_deployment",
flow_name="example_flow",
schedule=CronSchedule(cron="0 0 * * *", timezone="UTC", active=False),
)
def notify_team(schedule_status):
# Your custom notification logic here, e.g., send an email or Slack message
print(f"Schedule has been {schedule_status}")
# Toggle the schedule's active status and notify the team
schedule_active = False
if schedule_active:
deployment.schedule.active = True
notify_team("re-enabled")
else:
deployment.schedule.active = False
notify_team("disabled")
# Apply the deployment update
deployment.apply()
This script manually updates the schedule and includes a function to notify your team of the change.
### Resources
- Prefect Automations: https://docs-2.prefect.io/latest/concepts/automations/
- Prefect 3.x Schedules: https://docs-3.prefect.io/3.0/automate/add-schedules
Using these approaches, you can programmatically inform your team when a flow's schedule is disabled or re-enabled. If there's any other specific requirement or challenge you face, feel free to ask!Florian Giroud
10/01/2024, 1:23 PM