class CronScheduleSchema(ObjectSchema): class Meta: object_class = prefect.schedules.CronSchedule start_date = DateTimeTZ(allow_none=True) end_date = DateTimeTZ(allow_none=True) cron = fields.String(required=True)
class IntervalClockSchema(ObjectSchema): class Meta: object_class = prefect.schedules.clocks.IntervalClock start_date = DateTimeTZ(allow_none=True) end_date = DateTimeTZ(allow_none=True) interval = fields.TimeDelta(precision="microseconds", required=True) parameter_defaults = fields.Dict(keys=fields.Str(), values=JSONCompatible(), allow_none=True) labels = fields.List(fields.Str(), allow_none=True) @post_dump def _interval_validation(self, data: dict, **kwargs: Any) -> dict: """ Ensures interval is at least one minute in length """ if data["interval"] / 1e6 < 60: raise ValueError( "Interval can not be less than one minute when deploying to Prefect Cloud." ) return data @post_load def create_object(self, data: dict, **kwargs: Any): if data["interval"].total_seconds() < 60: raise ValueError( "Interval can not be less than one minute when deploying to Prefect Cloud." ) base_obj = super().create_object(data) return base_obj
class IntervalScheduleSchema(ObjectSchema): class Meta: object_class = prefect.schedules.IntervalSchedule start_date = DateTimeTZ(required=True) end_date = DateTimeTZ(allow_none=True) interval = fields.TimeDelta(precision="microseconds", required=True)
class DatesClockSchema(ObjectSchema): class Meta: object_class = prefect.schedules.clocks.DatesClock start_date = DateTimeTZ(allow_none=True) end_date = DateTimeTZ(allow_none=True) dates = DateTimeTZ(required=True, many=True)
class CronClockSchema(ObjectSchema): class Meta: object_class = prefect.schedules.clocks.CronClock start_date = DateTimeTZ(allow_none=True) end_date = DateTimeTZ(allow_none=True) cron = fields.String(required=True) parameter_defaults = fields.Dict( key=fields.Str(), values=JSONCompatible(), allow_none=True )
class RRuleClockSchema(ObjectSchema): class Meta: object_class = prefect.schedules.clocks.RRuleClock rrule_obj = fields.Nested(RRuleBaseSchema) start_date = DateTimeTZ(allow_none=True) end_date = DateTimeTZ(allow_none=True) parameter_defaults = fields.Dict(keys=fields.Str(), values=JSONCompatible(), allow_none=True) labels = fields.List(fields.Str(), allow_none=True)
class UnionScheduleSchema(ObjectSchema): class Meta: object_class = lambda: prefect.schedules.UnionSchedule start_date = DateTimeTZ(required=True) end_date = DateTimeTZ(allow_none=True) schedules = fields.Nested("prefect.serialization.schedule.ScheduleSchema", many=True) @post_load def create_object(self, data: dict, **kwargs: Any) -> prefect.schedules.Schedule: return super().create_object({"schedules": data.pop("schedules", [])})
class UnionScheduleSchema(ObjectSchema): class Meta: object_class = prefect.schedules.UnionSchedule start_date = DateTimeTZ(required=True) end_date = DateTimeTZ(allow_none=True) schedules = fields.Nested("prefect.serialization.schedule.ScheduleSchema", many=True) @post_load def create_object(self, data: dict) -> prefect.schedules.UnionSchedule: schedules = data.pop("schedules", []) base_obj = super().create_object({"schedules": schedules}) return base_obj
class DatesClockSchema(ObjectSchema): class Meta: object_class = prefect.schedules.clocks.DatesClock dates = fields.List(DateTimeTZ(), required=True) parameter_defaults = fields.Dict( key=fields.Str(), values=JSONCompatible(), allow_none=True )
class Schema(marshmallow.Schema): dt = DateTimeTZ()
class OneTimeScheduleSchema(ObjectSchema): class Meta: object_class = prefect.schedules.OneTimeSchedule start_date = DateTimeTZ(required=True)