Skip to content

prefect.events.schemas.deployment_triggers

Schemas for defining triggers within a Prefect deployment YAML. This is a separate parallel hierarchy for representing triggers so that they can also include the information necessary to create an automation.

These triggers should follow the validation rules of the main Trigger class hierarchy as closely as possible (because otherwise users will get validation errors creating triggers), but we can be more liberal with the defaults here to make it simpler to create them from YAML.

BaseDeploymentTrigger

Bases: PrefectBaseModel, ABC

Base class describing a set of criteria that must be satisfied in order to trigger an automation.

Source code in src/prefect/events/schemas/deployment_triggers.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class BaseDeploymentTrigger(PrefectBaseModel, abc.ABC, extra="ignore"):  # type: ignore[call-arg]
    """
    Base class describing a set of criteria that must be satisfied in order to trigger
    an automation.
    """

    # Fields from Automation

    name: Optional[str] = Field(
        default=None,
        description="The name to give to the automation created for this trigger.",
    )
    description: str = Field(
        default="", description="A longer description of this automation"
    )
    enabled: bool = Field(
        default=True, description="Whether this automation will be evaluated"
    )

    # Fields from the RunDeployment action

    parameters: Optional[Dict[str, Any]] = Field(
        default=None,
        description=(
            "The parameters to pass to the deployment, or None to use the "
            "deployment's default parameters"
        ),
    )
    job_variables: Optional[Dict[str, Any]] = Field(
        default=None,
        description=(
            "Job variables to pass to the deployment, or None to use the "
            "deployment's default job variables"
        ),
    )

DeploymentCompoundTrigger

Bases: BaseDeploymentTrigger, CompoundTrigger

A composite trigger that requires some number of triggers to have fired within the given time period

Source code in src/prefect/events/schemas/deployment_triggers.py
90
91
92
93
94
class DeploymentCompoundTrigger(BaseDeploymentTrigger, CompoundTrigger):
    """A composite trigger that requires some number of triggers to have
    fired within the given time period"""

    trigger_type: ClassVar[Type[TriggerTypes]] = CompoundTrigger

DeploymentEventTrigger

Bases: BaseDeploymentTrigger, EventTrigger

A trigger that fires based on the presence or absence of events within a given period of time.

Source code in src/prefect/events/schemas/deployment_triggers.py
73
74
75
76
77
78
79
class DeploymentEventTrigger(BaseDeploymentTrigger, EventTrigger):
    """
    A trigger that fires based on the presence or absence of events within a given
    period of time.
    """

    trigger_type: ClassVar[Type[TriggerTypes]] = EventTrigger

DeploymentMetricTrigger

Bases: BaseDeploymentTrigger, MetricTrigger

A trigger that fires based on the results of a metric query.

Source code in src/prefect/events/schemas/deployment_triggers.py
82
83
84
85
86
87
class DeploymentMetricTrigger(BaseDeploymentTrigger, MetricTrigger):
    """
    A trigger that fires based on the results of a metric query.
    """

    trigger_type: ClassVar[Type[TriggerTypes]] = MetricTrigger

DeploymentSequenceTrigger

Bases: BaseDeploymentTrigger, SequenceTrigger

A composite trigger that requires some number of triggers to have fired within the given time period in a specific order

Source code in src/prefect/events/schemas/deployment_triggers.py
 97
 98
 99
100
101
class DeploymentSequenceTrigger(BaseDeploymentTrigger, SequenceTrigger):
    """A composite trigger that requires some number of triggers to have fired
    within the given time period in a specific order"""

    trigger_type: ClassVar[Type[TriggerTypes]] = SequenceTrigger