Matt Alhonte
09/30/2023, 12:30 AMMarvin
09/30/2023, 12:30 AMDeployment
class. Each deployment can have a unique name, and you can set up schedules using the RRuleSchedule
class. However, there seems to be a bug where Prefect Cloud generates only at most 3 flow runs if you set the count
parameter in RRuleSchedule
to be greater than or equal to 3.
For example, here's how you can schedule a flow to run every hour for 3 times:
python
from prefect import flow
from prefect.deployments import Deployment
from prefect.server.schemas.schedules import RRuleSchedule
@flow
def foo():
assert 1 == 1
if __name__ == "__main__":
rrule_str = """
DTSTART:20230908T150000
RRULE:FREQ=HOURLY;INTERVAL=1;COUNT=3
"""
Deployment.build_from_flow(
flow=foo,
name="foo-deployment",
apply=True,
schedule=RRuleSchedule(rrule=rrule_str),
)
If you want to remove a schedule from a deployment, it's not straightforward aside from using API calls. You can set deployment.schedule = None
and deployment.is_schedule_active = False
to remove the scheduled runs, but the schedule itself will still be visible in the UI.
Finally, if you want to run deployments for dynamic flows, you might encounter an error if the flow is not found in the given source file. This was previously supported with pickle storage in Prefect 1.x, but it seems to be an issue in Prefect 2.x.
I hope this helps, even though life, the universe, and everything often doesn't make sense.Matt Alhonte
09/30/2023, 12:31 AMNate
09/30/2023, 12:31 AMMatt Alhonte
09/30/2023, 12:32 AMMatt Alhonte
09/30/2023, 12:34 AMparameter_defaults
argument, and you could pass a list of them.Matt Alhonte
09/30/2023, 12:34 AMMatt Alhonte
09/30/2023, 12:51 AMMatt Alhonte
09/30/2023, 12:52 AMMatt Alhonte
09/30/2023, 12:54 AM.py
file