Does Prefect 2.0 support filters and adjustments e.g. to restrict the schedule to only run during business hours?

Not directly. Filters and Adjustments have been replaced by RRules Schedule, which includes the same functionality and a lot more by using the ical standard (anything you can do in a calendar app).

See docs here:

You can either provide RRules strings or use the rrules package to build the rules in code:
https://dateutil.readthedocs.io/en/stable/rrule.html

:point_right: Note that: It is anticipated that the UI will be the primary interface for scheduling to make it easier and more flexible for users to define or adjust schedules without having to redeploy any code.

Example - hourly schedule during business hours

Prefect 1.0

Here is an example to schedule your flow to run hourly but only during business days from 9 to 5:

from datetime import time, timedelta
import pendulum
from prefect.schedules import Schedule
from prefect.schedules.clocks import IntervalClock
from prefect.schedules.filters import between_times, is_weekday

# respects DST
clock = IntervalClock(
    start_date=pendulum.datetime(2021, 11, 12, 9, 0, tz="Europe/London"),
    interval=timedelta(hours=1),
)
schedule = Schedule(clocks=[clock],
                    filters=[is_weekday, between_times(time(9), time(17))])

for sched in schedule.next(20):
    print(sched)

Prefect 2.0

Prefect 2.0 doesn’t require custom filters or adjustments as it relies on rrule for complex scheduling. This makes it easier, as you can create and validate this schedule without Prefect!

import pendulum
from dateutil.rrule import rrule, MO, TU, WE, TH, FR, HOURLY

bus_hours = rrule(
    freq=HOURLY, interval=1,
    dtstart=pendulum.datetime(2022, 4, 29, 18, 0),
    byweekday=(MO, TU, WE, TH, FR),
    count=20,  # add limit count for testing schedules - todo remove later
    byhour=list(range(9, 18))
)
for sched_date in bus_hours:
    print(sched_date)

Once you have validated that your schedule is working as intended, you may add that to your DeploymentSpec as follows:

from prefect.deployments import DeploymentSpec
from prefect.orion.schemas.schedules import RRuleSchedule

DeploymentSpec(
    name="rrule-schedule-deployment",
    flow_location="/path/to/flow.py",
    schedule=RRuleSchedule.from_rrule(bus_hours),
)

For more rrule examples, check this documentation page:
https://dateutil.readthedocs.io/en/stable/rrule.html#rrule-examples

Further resources