Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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
    )
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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", [])})
Exemplo n.º 8
0
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
Exemplo n.º 9
0
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
    )
Exemplo n.º 10
0
 class Schema(marshmallow.Schema):
     dt = DateTimeTZ()
Exemplo n.º 11
0
class OneTimeScheduleSchema(ObjectSchema):
    class Meta:
        object_class = prefect.schedules.OneTimeSchedule

    start_date = DateTimeTZ(required=True)