Data used by the Prefect REST API to create a new state.
Source code in src/prefect/client/schemas/actions.py
65666768697071727374
classStateCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a new state."""type:StateTypename:Optional[str]=Field(default=None)message:Optional[str]=Field(default=None,examples=["Run started"])state_details:StateDetails=Field(default_factory=StateDetails)data:Union["BaseResult[R]","DataDocument[R]",Any]=Field(default=None,)
Data used by the Prefect REST API to create a flow.
Source code in src/prefect/client/schemas/actions.py
7778798081828384858687
classFlowCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a flow."""name:str=Field(default=...,description="The name of the flow",examples=["my-flow"])tags:List[str]=Field(default_factory=list,description="A list of flow tags",examples=[["tag-1","tag-2"]],)
Data used by the Prefect REST API to update a flow.
Source code in src/prefect/client/schemas/actions.py
9091929394959697
classFlowUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a flow."""tags:List[str]=Field(default_factory=list,description="A list of flow tags",examples=[["tag-1","tag-2"]],)
classDeploymentCreate(DeprecatedInfraOverridesField,ActionBaseModel):"""Data used by the Prefect REST API to create a deployment."""@root_validator(pre=True)defremove_old_fields(cls,values):returnremove_old_deployment_fields(values)name:str=Field(...,description="The name of the deployment.")flow_id:UUID=Field(...,description="The ID of the flow to deploy.")is_schedule_active:Optional[bool]=Field(None)paused:Optional[bool]=Field(None)schedules:List[DeploymentScheduleCreate]=Field(default_factory=list,description="A list of schedules for the deployment.",)enforce_parameter_schema:Optional[bool]=Field(default=None,description=("Whether or not the deployment should enforce the parameter schema."),)parameter_openapi_schema:Optional[Dict[str,Any]]=Field(None)parameters:Dict[str,Any]=Field(default_factory=dict,description="Parameters for flow runs scheduled by the deployment.",)tags:List[str]=Field(default_factory=list)pull_steps:Optional[List[dict]]=Field(None)manifest_path:Optional[str]=Field(None)work_queue_name:Optional[str]=Field(None)work_pool_name:Optional[str]=Field(default=None,description="The name of the deployment's work pool.",examples=["my-work-pool"],)storage_document_id:Optional[UUID]=Field(None)infrastructure_document_id:Optional[UUID]=Field(None)schedule:Optional[SCHEDULE_TYPES]=Field(None)description:Optional[str]=Field(None)path:Optional[str]=Field(None)version:Optional[str]=Field(None)entrypoint:Optional[str]=Field(None)job_variables:Optional[Dict[str,Any]]=Field(default_factory=dict,description="Overrides to apply to flow run infrastructure at runtime.",)defcheck_valid_configuration(self,base_job_template:dict):"""Check that the combination of base_job_template defaults and job_variables conforms to the specified schema. """variables_schema=deepcopy(base_job_template.get("variables"))ifvariables_schemaisnotNone:# jsonschema considers required fields, even if that field has a default,# to still be required. To get around this we remove the fields from# required if there is a default present.required=variables_schema.get("required")properties=variables_schema.get("properties")ifrequiredisnotNoneandpropertiesisnotNone:fork,vinproperties.items():if"default"invandkinrequired:required.remove(k)jsonschema.validate(self.job_variables,variables_schema)
defcheck_valid_configuration(self,base_job_template:dict):"""Check that the combination of base_job_template defaults and job_variables conforms to the specified schema. """variables_schema=deepcopy(base_job_template.get("variables"))ifvariables_schemaisnotNone:# jsonschema considers required fields, even if that field has a default,# to still be required. To get around this we remove the fields from# required if there is a default present.required=variables_schema.get("required")properties=variables_schema.get("properties")ifrequiredisnotNoneandpropertiesisnotNone:fork,vinproperties.items():if"default"invandkinrequired:required.remove(k)jsonschema.validate(self.job_variables,variables_schema)
classDeploymentUpdate(DeprecatedInfraOverridesField,ActionBaseModel):"""Data used by the Prefect REST API to update a deployment."""@root_validator(pre=True)defremove_old_fields(cls,values):returnremove_old_deployment_fields(values)@validator("schedule")defvalidate_none_schedule(cls,v):returnreturn_none_schedule(v)version:Optional[str]=Field(None)schedule:Optional[SCHEDULE_TYPES]=Field(None)description:Optional[str]=Field(None)is_schedule_active:bool=Field(None)parameters:Optional[Dict[str,Any]]=Field(default=None,description="Parameters for flow runs scheduled by the deployment.",)tags:List[str]=Field(default_factory=list)work_queue_name:Optional[str]=Field(None)work_pool_name:Optional[str]=Field(default=None,description="The name of the deployment's work pool.",examples=["my-work-pool"],)path:Optional[str]=Field(None)job_variables:Optional[Dict[str,Any]]=Field(default_factory=dict,description="Overrides to apply to flow run infrastructure at runtime.",)entrypoint:Optional[str]=Field(None)manifest_path:Optional[str]=Field(None)storage_document_id:Optional[UUID]=Field(None)infrastructure_document_id:Optional[UUID]=Field(None)enforce_parameter_schema:Optional[bool]=Field(default=None,description=("Whether or not the deployment should enforce the parameter schema."),)defcheck_valid_configuration(self,base_job_template:dict):"""Check that the combination of base_job_template defaults and job_variables conforms to the specified schema. """variables_schema=deepcopy(base_job_template.get("variables"))ifvariables_schemaisnotNone:# jsonschema considers required fields, even if that field has a default,# to still be required. To get around this we remove the fields from# required if there is a default present.required=variables_schema.get("required")properties=variables_schema.get("properties")ifrequiredisnotNoneandpropertiesisnotNone:fork,vinproperties.items():if"default"invandkinrequired:required.remove(k)ifvariables_schemaisnotNone:jsonschema.validate(self.job_variables,variables_schema)
defcheck_valid_configuration(self,base_job_template:dict):"""Check that the combination of base_job_template defaults and job_variables conforms to the specified schema. """variables_schema=deepcopy(base_job_template.get("variables"))ifvariables_schemaisnotNone:# jsonschema considers required fields, even if that field has a default,# to still be required. To get around this we remove the fields from# required if there is a default present.required=variables_schema.get("required")properties=variables_schema.get("properties")ifrequiredisnotNoneandpropertiesisnotNone:fork,vinproperties.items():if"default"invandkinrequired:required.remove(k)ifvariables_schemaisnotNone:jsonschema.validate(self.job_variables,variables_schema)
Data used by the Prefect REST API to update a flow run.
Source code in src/prefect/client/schemas/actions.py
288289290291292293294295296297298299
classFlowRunUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a flow run."""name:Optional[str]=Field(None)flow_version:Optional[str]=Field(None)parameters:Optional[Dict[str,Any]]=Field(None)empirical_policy:objects.FlowRunPolicy=Field(default_factory=objects.FlowRunPolicy)tags:List[str]=Field(default_factory=list)infrastructure_pid:Optional[str]=Field(None)job_variables:Optional[Dict[str,Any]]=Field(None)
classTaskRunCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a task run"""id:Optional[UUID]=Field(None,description="The ID to assign to the task run")# TaskRunCreate states must be provided as StateCreate objectsstate:Optional[StateCreate]=Field(default=None,description="The state of the task run to create")name:Optional[str]=Field(default=None,description="The name of the task run",)flow_run_id:Optional[UUID]=Field(None)task_key:str=Field(default=...,description="A unique identifier for the task being run.")dynamic_key:str=Field(default=...,description=("A dynamic key used to differentiate between multiple runs of the same task"" within the same flow run."),)cache_key:Optional[str]=Field(None)cache_expiration:Optional[objects.DateTimeTZ]=Field(None)task_version:Optional[str]=Field(None)empirical_policy:objects.TaskRunPolicy=Field(default_factory=objects.TaskRunPolicy,)tags:List[str]=Field(default_factory=list)task_inputs:Dict[str,List[Union[objects.TaskRunResult,objects.Parameter,objects.Constant,]],]=Field(default_factory=dict)
classFlowRunCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a flow run."""# FlowRunCreate states must be provided as StateCreate objectsstate:Optional[StateCreate]=Field(default=None,description="The state of the flow run to create")name:Optional[str]=Field(default=None,description="The name of the flow run.")flow_id:UUID=Field(default=...,description="The id of the flow being run.")deployment_id:Optional[UUID]=Field(None)flow_version:Optional[str]=Field(None)parameters:Dict[str,Any]=Field(default_factory=dict,description="The parameters for the flow run.")context:Dict[str,Any]=Field(default_factory=dict,description="The context for the flow run.")parent_task_run_id:Optional[UUID]=Field(None)infrastructure_document_id:Optional[UUID]=Field(None)empirical_policy:objects.FlowRunPolicy=Field(default_factory=objects.FlowRunPolicy)tags:List[str]=Field(default_factory=list)idempotency_key:Optional[str]=Field(None)classConfig(ActionBaseModel.Config):json_dumps=orjson_dumps_extra_compatible
classDeploymentFlowRunCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a flow run from a deployment."""# FlowRunCreate states must be provided as StateCreate objectsstate:Optional[StateCreate]=Field(default=None,description="The state of the flow run to create")name:Optional[str]=Field(default=None,description="The name of the flow run.")parameters:Dict[str,Any]=Field(default_factory=dict,description="The parameters for the flow run.")context:Dict[str,Any]=Field(default_factory=dict,description="The context for the flow run.")infrastructure_document_id:Optional[UUID]=Field(None)empirical_policy:objects.FlowRunPolicy=Field(default_factory=objects.FlowRunPolicy)tags:List[str]=Field(default_factory=list)idempotency_key:Optional[str]=Field(None)parent_task_run_id:Optional[UUID]=Field(None)work_queue_name:Optional[str]=Field(None)job_variables:Optional[dict]=Field(None)
Data used by the Prefect REST API to create a saved search.
Source code in src/prefect/client/schemas/actions.py
407408409410411412413
classSavedSearchCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a saved search."""name:str=Field(default=...,description="The name of the saved search.")filters:List[objects.SavedSearchFilter]=Field(default_factory=list,description="The filter set for the saved search.")
Data used by the Prefect REST API to create a concurrency limit.
Source code in src/prefect/client/schemas/actions.py
416417418419420421422
classConcurrencyLimitCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a concurrency limit."""tag:str=Field(default=...,description="A tag the concurrency limit is applied to.")concurrency_limit:int=Field(default=...,description="The concurrency limit.")
classBlockTypeCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a block type."""name:str=Field(default=...,description="A block type's name")slug:str=Field(default=...,description="A block type's slug")logo_url:Optional[objects.HttpUrl]=Field(default=None,description="Web URL for the block type's logo")documentation_url:Optional[objects.HttpUrl]=Field(default=None,description="Web URL for the block type's documentation")description:Optional[str]=Field(default=None,description="A short blurb about the corresponding block's intended use",)code_example:Optional[str]=Field(default=None,description="A code snippet demonstrating use of the corresponding block",)# validators_validate_slug_format=validator("slug",allow_reuse=True)(validate_block_type_slug)
Data used by the Prefect REST API to update a block type.
Source code in src/prefect/client/schemas/actions.py
451452453454455456457458459460461
classBlockTypeUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a block type."""logo_url:Optional[objects.HttpUrl]=Field(None)documentation_url:Optional[objects.HttpUrl]=Field(None)description:Optional[str]=Field(None)code_example:Optional[str]=Field(None)@classmethoddefupdatable_fields(cls)->set:returnget_class_fields_only(cls)
Data used by the Prefect REST API to create a block schema.
Source code in src/prefect/client/schemas/actions.py
464465466467468469470471472473474475476477478
classBlockSchemaCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a block schema."""fields:Dict[str,Any]=Field(default_factory=dict,description="The block schema's field schema")block_type_id:Optional[UUID]=Field(None)capabilities:List[str]=Field(default_factory=list,description="A list of Block capabilities",)version:str=Field(default=objects.DEFAULT_BLOCK_SCHEMA_VERSION,description="Human readable identifier for the block schema",)
classBlockDocumentCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a block document."""name:Optional[str]=Field(default=None,description="The name of the block document")data:Dict[str,Any]=Field(default_factory=dict,description="The block document's data")block_schema_id:UUID=Field(default=...,description="The block schema ID for the block document")block_type_id:UUID=Field(default=...,description="The block type ID for the block document")is_anonymous:bool=Field(default=False,description=("Whether the block is anonymous (anonymous blocks are usually created by"" Prefect automatically)"),)_validate_name_format=validator("name",allow_reuse=True)(validate_block_document_name)@root_validatordefvalidate_name_is_present_if_not_anonymous(cls,values):returnvalidate_name_present_on_nonanonymous_blocks(values)
Data used by the Prefect REST API to update a block document.
Source code in src/prefect/client/schemas/actions.py
513514515516517518519520521522523524525
classBlockDocumentUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a block document."""block_schema_id:Optional[UUID]=Field(default=None,description="A block schema ID")data:Dict[str,Any]=Field(default_factory=dict,description="The block document's data")merge_existing_data:bool=Field(default=True,description="Whether to merge the existing data with the new data or replace it",)
Source code in src/prefect/client/schemas/actions.py
528529530531532533534535536537538539540
classBlockDocumentReferenceCreate(ActionBaseModel):"""Data used to create block document reference."""id:UUID=Field(default_factory=uuid4)parent_block_document_id:UUID=Field(default=...,description="ID of block document the reference is nested within")reference_block_document_id:UUID=Field(default=...,description="ID of the nested block document")name:str=Field(default=...,description="The name that the reference is nested under")
Data used by the Prefect REST API to create a log.
Source code in src/prefect/client/schemas/actions.py
543544545546547548549550551
classLogCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a log."""name:str=Field(default=...,description="The logger name.")level:int=Field(default=...,description="The log level.")message:str=Field(default=...,description="The log message.")timestamp:DateTimeTZ=Field(default=...,description="The log timestamp.")flow_run_id:Optional[UUID]=Field(None)task_run_id:Optional[UUID]=Field(None)
classWorkPoolCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a work pool."""name:str=Field(description="The name of the work pool.",)description:Optional[str]=Field(None)type:str=Field(description="The work pool type.",default="prefect-agent")# TODO: change defaultbase_job_template:Dict[str,Any]=Field(default_factory=dict,description="The base job template for the work pool.",)is_paused:bool=Field(default=False,description="Whether the work pool is paused.",)concurrency_limit:Optional[NonNegativeInteger]=Field(default=None,description="A concurrency limit for the work pool.")
Data used by the Prefect REST API to update a work pool.
Source code in src/prefect/client/schemas/actions.py
577578579580581582583
classWorkPoolUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a work pool."""description:Optional[str]=Field(None)is_paused:Optional[bool]=Field(None)base_job_template:Optional[Dict[str,Any]]=Field(None)concurrency_limit:Optional[int]=Field(None)
classWorkQueueCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a work queue."""name:str=Field(default=...,description="The name of the work queue.")description:Optional[str]=Field(None)is_paused:bool=Field(default=False,description="Whether the work queue is paused.",)concurrency_limit:Optional[int]=Field(default=None,description="A concurrency limit for the work queue.",)priority:Optional[int]=Field(default=None,description=("The queue's priority. Lower values are higher priority (1 is the highest)."),)# DEPRECATEDfilter:Optional[objects.QueueFilter]=Field(None,description="DEPRECATED: Filter criteria for the work queue.",deprecated=True,)
classWorkQueueUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a work queue."""name:Optional[str]=Field(None)description:Optional[str]=Field(None)is_paused:bool=Field(default=False,description="Whether or not the work queue is paused.")concurrency_limit:Optional[int]=Field(None)priority:Optional[int]=Field(None)last_polled:Optional[DateTimeTZ]=Field(None)# DEPRECATEDfilter:Optional[objects.QueueFilter]=Field(None,description="DEPRECATED: Filter criteria for the work queue.",deprecated=True,)
classFlowRunNotificationPolicyCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a flow run notification policy."""is_active:bool=Field(default=True,description="Whether the policy is currently active")state_names:List[str]=Field(default=...,description="The flow run states that trigger notifications")tags:List[str]=Field(default=...,description="The flow run tags that trigger notifications (set [] to disable)",)block_document_id:UUID=Field(default=...,description="The block document ID used for sending notifications")message_template:Optional[str]=Field(default=None,description=("A templatable notification message. Use {braces} to add variables."" Valid variables include:"f" {listrepr(sorted(objects.FLOW_RUN_NOTIFICATION_TEMPLATE_KWARGS),sep=', ')}"),examples=["Flow run {flow_run_name} with id {flow_run_id} entered state"" {flow_run_state_name}."],)@validator("message_template")defvalidate_message_template_variables(cls,v):returnvalidate_message_template_variables(v)
Data used by the Prefect REST API to update a flow run notification policy.
Source code in src/prefect/client/schemas/actions.py
670671672673674675676677
classFlowRunNotificationPolicyUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a flow run notification policy."""is_active:Optional[bool]=Field(None)state_names:Optional[List[str]]=Field(None)tags:Optional[List[str]]=Field(None)block_document_id:Optional[UUID]=Field(None)message_template:Optional[str]=Field(None)
Data used by the Prefect REST API to create an artifact.
Source code in src/prefect/client/schemas/actions.py
680681682683684685686687688689690691692693
classArtifactCreate(ActionBaseModel):"""Data used by the Prefect REST API to create an artifact."""key:Optional[str]=Field(None)type:Optional[str]=Field(None)description:Optional[str]=Field(None)data:Optional[Union[Dict[str,Any],Any]]=Field(None)metadata_:Optional[Dict[str,str]]=Field(None)flow_run_id:Optional[UUID]=Field(None)task_run_id:Optional[UUID]=Field(None)_validate_artifact_format=validator("key",allow_reuse=True)(validate_artifact_key)
Data used by the Prefect REST API to update an artifact.
Source code in src/prefect/client/schemas/actions.py
696697698699700701
classArtifactUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update an artifact."""data:Optional[Union[Dict[str,Any],Any]]=Field(None)description:Optional[str]=Field(None)metadata_:Optional[Dict[str,str]]=Field(None)
classVariableCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a Variable."""name:str=Field(default=...,description="The name of the variable",examples=["my_variable"],max_length=objects.MAX_VARIABLE_NAME_LENGTH,)value:str=Field(default=...,description="The value of the variable",examples=["my-value"],max_length=objects.MAX_VARIABLE_VALUE_LENGTH,)tags:Optional[List[str]]=Field(default=None)# validators_validate_name_format=validator("name",allow_reuse=True)(validate_variable_name)
classVariableUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a Variable."""name:Optional[str]=Field(default=None,description="The name of the variable",examples=["my_variable"],max_length=objects.MAX_VARIABLE_NAME_LENGTH,)value:Optional[str]=Field(default=None,description="The value of the variable",examples=["my-value"],max_length=objects.MAX_VARIABLE_NAME_LENGTH,)tags:Optional[List[str]]=Field(default=None)# validators_validate_name_format=validator("name",allow_reuse=True)(validate_variable_name)
classGlobalConcurrencyLimitCreate(ActionBaseModel):"""Data used by the Prefect REST API to create a global concurrency limit."""name:str=Field(description="The name of the global concurrency limit.")limit:NonNegativeInteger=Field(description=("The maximum number of slots that can be occupied on this concurrency"" limit."))active:Optional[bool]=Field(default=True,description="Whether or not the concurrency limit is in an active state.",)active_slots:Optional[NonNegativeInteger]=Field(default=0,description="Number of tasks currently using a concurrency slot.",)slot_decay_per_second:Optional[NonNegativeFloat]=Field(default=0.0,description=("Controls the rate at which slots are released when the concurrency limit"" is used as a rate limit."),)@validator("name",check_fields=False)defvalidate_name_characters(cls,v):returnraise_on_name_with_banned_characters(v)
Data used by the Prefect REST API to update a global concurrency limit.
Source code in src/prefect/client/schemas/actions.py
777778779780781782783784785786787788
classGlobalConcurrencyLimitUpdate(ActionBaseModel):"""Data used by the Prefect REST API to update a global concurrency limit."""name:Optional[str]=Field(None)limit:Optional[NonNegativeInteger]=Field(None)active:Optional[NonNegativeInteger]=Field(None)active_slots:Optional[NonNegativeInteger]=Field(None)slot_decay_per_second:Optional[NonNegativeFloat]=Field(None)@validator("name",check_fields=False)defvalidate_name_characters(cls,v):returnraise_on_name_with_banned_characters(v)
Base model for Prefect filters that combines criteria with a user-provided operator
Source code in src/prefect/client/schemas/filters.py
28293031323334
classOperatorMixin:"""Base model for Prefect filters that combines criteria with a user-provided operator"""operator:Operator=Field(default=Operator.and_,description="Operator for combining filter criteria. Defaults to 'and_'.",)
Source code in src/prefect/client/schemas/filters.py
373839404142
classFlowFilterId(PrefectBaseModel):"""Filter by `Flow.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow ids to include")
Source code in src/prefect/client/schemas/filters.py
454647484950515253545556575859606162
classFlowFilterName(PrefectBaseModel):"""Filter by `Flow.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of flow names to include",examples=[["my-flow-1","my-flow-2"]],)like_:Optional[str]=Field(default=None,description=("A case-insensitive partial match. For example, "" passing 'marvin' will match ""'marvin', 'sad-Marvin', and 'marvin-robot'."),examples=["marvin"],)
Source code in src/prefect/client/schemas/filters.py
6566676869707172737475767778
classFlowFilterTags(PrefectBaseModel,OperatorMixin):"""Filter by `Flow.tags`."""all_:Optional[List[str]]=Field(default=None,examples=[["tag-1","tag-2"]],description=("A list of tags. Flows will be returned only if their tags are a superset"" of the list"),)is_null_:Optional[bool]=Field(default=None,description="If true, only include flows without tags")
Filter for flows. Only flows matching all criteria will be returned.
Source code in src/prefect/client/schemas/filters.py
818283848586878889909192
classFlowFilter(PrefectBaseModel,OperatorMixin):"""Filter for flows. Only flows matching all criteria will be returned."""id:Optional[FlowFilterId]=Field(default=None,description="Filter criteria for `Flow.id`")name:Optional[FlowFilterName]=Field(default=None,description="Filter criteria for `Flow.name`")tags:Optional[FlowFilterTags]=Field(default=None,description="Filter criteria for `Flow.tags`")
Source code in src/prefect/client/schemas/filters.py
95 96 97 98 99100101102103
classFlowRunFilterId(PrefectBaseModel):"""Filter by FlowRun.id."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run ids to include")not_any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run ids to exclude")
classFlowRunFilterName(PrefectBaseModel):"""Filter by `FlowRun.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of flow run names to include",examples=[["my-flow-run-1","my-flow-run-2"]],)like_:Optional[str]=Field(default=None,description=("A case-insensitive partial match. For example, "" passing 'marvin' will match ""'marvin', 'sad-Marvin', and 'marvin-robot'."),examples=["marvin"],)
Source code in src/prefect/client/schemas/filters.py
126127128129130131132133134135136137138139
classFlowRunFilterTags(PrefectBaseModel,OperatorMixin):"""Filter by `FlowRun.tags`."""all_:Optional[List[str]]=Field(default=None,examples=[["tag-1","tag-2"]],description=("A list of tags. Flow runs will be returned only if their tags are a"" superset of the list"),)is_null_:Optional[bool]=Field(default=None,description="If true, only include flow runs without tags")
Source code in src/prefect/client/schemas/filters.py
142143144145146147148149150151
classFlowRunFilterDeploymentId(PrefectBaseModel,OperatorMixin):"""Filter by `FlowRun.deployment_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run deployment ids to include")is_null_:Optional[bool]=Field(default=None,description="If true, only include flow runs without deployment ids",)
Source code in src/prefect/client/schemas/filters.py
154155156157158159160161162163164165
classFlowRunFilterWorkQueueName(PrefectBaseModel,OperatorMixin):"""Filter by `FlowRun.work_queue_name`."""any_:Optional[List[str]]=Field(default=None,description="A list of work queue names to include",examples=[["work_queue_1","work_queue_2"]],)is_null_:Optional[bool]=Field(default=None,description="If true, only include flow runs without work queue names",)
Source code in src/prefect/client/schemas/filters.py
168169170171172173
classFlowRunFilterStateType(PrefectBaseModel):"""Filter by `FlowRun.state_type`."""any_:Optional[List[StateType]]=Field(default=None,description="A list of flow run state types to include")
Source code in src/prefect/client/schemas/filters.py
187188189190191192
classFlowRunFilterFlowVersion(PrefectBaseModel):"""Filter by `FlowRun.flow_version`."""any_:Optional[List[str]]=Field(default=None,description="A list of flow run flow_versions to include")
Source code in src/prefect/client/schemas/filters.py
195196197198199200201202203204205206207208
classFlowRunFilterStartTime(PrefectBaseModel):"""Filter by `FlowRun.start_time`."""before_:Optional[DateTimeTZ]=Field(default=None,description="Only include flow runs starting at or before this time",)after_:Optional[DateTimeTZ]=Field(default=None,description="Only include flow runs starting at or after this time",)is_null_:Optional[bool]=Field(default=None,description="If true, only return flow runs without a start time")
Source code in src/prefect/client/schemas/filters.py
211212213214215216217218219220221
classFlowRunFilterExpectedStartTime(PrefectBaseModel):"""Filter by `FlowRun.expected_start_time`."""before_:Optional[DateTimeTZ]=Field(default=None,description="Only include flow runs scheduled to start at or before this time",)after_:Optional[DateTimeTZ]=Field(default=None,description="Only include flow runs scheduled to start at or after this time",)
classFlowRunFilterNextScheduledStartTime(PrefectBaseModel):"""Filter by `FlowRun.next_scheduled_start_time`."""before_:Optional[DateTimeTZ]=Field(default=None,description=("Only include flow runs with a next_scheduled_start_time or before this"" time"),)after_:Optional[DateTimeTZ]=Field(default=None,description=("Only include flow runs with a next_scheduled_start_time at or after this"" time"),)
Source code in src/prefect/client/schemas/filters.py
243244245246247248
classFlowRunFilterParentFlowRunId(PrefectBaseModel,OperatorMixin):"""Filter for subflows of the given flow runs"""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run parents to include")
Source code in src/prefect/client/schemas/filters.py
251252253254255256257258259260
classFlowRunFilterParentTaskRunId(PrefectBaseModel,OperatorMixin):"""Filter by `FlowRun.parent_task_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run parent_task_run_ids to include")is_null_:Optional[bool]=Field(default=None,description="If true, only include flow runs without parent_task_run_id",)
Source code in src/prefect/client/schemas/filters.py
263264265266267268269270271
classFlowRunFilterIdempotencyKey(PrefectBaseModel):"""Filter by FlowRun.idempotency_key."""any_:Optional[List[str]]=Field(default=None,description="A list of flow run idempotency keys to include")not_any_:Optional[List[str]]=Field(default=None,description="A list of flow run idempotency keys to exclude")
classFlowRunFilter(PrefectBaseModel,OperatorMixin):"""Filter flow runs. Only flow runs matching all criteria will be returned"""id:Optional[FlowRunFilterId]=Field(default=None,description="Filter criteria for `FlowRun.id`")name:Optional[FlowRunFilterName]=Field(default=None,description="Filter criteria for `FlowRun.name`")tags:Optional[FlowRunFilterTags]=Field(default=None,description="Filter criteria for `FlowRun.tags`")deployment_id:Optional[FlowRunFilterDeploymentId]=Field(default=None,description="Filter criteria for `FlowRun.deployment_id`")work_queue_name:Optional[FlowRunFilterWorkQueueName]=Field(default=None,description="Filter criteria for `FlowRun.work_queue_name")state:Optional[FlowRunFilterState]=Field(default=None,description="Filter criteria for `FlowRun.state`")flow_version:Optional[FlowRunFilterFlowVersion]=Field(default=None,description="Filter criteria for `FlowRun.flow_version`")start_time:Optional[FlowRunFilterStartTime]=Field(default=None,description="Filter criteria for `FlowRun.start_time`")expected_start_time:Optional[FlowRunFilterExpectedStartTime]=Field(default=None,description="Filter criteria for `FlowRun.expected_start_time`")next_scheduled_start_time:Optional[FlowRunFilterNextScheduledStartTime]=Field(default=None,description="Filter criteria for `FlowRun.next_scheduled_start_time`",)parent_flow_run_id:Optional[FlowRunFilterParentFlowRunId]=Field(default=None,description="Filter criteria for subflows of the given flow runs")parent_task_run_id:Optional[FlowRunFilterParentTaskRunId]=Field(default=None,description="Filter criteria for `FlowRun.parent_task_run_id`")idempotency_key:Optional[FlowRunFilterIdempotencyKey]=Field(default=None,description="Filter criteria for `FlowRun.idempotency_key`")
Source code in src/prefect/client/schemas/filters.py
319320321322323324325326327328329
classTaskRunFilterFlowRunId(PrefectBaseModel):"""Filter by `TaskRun.flow_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run ids to include")is_null_:bool=Field(default=False,description="If true, only include task runs without a flow run id",)
Source code in src/prefect/client/schemas/filters.py
332333334335336337
classTaskRunFilterId(PrefectBaseModel):"""Filter by `TaskRun.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of task run ids to include")
classTaskRunFilterName(PrefectBaseModel):"""Filter by `TaskRun.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of task run names to include",examples=[["my-task-run-1","my-task-run-2"]],)like_:Optional[str]=Field(default=None,description=("A case-insensitive partial match. For example, "" passing 'marvin' will match ""'marvin', 'sad-Marvin', and 'marvin-robot'."),examples=["marvin"],)
Source code in src/prefect/client/schemas/filters.py
360361362363364365366367368369370371372373
classTaskRunFilterTags(PrefectBaseModel,OperatorMixin):"""Filter by `TaskRun.tags`."""all_:Optional[List[str]]=Field(default=None,examples=[["tag-1","tag-2"]],description=("A list of tags. Task runs will be returned only if their tags are a"" superset of the list"),)is_null_:Optional[bool]=Field(default=None,description="If true, only include task runs without tags")
Source code in src/prefect/client/schemas/filters.py
376377378379380381
classTaskRunFilterStateType(PrefectBaseModel):"""Filter by `TaskRun.state_type`."""any_:Optional[List[StateType]]=Field(default=None,description="A list of task run state types to include")
Source code in src/prefect/client/schemas/filters.py
395396397398399400401402403404
classTaskRunFilterSubFlowRuns(PrefectBaseModel):"""Filter by `TaskRun.subflow_run`."""exists_:Optional[bool]=Field(default=None,description=("If true, only include task runs that are subflow run parents; if false,"" exclude parent task runs"),)
Source code in src/prefect/client/schemas/filters.py
407408409410411412413414415416417418419420
classTaskRunFilterStartTime(PrefectBaseModel):"""Filter by `TaskRun.start_time`."""before_:Optional[DateTimeTZ]=Field(default=None,description="Only include task runs starting at or before this time",)after_:Optional[DateTimeTZ]=Field(default=None,description="Only include task runs starting at or after this time",)is_null_:Optional[bool]=Field(default=None,description="If true, only return task runs without a start time")
classTaskRunFilter(PrefectBaseModel,OperatorMixin):"""Filter task runs. Only task runs matching all criteria will be returned"""id:Optional[TaskRunFilterId]=Field(default=None,description="Filter criteria for `TaskRun.id`")name:Optional[TaskRunFilterName]=Field(default=None,description="Filter criteria for `TaskRun.name`")tags:Optional[TaskRunFilterTags]=Field(default=None,description="Filter criteria for `TaskRun.tags`")state:Optional[TaskRunFilterState]=Field(default=None,description="Filter criteria for `TaskRun.state`")start_time:Optional[TaskRunFilterStartTime]=Field(default=None,description="Filter criteria for `TaskRun.start_time`")subflow_runs:Optional[TaskRunFilterSubFlowRuns]=Field(default=None,description="Filter criteria for `TaskRun.subflow_run`")flow_run_id:Optional[TaskRunFilterFlowRunId]=Field(default=None,description="Filter criteria for `TaskRun.flow_run_id`")
Source code in src/prefect/client/schemas/filters.py
449450451452453454
classDeploymentFilterId(PrefectBaseModel):"""Filter by `Deployment.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of deployment ids to include")
classDeploymentFilterName(PrefectBaseModel):"""Filter by `Deployment.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of deployment names to include",examples=[["my-deployment-1","my-deployment-2"]],)like_:Optional[str]=Field(default=None,description=("A case-insensitive partial match. For example, "" passing 'marvin' will match ""'marvin', 'sad-Marvin', and 'marvin-robot'."),examples=["marvin"],)
Source code in src/prefect/client/schemas/filters.py
477478479480481482483484
classDeploymentFilterWorkQueueName(PrefectBaseModel):"""Filter by `Deployment.work_queue_name`."""any_:Optional[List[str]]=Field(default=None,description="A list of work queue names to include",examples=[["work_queue_1","work_queue_2"]],)
Source code in src/prefect/client/schemas/filters.py
487488489490491492493
classDeploymentFilterIsScheduleActive(PrefectBaseModel):"""Filter by `Deployment.is_schedule_active`."""eq_:Optional[bool]=Field(default=None,description="Only returns where deployment schedule is/is not active",)
Source code in src/prefect/client/schemas/filters.py
496497498499500501502503504505506507508509
classDeploymentFilterTags(PrefectBaseModel,OperatorMixin):"""Filter by `Deployment.tags`."""all_:Optional[List[str]]=Field(default=None,examples=[["tag-1","tag-2"]],description=("A list of tags. Deployments will be returned only if their tags are a"" superset of the list"),)is_null_:Optional[bool]=Field(default=None,description="If true, only include deployments without tags")
classDeploymentFilter(PrefectBaseModel,OperatorMixin):"""Filter for deployments. Only deployments matching all criteria will be returned."""id:Optional[DeploymentFilterId]=Field(default=None,description="Filter criteria for `Deployment.id`")name:Optional[DeploymentFilterName]=Field(default=None,description="Filter criteria for `Deployment.name`")is_schedule_active:Optional[DeploymentFilterIsScheduleActive]=Field(default=None,description="Filter criteria for `Deployment.is_schedule_active`")tags:Optional[DeploymentFilterTags]=Field(default=None,description="Filter criteria for `Deployment.tags`")work_queue_name:Optional[DeploymentFilterWorkQueueName]=Field(default=None,description="Filter criteria for `Deployment.work_queue_name`")
Source code in src/prefect/client/schemas/filters.py
532533534535536537538539
classLogFilterName(PrefectBaseModel):"""Filter by `Log.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of log names to include",examples=[["prefect.logger.flow_runs","prefect.logger.task_runs"]],)
Source code in src/prefect/client/schemas/filters.py
542543544545546547548549550551552553554555
classLogFilterLevel(PrefectBaseModel):"""Filter by `Log.level`."""ge_:Optional[int]=Field(default=None,description="Include logs with a level greater than or equal to this level",examples=[20],)le_:Optional[int]=Field(default=None,description="Include logs with a level less than or equal to this level",examples=[50],)
Source code in src/prefect/client/schemas/filters.py
558559560561562563564565566567568
classLogFilterTimestamp(PrefectBaseModel):"""Filter by `Log.timestamp`."""before_:Optional[DateTimeTZ]=Field(default=None,description="Only include logs with a timestamp at or before this time",)after_:Optional[DateTimeTZ]=Field(default=None,description="Only include logs with a timestamp at or after this time",)
Source code in src/prefect/client/schemas/filters.py
571572573574575576
classLogFilterFlowRunId(PrefectBaseModel):"""Filter by `Log.flow_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run IDs to include")
Source code in src/prefect/client/schemas/filters.py
579580581582583584
classLogFilterTaskRunId(PrefectBaseModel):"""Filter by `Log.task_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of task run IDs to include")
Filter logs. Only logs matching all criteria will be returned
Source code in src/prefect/client/schemas/filters.py
587588589590591592593594595596597598599600601
classLogFilter(PrefectBaseModel,OperatorMixin):"""Filter logs. Only logs matching all criteria will be returned"""level:Optional[LogFilterLevel]=Field(default=None,description="Filter criteria for `Log.level`")timestamp:Optional[LogFilterTimestamp]=Field(default=None,description="Filter criteria for `Log.timestamp`")flow_run_id:Optional[LogFilterFlowRunId]=Field(default=None,description="Filter criteria for `Log.flow_run_id`")task_run_id:Optional[LogFilterTaskRunId]=Field(default=None,description="Filter criteria for `Log.task_run_id`")
Source code in src/prefect/client/schemas/filters.py
604605606607608609610611612613614615616617618619
classFilterSet(PrefectBaseModel):"""A collection of filters for common objects"""flows:FlowFilter=Field(default_factory=FlowFilter,description="Filters that apply to flows")flow_runs:FlowRunFilter=Field(default_factory=FlowRunFilter,description="Filters that apply to flow runs")task_runs:TaskRunFilter=Field(default_factory=TaskRunFilter,description="Filters that apply to task runs")deployments:DeploymentFilter=Field(default_factory=DeploymentFilter,description="Filters that apply to deployments",)
Source code in src/prefect/client/schemas/filters.py
622623624625626627628629630631632633
classBlockTypeFilterName(PrefectBaseModel):"""Filter by `BlockType.name`"""like_:Optional[str]=Field(default=None,description=("A case-insensitive partial match. For example, "" passing 'marvin' will match ""'marvin', 'sad-Marvin', and 'marvin-robot'."),examples=["marvin"],)
Source code in src/prefect/client/schemas/filters.py
636637638639640641
classBlockTypeFilterSlug(PrefectBaseModel):"""Filter by `BlockType.slug`"""any_:Optional[List[str]]=Field(default=None,description="A list of slugs to match")
Source code in src/prefect/client/schemas/filters.py
644645646647648649650651652653
classBlockTypeFilter(PrefectBaseModel):"""Filter BlockTypes"""name:Optional[BlockTypeFilterName]=Field(default=None,description="Filter criteria for `BlockType.name`")slug:Optional[BlockTypeFilterSlug]=Field(default=None,description="Filter criteria for `BlockType.slug`")
Source code in src/prefect/client/schemas/filters.py
656657658659660661
classBlockSchemaFilterBlockTypeId(PrefectBaseModel):"""Filter by `BlockSchema.block_type_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of block type ids to include")
Source code in src/prefect/client/schemas/filters.py
664665666667668669
classBlockSchemaFilterId(PrefectBaseModel):"""Filter by BlockSchema.id"""any_:Optional[List[UUID]]=Field(default=None,description="A list of IDs to include")
Source code in src/prefect/client/schemas/filters.py
672673674675676677678679680681682
classBlockSchemaFilterCapabilities(PrefectBaseModel):"""Filter by `BlockSchema.capabilities`"""all_:Optional[List[str]]=Field(default=None,examples=[["write-storage","read-storage"]],description=("A list of block capabilities. Block entities will be returned only if an"" associated block schema has a superset of the defined capabilities."),)
Source code in src/prefect/client/schemas/filters.py
685686687688689690691692
classBlockSchemaFilterVersion(PrefectBaseModel):"""Filter by `BlockSchema.capabilities`"""any_:Optional[List[str]]=Field(default=None,examples=[["2.0.0","2.1.0"]],description="A list of block schema versions.",)
Source code in src/prefect/client/schemas/filters.py
695696697698699700701702703704705706707708709
classBlockSchemaFilter(PrefectBaseModel,OperatorMixin):"""Filter BlockSchemas"""block_type_id:Optional[BlockSchemaFilterBlockTypeId]=Field(default=None,description="Filter criteria for `BlockSchema.block_type_id`")block_capabilities:Optional[BlockSchemaFilterCapabilities]=Field(default=None,description="Filter criteria for `BlockSchema.capabilities`")id:Optional[BlockSchemaFilterId]=Field(default=None,description="Filter criteria for `BlockSchema.id`")version:Optional[BlockSchemaFilterVersion]=Field(default=None,description="Filter criteria for `BlockSchema.version`")
Source code in src/prefect/client/schemas/filters.py
712713714715716717718719720
classBlockDocumentFilterIsAnonymous(PrefectBaseModel):"""Filter by `BlockDocument.is_anonymous`."""eq_:Optional[bool]=Field(default=None,description=("Filter block documents for only those that are or are not anonymous."),)
Source code in src/prefect/client/schemas/filters.py
723724725726727728
classBlockDocumentFilterBlockTypeId(PrefectBaseModel):"""Filter by `BlockDocument.block_type_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of block type ids to include")
Source code in src/prefect/client/schemas/filters.py
731732733734735736
classBlockDocumentFilterId(PrefectBaseModel):"""Filter by `BlockDocument.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of block ids to include")
Source code in src/prefect/client/schemas/filters.py
739740741742743744745746747748749750751752
classBlockDocumentFilterName(PrefectBaseModel):"""Filter by `BlockDocument.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of block names to include")like_:Optional[str]=Field(default=None,description=("A string to match block names against. This can include ""SQL wildcard characters like `%` and `_`."),examples=["my-block%"],)
classBlockDocumentFilter(PrefectBaseModel,OperatorMixin):"""Filter BlockDocuments. Only BlockDocuments matching all criteria will be returned"""id:Optional[BlockDocumentFilterId]=Field(default=None,description="Filter criteria for `BlockDocument.id`")is_anonymous:Optional[BlockDocumentFilterIsAnonymous]=Field(# default is to exclude anonymous blocksBlockDocumentFilterIsAnonymous(eq_=False),description=("Filter criteria for `BlockDocument.is_anonymous`. ""Defaults to excluding anonymous blocks."),)block_type_id:Optional[BlockDocumentFilterBlockTypeId]=Field(default=None,description="Filter criteria for `BlockDocument.block_type_id`")name:Optional[BlockDocumentFilterName]=Field(default=None,description="Filter criteria for `BlockDocument.name`")
Source code in src/prefect/client/schemas/filters.py
777778779780781782783784785
classFlowRunNotificationPolicyFilterIsActive(PrefectBaseModel):"""Filter by `FlowRunNotificationPolicy.is_active`."""eq_:Optional[bool]=Field(default=None,description=("Filter notification policies for only those that are or are not active."),)
Source code in src/prefect/client/schemas/filters.py
797798799800801802803
classWorkQueueFilterId(PrefectBaseModel):"""Filter by `WorkQueue.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of work queue ids to include",)
classWorkQueueFilterName(PrefectBaseModel):"""Filter by `WorkQueue.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of work queue names to include",examples=[["wq-1","wq-2"]],)startswith_:Optional[List[str]]=Field(default=None,description=("A list of case-insensitive starts-with matches. For example, "" passing 'marvin' will match ""'marvin', and 'Marvin-robot', but not 'sad-marvin'."),examples=[["marvin","Marvin-robot"]],)
Filter work queues. Only work queues matching all criteria will be
returned
Source code in src/prefect/client/schemas/filters.py
826827828829830831832833834835836
classWorkQueueFilter(PrefectBaseModel,OperatorMixin):"""Filter work queues. Only work queues matching all criteria will be returned"""id:Optional[WorkQueueFilterId]=Field(default=None,description="Filter criteria for `WorkQueue.id`")name:Optional[WorkQueueFilterName]=Field(default=None,description="Filter criteria for `WorkQueue.name`")
Source code in src/prefect/client/schemas/filters.py
839840841842843844
classWorkPoolFilterId(PrefectBaseModel):"""Filter by `WorkPool.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of work pool ids to include")
Source code in src/prefect/client/schemas/filters.py
847848849850851852
classWorkPoolFilterName(PrefectBaseModel):"""Filter by `WorkPool.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of work pool names to include")
Source code in src/prefect/client/schemas/filters.py
855856857858859860
classWorkPoolFilterType(PrefectBaseModel):"""Filter by `WorkPool.type`."""any_:Optional[List[str]]=Field(default=None,description="A list of work pool types to include")
Source code in src/prefect/client/schemas/filters.py
875876877878879880
classWorkerFilterWorkPoolId(PrefectBaseModel):"""Filter by `Worker.worker_config_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of work pool ids to include")
Source code in src/prefect/client/schemas/filters.py
883884885886887888889890891892893894895896897
classWorkerFilterLastHeartbeatTime(PrefectBaseModel):"""Filter by `Worker.last_heartbeat_time`."""before_:Optional[DateTimeTZ]=Field(default=None,description=("Only include processes whose last heartbeat was at or before this time"),)after_:Optional[DateTimeTZ]=Field(default=None,description=("Only include processes whose last heartbeat was at or after this time"),)
Source code in src/prefect/client/schemas/filters.py
911912913914915916
classArtifactFilterId(PrefectBaseModel):"""Filter by `Artifact.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of artifact ids to include")
classArtifactFilterKey(PrefectBaseModel):"""Filter by `Artifact.key`."""any_:Optional[List[str]]=Field(default=None,description="A list of artifact keys to include")like_:Optional[str]=Field(default=None,description=("A string to match artifact keys against. This can include ""SQL wildcard characters like `%` and `_`."),examples=["my-artifact-%"],)exists_:Optional[bool]=Field(default=None,description=("If `true`, only include artifacts with a non-null key. If `false`, ""only include artifacts with a null key."),)
Source code in src/prefect/client/schemas/filters.py
944945946947948949
classArtifactFilterFlowRunId(PrefectBaseModel):"""Filter by `Artifact.flow_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run IDs to include")
Source code in src/prefect/client/schemas/filters.py
952953954955956957
classArtifactFilterTaskRunId(PrefectBaseModel):"""Filter by `Artifact.task_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of task run IDs to include")
Source code in src/prefect/client/schemas/filters.py
960961962963964965966967968
classArtifactFilterType(PrefectBaseModel):"""Filter by `Artifact.type`."""any_:Optional[List[str]]=Field(default=None,description="A list of artifact types to include")not_any_:Optional[List[str]]=Field(default=None,description="A list of artifact types to exclude")
classArtifactFilter(PrefectBaseModel,OperatorMixin):"""Filter artifacts. Only artifacts matching all criteria will be returned"""id:Optional[ArtifactFilterId]=Field(default=None,description="Filter criteria for `Artifact.id`")key:Optional[ArtifactFilterKey]=Field(default=None,description="Filter criteria for `Artifact.key`")flow_run_id:Optional[ArtifactFilterFlowRunId]=Field(default=None,description="Filter criteria for `Artifact.flow_run_id`")task_run_id:Optional[ArtifactFilterTaskRunId]=Field(default=None,description="Filter criteria for `Artifact.task_run_id`")type:Optional[ArtifactFilterType]=Field(default=None,description="Filter criteria for `Artifact.type`")
Source code in src/prefect/client/schemas/filters.py
991992993994995996
classArtifactCollectionFilterLatestId(PrefectBaseModel):"""Filter by `ArtifactCollection.latest_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of artifact ids to include")
classArtifactCollectionFilterKey(PrefectBaseModel):"""Filter by `ArtifactCollection.key`."""any_:Optional[List[str]]=Field(default=None,description="A list of artifact keys to include")like_:Optional[str]=Field(default=None,description=("A string to match artifact keys against. This can include ""SQL wildcard characters like `%` and `_`."),examples=["my-artifact-%"],)exists_:Optional[bool]=Field(default=None,description=("If `true`, only include artifacts with a non-null key. If `false`, ""only include artifacts with a null key. Should return all rows in ""the ArtifactCollection table if specified."),)
Source code in src/prefect/client/schemas/filters.py
102510261027102810291030
classArtifactCollectionFilterFlowRunId(PrefectBaseModel):"""Filter by `ArtifactCollection.flow_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of flow run IDs to include")
Source code in src/prefect/client/schemas/filters.py
103310341035103610371038
classArtifactCollectionFilterTaskRunId(PrefectBaseModel):"""Filter by `ArtifactCollection.task_run_id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of task run IDs to include")
Source code in src/prefect/client/schemas/filters.py
104110421043104410451046104710481049
classArtifactCollectionFilterType(PrefectBaseModel):"""Filter by `ArtifactCollection.type`."""any_:Optional[List[str]]=Field(default=None,description="A list of artifact types to include")not_any_:Optional[List[str]]=Field(default=None,description="A list of artifact types to exclude")
classArtifactCollectionFilter(PrefectBaseModel,OperatorMixin):"""Filter artifact collections. Only artifact collections matching all criteria will be returned"""latest_id:Optional[ArtifactCollectionFilterLatestId]=Field(default=None,description="Filter criteria for `Artifact.id`")key:Optional[ArtifactCollectionFilterKey]=Field(default=None,description="Filter criteria for `Artifact.key`")flow_run_id:Optional[ArtifactCollectionFilterFlowRunId]=Field(default=None,description="Filter criteria for `Artifact.flow_run_id`")task_run_id:Optional[ArtifactCollectionFilterTaskRunId]=Field(default=None,description="Filter criteria for `Artifact.task_run_id`")type:Optional[ArtifactCollectionFilterType]=Field(default=None,description="Filter criteria for `Artifact.type`")
Source code in src/prefect/client/schemas/filters.py
107210731074107510761077
classVariableFilterId(PrefectBaseModel):"""Filter by `Variable.id`."""any_:Optional[List[UUID]]=Field(default=None,description="A list of variable ids to include")
classVariableFilterName(PrefectBaseModel):"""Filter by `Variable.name`."""any_:Optional[List[str]]=Field(default=None,description="A list of variables names to include")like_:Optional[str]=Field(default=None,description=("A string to match variable names against. This can include ""SQL wildcard characters like `%` and `_`."),examples=["my_variable_%"],)
classVariableFilterValue(PrefectBaseModel):"""Filter by `Variable.value`."""any_:Optional[List[str]]=Field(default=None,description="A list of variables value to include")like_:Optional[str]=Field(default=None,description=("A string to match variable value against. This can include ""SQL wildcard characters like `%` and `_`."),examples=["my-value-%"],)
classVariableFilterTags(PrefectBaseModel,OperatorMixin):"""Filter by `Variable.tags`."""all_:Optional[List[str]]=Field(default=None,examples=[["tag-1","tag-2"]],description=("A list of tags. Variables will be returned only if their tags are a"" superset of the list"),)is_null_:Optional[bool]=Field(default=None,description="If true, only include Variables without tags")
classVariableFilter(PrefectBaseModel,OperatorMixin):"""Filter variables. Only variables matching all criteria will be returned"""id:Optional[VariableFilterId]=Field(default=None,description="Filter criteria for `Variable.id`")name:Optional[VariableFilterName]=Field(default=None,description="Filter criteria for `Variable.name`")value:Optional[VariableFilterValue]=Field(default=None,description="Filter criteria for `Variable.value`")tags:Optional[VariableFilterTags]=Field(default=None,description="Filter criteria for `Variable.tags`")
Source code in src/prefect/client/schemas/objects.py
798081828384858687888990
classStateType(AutoEnum):"""Enumeration of state types."""SCHEDULED=AutoEnum.auto()PENDING=AutoEnum.auto()RUNNING=AutoEnum.auto()COMPLETED=AutoEnum.auto()FAILED=AutoEnum.auto()CANCELLED=AutoEnum.auto()CRASHED=AutoEnum.auto()PAUSED=AutoEnum.auto()CANCELLING=AutoEnum.auto()
classState(ObjectBaseModel,Generic[R]):""" The state of a run. """type:StateTypename:Optional[str]=Field(default=None)timestamp:DateTimeTZ=Field(default_factory=lambda:pendulum.now("UTC"))message:Optional[str]=Field(default=None,examples=["Run started"])state_details:StateDetails=Field(default_factory=StateDetails)data:Union["BaseResult[R]","DataDocument[R]",Any]=Field(default=None,)@overloaddefresult(self:"State[R]",raise_on_failure:bool=True)->R:...@overloaddefresult(self:"State[R]",raise_on_failure:bool=False)->Union[R,Exception]:...defresult(self,raise_on_failure:bool=True,fetch:Optional[bool]=None)->Union[R,Exception]:""" Retrieve the result attached to this state. Args: raise_on_failure: a boolean specifying whether to raise an exception if the state is of type `FAILED` and the underlying data is an exception fetch: a boolean specifying whether to resolve references to persisted results into data. For synchronous users, this defaults to `True`. For asynchronous users, this defaults to `False` for backwards compatibility. Raises: TypeError: If the state is failed but the result is not an exception. Returns: The result of the run Examples: >>> from prefect import flow, task >>> @task >>> def my_task(x): >>> return x Get the result from a task future in a flow >>> @flow >>> def my_flow(): >>> future = my_task("hello") >>> state = future.wait() >>> result = state.result() >>> print(result) >>> my_flow() hello Get the result from a flow state >>> @flow >>> def my_flow(): >>> return "hello" >>> my_flow(return_state=True).result() hello Get the result from a failed state >>> @flow >>> def my_flow(): >>> raise ValueError("oh no!") >>> state = my_flow(return_state=True) # Error is wrapped in FAILED state >>> state.result() # Raises `ValueError` Get the result from a failed state without erroring >>> @flow >>> def my_flow(): >>> raise ValueError("oh no!") >>> state = my_flow(return_state=True) >>> result = state.result(raise_on_failure=False) >>> print(result) ValueError("oh no!") Get the result from a flow state in an async context >>> @flow >>> async def my_flow(): >>> return "hello" >>> state = await my_flow(return_state=True) >>> await state.result() hello """fromprefect.statesimportget_state_resultreturnget_state_result(self,raise_on_failure=raise_on_failure,fetch=fetch)defto_state_create(self):""" Convert this state to a `StateCreate` type which can be used to set the state of a run in the API. This method will drop this state's `data` if it is not a result type. Only results should be sent to the API. Other data is only available locally. """fromprefect.client.schemas.actionsimportStateCreatefromprefect.resultsimportBaseResultreturnStateCreate(type=self.type,name=self.name,message=self.message,data=self.dataifisinstance(self.data,BaseResult)elseNone,state_details=self.state_details,)@validator("name",always=True)defdefault_name_from_type(cls,v,*,values,**kwargs):returnget_or_create_state_name(v,values)@root_validatordefdefault_scheduled_start_time(cls,values):""" TODO: This should throw an error instead of setting a default but is out of scope for https://github.com/PrefectHQ/orion/pull/174/ and can be rolled into work refactoring state initialization """ifvalues.get("type")==StateType.SCHEDULED:state_details=values.setdefault("state_details",cls.__fields__["state_details"].get_default())ifnotstate_details.scheduled_time:state_details.scheduled_time=pendulum.now("utc")returnvaluesdefis_scheduled(self)->bool:returnself.type==StateType.SCHEDULEDdefis_pending(self)->bool:returnself.type==StateType.PENDINGdefis_running(self)->bool:returnself.type==StateType.RUNNINGdefis_completed(self)->bool:returnself.type==StateType.COMPLETEDdefis_failed(self)->bool:returnself.type==StateType.FAILEDdefis_crashed(self)->bool:returnself.type==StateType.CRASHEDdefis_cancelled(self)->bool:returnself.type==StateType.CANCELLEDdefis_cancelling(self)->bool:returnself.type==StateType.CANCELLINGdefis_final(self)->bool:returnself.typein{StateType.CANCELLED,StateType.FAILED,StateType.COMPLETED,StateType.CRASHED,}defis_paused(self)->bool:returnself.type==StateType.PAUSEDdefcopy(self,*,update:Optional[Dict[str,Any]]=None,reset_fields:bool=False,**kwargs,):""" Copying API models should return an object that could be inserted into the database again. The 'timestamp' is reset using the default factory. """update=updateor{}update.setdefault("timestamp",self.__fields__["timestamp"].get_default())returnsuper().copy(reset_fields=reset_fields,update=update,**kwargs)def__repr__(self)->str:""" Generates a complete state representation appropriate for introspection and debugging, including the result: `MyCompletedState(message="my message", type=COMPLETED, result=...)` """fromprefect.deprecated.data_documentsimportDataDocumentifisinstance(self.data,DataDocument):result=self.data.decode()else:result=self.datadisplay=dict(message=repr(self.message),type=str(self.type.value),result=repr(result),)returnf"{self.name}({', '.join(f'{k}={v}'fork,vindisplay.items())})"def__str__(self)->str:""" Generates a simple state representation appropriate for logging: `MyCompletedState("my message", type=COMPLETED)` """display=[]ifself.message:display.append(repr(self.message))ifself.type.value.lower()!=self.name.lower():display.append(f"type={self.type.value}")returnf"{self.name}({', '.join(display)})"def__hash__(self)->int:returnhash((getattr(self.state_details,"flow_run_id",None),getattr(self.state_details,"task_run_id",None),self.timestamp,self.type,))
a boolean specifying whether to raise an exception
if the state is of type FAILED and the underlying data is an exception
True
fetch
Optional[bool]
a boolean specifying whether to resolve references to persisted
results into data. For synchronous users, this defaults to True.
For asynchronous users, this defaults to False for backwards
compatibility.
None
Raises:
Type
Description
TypeError
If the state is failed but the result is not an exception.
defresult(self,raise_on_failure:bool=True,fetch:Optional[bool]=None)->Union[R,Exception]:""" Retrieve the result attached to this state. Args: raise_on_failure: a boolean specifying whether to raise an exception if the state is of type `FAILED` and the underlying data is an exception fetch: a boolean specifying whether to resolve references to persisted results into data. For synchronous users, this defaults to `True`. For asynchronous users, this defaults to `False` for backwards compatibility. Raises: TypeError: If the state is failed but the result is not an exception. Returns: The result of the run Examples: >>> from prefect import flow, task >>> @task >>> def my_task(x): >>> return x Get the result from a task future in a flow >>> @flow >>> def my_flow(): >>> future = my_task("hello") >>> state = future.wait() >>> result = state.result() >>> print(result) >>> my_flow() hello Get the result from a flow state >>> @flow >>> def my_flow(): >>> return "hello" >>> my_flow(return_state=True).result() hello Get the result from a failed state >>> @flow >>> def my_flow(): >>> raise ValueError("oh no!") >>> state = my_flow(return_state=True) # Error is wrapped in FAILED state >>> state.result() # Raises `ValueError` Get the result from a failed state without erroring >>> @flow >>> def my_flow(): >>> raise ValueError("oh no!") >>> state = my_flow(return_state=True) >>> result = state.result(raise_on_failure=False) >>> print(result) ValueError("oh no!") Get the result from a flow state in an async context >>> @flow >>> async def my_flow(): >>> return "hello" >>> state = await my_flow(return_state=True) >>> await state.result() hello """fromprefect.statesimportget_state_resultreturnget_state_result(self,raise_on_failure=raise_on_failure,fetch=fetch)
defto_state_create(self):""" Convert this state to a `StateCreate` type which can be used to set the state of a run in the API. This method will drop this state's `data` if it is not a result type. Only results should be sent to the API. Other data is only available locally. """fromprefect.client.schemas.actionsimportStateCreatefromprefect.resultsimportBaseResultreturnStateCreate(type=self.type,name=self.name,message=self.message,data=self.dataifisinstance(self.data,BaseResult)elseNone,state_details=self.state_details,)
This should throw an error instead of setting a default but is out of
scope for https://github.com/PrefectHQ/orion/pull/174/ and can be rolled
into work refactoring state initialization
Source code in src/prefect/client/schemas/objects.py
264265266267268269270271272273274275276277
@root_validatordefdefault_scheduled_start_time(cls,values):""" TODO: This should throw an error instead of setting a default but is out of scope for https://github.com/PrefectHQ/orion/pull/174/ and can be rolled into work refactoring state initialization """ifvalues.get("type")==StateType.SCHEDULED:state_details=values.setdefault("state_details",cls.__fields__["state_details"].get_default())ifnotstate_details.scheduled_time:state_details.scheduled_time=pendulum.now("utc")returnvalues
classFlowRunPolicy(PrefectBaseModel):"""Defines of how a flow run should be orchestrated."""max_retries:int=Field(default=0,description=("The maximum number of retries. Field is not used. Please use `retries`"" instead."),deprecated=True,)retry_delay_seconds:float=Field(default=0,description=("The delay between retries. Field is not used. Please use `retry_delay`"" instead."),deprecated=True,)retries:Optional[int]=Field(default=None,description="The number of retries.")retry_delay:Optional[int]=Field(default=None,description="The delay time between retries, in seconds.")pause_keys:Optional[set]=Field(default_factory=set,description="Tracks pauses this run has observed.")resuming:Optional[bool]=Field(default=False,description="Indicates if this run is resuming from a pause.")@root_validatordefpopulate_deprecated_fields(cls,values):returnset_run_policy_deprecated_fields(values)
classFlowRun(ObjectBaseModel):name:str=Field(default_factory=lambda:generate_slug(2),description=("The name of the flow run. Defaults to a random slug if not specified."),examples=["my-flow-run"],)flow_id:UUID=Field(default=...,description="The id of the flow being run.")state_id:Optional[UUID]=Field(default=None,description="The id of the flow run's current state.")deployment_id:Optional[UUID]=Field(default=None,description=("The id of the deployment associated with this flow run, if available."),)deployment_version:Optional[str]=Field(default=None,description="The version of the deployment associated with this flow run.",examples=["1.0"],)work_queue_name:Optional[str]=Field(default=None,description="The work queue that handled this flow run.")flow_version:Optional[str]=Field(default=None,description="The version of the flow executed in this flow run.",examples=["1.0"],)parameters:Dict[str,Any]=Field(default_factory=dict,description="Parameters for the flow run.")idempotency_key:Optional[str]=Field(default=None,description=("An optional idempotency key for the flow run. Used to ensure the same flow"" run is not created multiple times."),)context:Dict[str,Any]=Field(default_factory=dict,description="Additional context for the flow run.",examples=[{"my_var":"my_val"}],)empirical_policy:FlowRunPolicy=Field(default_factory=FlowRunPolicy,)tags:List[str]=Field(default_factory=list,description="A list of tags on the flow run",examples=[["tag-1","tag-2"]],)parent_task_run_id:Optional[UUID]=Field(default=None,description=("If the flow run is a subflow, the id of the 'dummy' task in the parent"" flow used to track subflow state."),)run_count:int=Field(default=0,description="The number of times the flow run was executed.")expected_start_time:Optional[DateTimeTZ]=Field(default=None,description="The flow run's expected start time.",)next_scheduled_start_time:Optional[DateTimeTZ]=Field(default=None,description="The next time the flow run is scheduled to start.",)start_time:Optional[DateTimeTZ]=Field(default=None,description="The actual start time.")end_time:Optional[DateTimeTZ]=Field(default=None,description="The actual end time.")total_run_time:datetime.timedelta=Field(default=datetime.timedelta(0),description=("Total run time. If the flow run was executed multiple times, the time of"" each run will be summed."),)estimated_run_time:datetime.timedelta=Field(default=datetime.timedelta(0),description="A real-time estimate of the total run time.",)estimated_start_time_delta:datetime.timedelta=Field(default=datetime.timedelta(0),description="The difference between actual and expected start time.",)auto_scheduled:bool=Field(default=False,description="Whether or not the flow run was automatically scheduled.",)infrastructure_document_id:Optional[UUID]=Field(default=None,description="The block document defining infrastructure to use this flow run.",)infrastructure_pid:Optional[str]=Field(default=None,description="The id of the flow run as returned by an infrastructure block.",)created_by:Optional[CreatedBy]=Field(default=None,description="Optional information about the creator of this flow run.",)work_queue_id:Optional[UUID]=Field(default=None,description="The id of the run's work pool queue.")work_pool_id:Optional[UUID]=Field(description="The work pool with which the queue is associated.")work_pool_name:Optional[str]=Field(default=None,description="The name of the flow run's work pool.",examples=["my-work-pool"],)state:Optional[State]=Field(default=None,description="The state of the flow run.",examples=[State(type=StateType.COMPLETED)],)job_variables:Optional[dict]=Field(default=None,description="Job variables for the flow run.")# These are server-side optimizations and should not be present on client models# TODO: Deprecate these fieldsstate_type:Optional[StateType]=Field(default=None,description="The type of the current flow run state.")state_name:Optional[str]=Field(default=None,description="The name of the current flow run state.")def__eq__(self,other:Any)->bool:""" Check for "equality" to another flow run schema Estimates times are rolling and will always change with repeated queries for a flow run so we ignore them during equality checks. """ifisinstance(other,FlowRun):exclude_fields={"estimated_run_time","estimated_start_time_delta"}returnself.dict(exclude=exclude_fields)==other.dict(exclude=exclude_fields)returnsuper().__eq__(other)@validator("name",pre=True)defset_default_name(cls,name):returnget_or_create_run_name(name)
classTaskRunPolicy(PrefectBaseModel):"""Defines of how a task run should retry."""max_retries:int=Field(default=0,description=("The maximum number of retries. Field is not used. Please use `retries`"" instead."),deprecated=True,)retry_delay_seconds:float=Field(default=0,description=("The delay between retries. Field is not used. Please use `retry_delay`"" instead."),deprecated=True,)retries:Optional[int]=Field(default=None,description="The number of retries.")retry_delay:Union[None,int,List[int]]=Field(default=None,description="A delay time or list of delay times between retries, in seconds.",)retry_jitter_factor:Optional[float]=Field(default=None,description="Determines the amount a retry should jitter")@root_validatordefpopulate_deprecated_fields(cls,values):returnset_run_policy_deprecated_fields(values)@validator("retry_delay")defvalidate_configured_retry_delays(cls,v):returnlist_length_50_or_less(v)@validator("retry_jitter_factor")defvalidate_jitter_factor(cls,v):returnvalidate_not_negative(v)
Base class for classes that represent inputs to task runs, which
could include, constants, parameters, or other task runs.
Source code in src/prefect/client/schemas/objects.py
614615616617618619620621622623624
classTaskRunInput(PrefectBaseModel):""" Base class for classes that represent inputs to task runs, which could include, constants, parameters, or other task runs. """# freeze TaskRunInputs to allow them to be placed in setsclassConfig:frozen=Trueinput_type:str
classWorkspace(PrefectBaseModel):""" A Prefect Cloud workspace. Expected payload for each workspace returned by the `me/workspaces` route. """account_id:UUID=Field(...,description="The account id of the workspace.")account_name:str=Field(...,description="The account name.")account_handle:str=Field(...,description="The account's unique handle.")workspace_id:UUID=Field(...,description="The workspace id.")workspace_name:str=Field(...,description="The workspace name.")workspace_description:str=Field(...,description="Description of the workspace.")workspace_handle:str=Field(...,description="The workspace's unique handle.")classConfig:extra="ignore"@propertydefhandle(self)->str:""" The full handle of the workspace as `account_handle` / `workspace_handle` """returnself.account_handle+"/"+self.workspace_handledefapi_url(self)->str:""" Generate the API URL for accessing this workspace """return(f"{PREFECT_CLOUD_API_URL.value()}"f"/accounts/{self.account_id}"f"/workspaces/{self.workspace_id}")defui_url(self)->str:""" Generate the UI URL for accessing this workspace """return(f"{PREFECT_CLOUD_UI_URL.value()}"f"/account/{self.account_id}"f"/workspace/{self.workspace_id}")def__hash__(self):returnhash(self.handle)
Source code in src/prefect/client/schemas/objects.py
783784785786787788789790791
defapi_url(self)->str:""" Generate the API URL for accessing this workspace """return(f"{PREFECT_CLOUD_API_URL.value()}"f"/accounts/{self.account_id}"f"/workspaces/{self.workspace_id}")
Source code in src/prefect/client/schemas/objects.py
793794795796797798799800801
defui_url(self)->str:""" Generate the UI URL for accessing this workspace """return(f"{PREFECT_CLOUD_UI_URL.value()}"f"/account/{self.account_id}"f"/workspace/{self.workspace_id}")
classBlockType(ObjectBaseModel):"""An ORM representation of a block type"""name:str=Field(default=...,description="A block type's name")slug:str=Field(default=...,description="A block type's slug")logo_url:Optional[HttpUrl]=Field(default=None,description="Web URL for the block type's logo")documentation_url:Optional[HttpUrl]=Field(default=None,description="Web URL for the block type's documentation")description:Optional[str]=Field(default=None,description="A short blurb about the corresponding block's intended use",)code_example:Optional[str]=Field(default=None,description="A code snippet demonstrating use of the corresponding block",)is_protected:bool=Field(default=False,description="Protected block types cannot be modified via API.")@validator("name",check_fields=False)defvalidate_name_characters(cls,v):returnraise_on_name_with_banned_characters(v)
classBlockDocument(ObjectBaseModel):"""An ORM representation of a block document."""name:Optional[str]=Field(default=None,description=("The block document's name. Not required for anonymous block documents."),)data:Dict[str,Any]=Field(default_factory=dict,description="The block document's data")block_schema_id:UUID=Field(default=...,description="A block schema ID")block_schema:Optional[BlockSchema]=Field(default=None,description="The associated block schema")block_type_id:UUID=Field(default=...,description="A block type ID")block_type_name:Optional[str]=Field(None,description="A block type name")block_type:Optional[BlockType]=Field(default=None,description="The associated block type")block_document_references:Dict[str,Dict[str,Any]]=Field(default_factory=dict,description="Record of the block document's references")is_anonymous:bool=Field(default=False,description=("Whether the block is anonymous (anonymous blocks are usually created by"" Prefect automatically)"),)@validator("name",check_fields=False)defvalidate_name_characters(cls,v):# the BlockDocumentCreate subclass allows name=None# and will inherit this validatorreturnraise_on_name_with_banned_characters(v)@root_validatordefvalidate_name_is_present_if_not_anonymous(cls,values):returnvalidate_name_present_on_nonanonymous_blocks(values)
Source code in src/prefect/client/schemas/objects.py
899900901902903904905906907908909910911912913
classFlow(ObjectBaseModel):"""An ORM representation of flow data."""name:str=Field(default=...,description="The name of the flow",examples=["my-flow"])tags:List[str]=Field(default_factory=list,description="A list of flow tags",examples=[["tag-1","tag-2"]],)@validator("name",check_fields=False)defvalidate_name_characters(cls,v):returnraise_on_name_with_banned_characters(v)
classDeployment(DeprecatedInfraOverridesField,ObjectBaseModel):"""An ORM representation of deployment data."""name:str=Field(default=...,description="The name of the deployment.")version:Optional[str]=Field(default=None,description="An optional version for the deployment.")description:Optional[str]=Field(default=None,description="A description for the deployment.")flow_id:UUID=Field(default=...,description="The flow id associated with the deployment.")schedule:Optional[SCHEDULE_TYPES]=Field(default=None,description="A schedule for the deployment.")is_schedule_active:bool=Field(default=True,description="Whether or not the deployment schedule is active.")paused:bool=Field(default=False,description="Whether or not the deployment is paused.")schedules:List[DeploymentSchedule]=Field(default_factory=list,description="A list of schedules for the deployment.")job_variables:Dict[str,Any]=Field(default_factory=dict,description="Overrides to apply to flow run infrastructure at runtime.",)parameters:Dict[str,Any]=Field(default_factory=dict,description="Parameters for flow runs scheduled by the deployment.",)pull_steps:Optional[List[dict]]=Field(default=None,description="Pull steps for cloning and running this deployment.",)tags:List[str]=Field(default_factory=list,description="A list of tags for the deployment",examples=[["tag-1","tag-2"]],)work_queue_name:Optional[str]=Field(default=None,description=("The work queue for the deployment. If no work queue is set, work will not"" be scheduled."),)last_polled:Optional[DateTimeTZ]=Field(default=None,description="The last time the deployment was polled for status updates.",)parameter_openapi_schema:Optional[Dict[str,Any]]=Field(default=None,description="The parameter schema of the flow, including defaults.",)path:Optional[str]=Field(default=None,description=("The path to the working directory for the workflow, relative to remote"" storage or an absolute path."),)entrypoint:Optional[str]=Field(default=None,description=("The path to the entrypoint for the workflow, relative to the `path`."),)manifest_path:Optional[str]=Field(default=None,description=("The path to the flow's manifest file, relative to the chosen storage."),)storage_document_id:Optional[UUID]=Field(default=None,description="The block document defining storage used for this flow.",)infrastructure_document_id:Optional[UUID]=Field(default=None,description="The block document defining infrastructure to use for flow runs.",)created_by:Optional[CreatedBy]=Field(default=None,description="Optional information about the creator of this deployment.",)updated_by:Optional[UpdatedBy]=Field(default=None,description="Optional information about the updater of this deployment.",)work_queue_id:UUID=Field(default=None,description=("The id of the work pool queue to which this deployment is assigned."),)enforce_parameter_schema:bool=Field(default=False,description=("Whether or not the deployment should enforce the parameter schema."),)@validator("name",check_fields=False)defvalidate_name_characters(cls,v):returnraise_on_name_with_banned_characters(v)
Source code in src/prefect/client/schemas/objects.py
10601061106210631064106510661067106810691070
classConcurrencyLimit(ObjectBaseModel):"""An ORM representation of a concurrency limit."""tag:str=Field(default=...,description="A tag the concurrency limit is applied to.")concurrency_limit:int=Field(default=...,description="The concurrency limit.")active_slots:List[UUID]=Field(default_factory=list,description="A list of active run ids using a concurrency slot",)
classBlockSchema(ObjectBaseModel):"""An ORM representation of a block schema."""checksum:str=Field(default=...,description="The block schema's unique checksum")fields:Dict[str,Any]=Field(default_factory=dict,description="The block schema's field schema")block_type_id:Optional[UUID]=Field(default=...,description="A block type ID")block_type:Optional[BlockType]=Field(default=None,description="The associated block type")capabilities:List[str]=Field(default_factory=list,description="A list of Block capabilities",)version:str=Field(default=DEFAULT_BLOCK_SCHEMA_VERSION,description="Human readable identifier for the block schema",)
classBlockSchemaReference(ObjectBaseModel):"""An ORM representation of a block schema reference."""parent_block_schema_id:UUID=Field(default=...,description="ID of block schema the reference is nested within")parent_block_schema:Optional[BlockSchema]=Field(default=None,description="The block schema the reference is nested within")reference_block_schema_id:UUID=Field(default=...,description="ID of the nested block schema")reference_block_schema:Optional[BlockSchema]=Field(default=None,description="The nested block schema")name:str=Field(default=...,description="The name that the reference is nested under")
classBlockDocumentReference(ObjectBaseModel):"""An ORM representation of a block document reference."""parent_block_document_id:UUID=Field(default=...,description="ID of block document the reference is nested within")parent_block_document:Optional[BlockDocument]=Field(default=None,description="The block document the reference is nested within")reference_block_document_id:UUID=Field(default=...,description="ID of the nested block document")reference_block_document:Optional[BlockDocument]=Field(default=None,description="The nested block document")name:str=Field(default=...,description="The name that the reference is nested under")@root_validatordefvalidate_parent_and_ref_are_different(cls,values):returnvalidate_parent_and_ref_diff(values)
classSavedSearchFilter(PrefectBaseModel):"""A filter for a saved search model. Intended for use by the Prefect UI."""object:str=Field(default=...,description="The object over which to filter.")property:str=Field(default=...,description="The property of the object on which to filter.")type:str=Field(default=...,description="The type of the property.")operation:str=Field(default=...,description="The operator to apply to the object. For example, `equals`.",)value:Any=Field(default=...,description="A JSON-compatible value for the filter.")
An ORM representation of saved search data. Represents a set of filter criteria.
Source code in src/prefect/client/schemas/objects.py
1162116311641165116611671168
classSavedSearch(ObjectBaseModel):"""An ORM representation of saved search data. Represents a set of filter criteria."""name:str=Field(default=...,description="The name of the saved search.")filters:List[SavedSearchFilter]=Field(default_factory=list,description="The filter set for the saved search.")
classLog(ObjectBaseModel):"""An ORM representation of log data."""name:str=Field(default=...,description="The logger name.")level:int=Field(default=...,description="The log level.")message:str=Field(default=...,description="The log message.")timestamp:DateTimeTZ=Field(default=...,description="The log timestamp.")flow_run_id:Optional[UUID]=Field(default=None,description="The flow run ID associated with the log.")task_run_id:Optional[UUID]=Field(default=None,description="The task run ID associated with the log.")
Source code in src/prefect/client/schemas/objects.py
11861187118811891190119111921193119411951196
classQueueFilter(PrefectBaseModel):"""Filter criteria definition for a work queue."""tags:Optional[List[str]]=Field(default=None,description="Only include flow runs with these tags in the work queue.",)deployment_ids:Optional[List[UUID]]=Field(default=None,description="Only include flow runs from these deployments in the work queue.",)
classWorkQueue(ObjectBaseModel):"""An ORM representation of a work queue"""name:str=Field(default=...,description="The name of the work queue.")description:Optional[str]=Field(default="",description="An optional description for the work queue.")is_paused:bool=Field(default=False,description="Whether or not the work queue is paused.")concurrency_limit:Optional[NonNegativeInteger]=Field(default=None,description="An optional concurrency limit for the work queue.")priority:PositiveInteger=Field(default=1,description=("The queue's priority. Lower values are higher priority (1 is the highest)."),)work_pool_name:Optional[str]=Field(default=None)# Will be required after a future migrationwork_pool_id:Optional[UUID]=Field(description="The work pool with which the queue is associated.")filter:Optional[QueueFilter]=Field(default=None,description="DEPRECATED: Filter criteria for the work queue.",deprecated=True,)last_polled:Optional[DateTimeTZ]=Field(default=None,description="The last time an agent polled this queue for work.")status:Optional[WorkQueueStatus]=Field(default=None,description="The queue status.")@validator("name",check_fields=False)defvalidate_name_characters(cls,v):returnraise_on_name_with_banned_characters(v)
classWorkQueueHealthPolicy(PrefectBaseModel):maximum_late_runs:Optional[int]=Field(default=0,description=("The maximum number of late runs in the work queue before it is deemed"" unhealthy. Defaults to `0`."),)maximum_seconds_since_last_polled:Optional[int]=Field(default=60,description=("The maximum number of time in seconds elapsed since work queue has been"" polled before it is deemed unhealthy. Defaults to `60`."),)defevaluate_health_status(self,late_runs_count:int,last_polled:Optional[DateTimeTZ]=None)->bool:""" Given empirical information about the state of the work queue, evaluate its health status. Args: late_runs: the count of late runs for the work queue. last_polled: the last time the work queue was polled, if available. Returns: bool: whether or not the work queue is healthy. """healthy=Trueif(self.maximum_late_runsisnotNoneandlate_runs_count>self.maximum_late_runs):healthy=Falseifself.maximum_seconds_since_last_polledisnotNone:if(last_polledisNoneorpendulum.now("UTC").diff(last_polled).in_seconds()>self.maximum_seconds_since_last_polled):healthy=Falsereturnhealthy
defevaluate_health_status(self,late_runs_count:int,last_polled:Optional[DateTimeTZ]=None)->bool:""" Given empirical information about the state of the work queue, evaluate its health status. Args: late_runs: the count of late runs for the work queue. last_polled: the last time the work queue was polled, if available. Returns: bool: whether or not the work queue is healthy. """healthy=Trueif(self.maximum_late_runsisnotNoneandlate_runs_count>self.maximum_late_runs):healthy=Falseifself.maximum_seconds_since_last_polledisnotNone:if(last_polledisNoneorpendulum.now("UTC").diff(last_polled).in_seconds()>self.maximum_seconds_since_last_polled):healthy=Falsereturnhealthy
classFlowRunNotificationPolicy(ObjectBaseModel):"""An ORM representation of a flow run notification."""is_active:bool=Field(default=True,description="Whether the policy is currently active")state_names:List[str]=Field(default=...,description="The flow run states that trigger notifications")tags:List[str]=Field(default=...,description="The flow run tags that trigger notifications (set [] to disable)",)block_document_id:UUID=Field(default=...,description="The block document ID used for sending notifications")message_template:Optional[str]=Field(default=None,description=("A templatable notification message. Use {braces} to add variables."" Valid variables include:"f" {listrepr(sorted(FLOW_RUN_NOTIFICATION_TEMPLATE_KWARGS),sep=', ')}"),examples=["Flow run {flow_run_name} with id {flow_run_id} entered state"" {flow_run_state_name}."],)@validator("message_template")defvalidate_message_template_variables(cls,v):returnvalidate_message_template_variables(v)
classAgent(ObjectBaseModel):"""An ORM representation of an agent"""name:str=Field(default_factory=lambda:generate_slug(2),description=("The name of the agent. If a name is not provided, it will be"" auto-generated."),)work_queue_id:UUID=Field(default=...,description="The work queue with which the agent is associated.")last_activity_time:Optional[DateTimeTZ]=Field(default=None,description="The last time this agent polled for work.")
classWorkPool(ObjectBaseModel):"""An ORM representation of a work pool"""name:str=Field(description="The name of the work pool.",)description:Optional[str]=Field(default=None,description="A description of the work pool.")type:str=Field(description="The work pool type.")base_job_template:Dict[str,Any]=Field(default_factory=dict,description="The work pool's base job template.")is_paused:bool=Field(default=False,description="Pausing the work pool stops the delivery of all work.",)concurrency_limit:Optional[NonNegativeInteger]=Field(default=None,description="A concurrency limit for the work pool.")status:Optional[WorkPoolStatus]=Field(default=None,description="The current status of the work pool.")# this required field has a default of None so that the custom validator# below will be called and produce a more helpful error messagedefault_queue_id:UUID=Field(None,description="The id of the pool's default queue.")@propertydefis_push_pool(self)->bool:returnself.type.endswith(":push")@propertydefis_managed_pool(self)->bool:returnself.type.endswith(":managed")@validator("name",check_fields=False)defvalidate_name_characters(cls,v):returnraise_on_name_with_banned_characters(v)@validator("default_queue_id",always=True)defhelpful_error_for_missing_default_queue_id(cls,v):returnvalidate_default_queue_id_not_none(v)
classWorker(ObjectBaseModel):"""An ORM representation of a worker"""name:str=Field(description="The name of the worker.")work_pool_id:UUID=Field(description="The work pool with which the queue is associated.")last_heartbeat_time:datetime.datetime=Field(None,description="The last time the worker process sent a heartbeat.")heartbeat_interval_seconds:Optional[int]=Field(default=None,description=("The number of seconds to expect between heartbeats sent by the worker."),)status:WorkerStatus=Field(WorkerStatus.OFFLINE,description="Current status of the worker.",)
classFlowRunInput(ObjectBaseModel):flow_run_id:UUID=Field(description="The flow run ID associated with the input.")key:str=Field(description="The key of the input.")value:str=Field(description="The value of the input.")sender:Optional[str]=Field(description="The sender of the input.")@propertydefdecoded_value(self)->Any:""" Decode the value of the input. Returns: Any: the decoded value """returnorjson.loads(self.value)@validator("key",check_fields=False)defvalidate_name_characters(cls,v):raise_on_name_alphanumeric_dashes_only(v)returnv
classGlobalConcurrencyLimit(ObjectBaseModel):"""An ORM representation of a global concurrency limit"""name:str=Field(description="The name of the global concurrency limit.")limit:int=Field(description=("The maximum number of slots that can be occupied on this concurrency"" limit."))active:Optional[bool]=Field(default=True,description="Whether or not the concurrency limit is in an active state.",)active_slots:Optional[int]=Field(default=0,description="Number of tasks currently using a concurrency slot.",)slot_decay_per_second:Optional[float]=Field(default=0.0,description=("Controls the rate at which slots are released when the concurrency limit"" is used as a rate limit."),)
Enumerates return statuses for setting run states.
Source code in src/prefect/client/schemas/responses.py
25262728293031
classSetStateStatus(AutoEnum):"""Enumerates return statuses for setting run states."""ACCEPT=AutoEnum.auto()REJECT=AutoEnum.auto()ABORT=AutoEnum.auto()WAIT=AutoEnum.auto()
Details associated with an ACCEPT state transition.
Source code in src/prefect/client/schemas/responses.py
34353637383940414243
classStateAcceptDetails(PrefectBaseModel):"""Details associated with an ACCEPT state transition."""type:Literal["accept_details"]=Field(default="accept_details",description=("The type of state transition detail. Used to ensure pydantic does not"" coerce into a different type."),)
Details associated with a REJECT state transition.
Source code in src/prefect/client/schemas/responses.py
46474849505152535455565758
classStateRejectDetails(PrefectBaseModel):"""Details associated with a REJECT state transition."""type:Literal["reject_details"]=Field(default="reject_details",description=("The type of state transition detail. Used to ensure pydantic does not"" coerce into a different type."),)reason:Optional[str]=Field(default=None,description="The reason why the state transition was rejected.")
Details associated with an ABORT state transition.
Source code in src/prefect/client/schemas/responses.py
61626364656667686970717273
classStateAbortDetails(PrefectBaseModel):"""Details associated with an ABORT state transition."""type:Literal["abort_details"]=Field(default="abort_details",description=("The type of state transition detail. Used to ensure pydantic does not"" coerce into a different type."),)reason:Optional[str]=Field(default=None,description="The reason why the state transition was aborted.")
Source code in src/prefect/client/schemas/responses.py
7677787980818283848586878889909192939495
classStateWaitDetails(PrefectBaseModel):"""Details associated with a WAIT state transition."""type:Literal["wait_details"]=Field(default="wait_details",description=("The type of state transition detail. Used to ensure pydantic does not"" coerce into a different type."),)delay_seconds:int=Field(default=...,description=("The length of time in seconds the client should wait before transitioning"" states."),)reason:Optional[str]=Field(default=None,description="The reason why the state transition should wait.")
classHistoryResponseState(PrefectBaseModel):"""Represents a single state's history over an interval."""state_type:objects.StateType=Field(default=...,description="The state type.")state_name:str=Field(default=...,description="The state name.")count_runs:int=Field(default=...,description="The number of runs in the specified state during the interval.",)sum_estimated_run_time:datetime.timedelta=Field(default=...,description="The total estimated run time of all runs during the interval.",)sum_estimated_lateness:datetime.timedelta=Field(default=...,description=("The sum of differences between actual and expected start time during the"" interval."),)
Represents a history of aggregation states over an interval
Source code in src/prefect/client/schemas/responses.py
120121122123124125126127128129130131
classHistoryResponse(PrefectBaseModel):"""Represents a history of aggregation states over an interval"""interval_start:DateTimeTZ=Field(default=...,description="The start date of the interval.")interval_end:DateTimeTZ=Field(default=...,description="The end date of the interval.")states:List[HistoryResponseState]=Field(default=...,description="A list of state histories during the interval.")
A container for the output of state orchestration.
Source code in src/prefect/client/schemas/responses.py
139140141142143144145146
classOrchestrationResult(PrefectBaseModel):""" A container for the output of state orchestration. """state:Optional[objects.State]status:SetStateStatusdetails:StateResponseDetails
classFlowRunResponse(ObjectBaseModel):name:str=Field(default_factory=lambda:generate_slug(2),description=("The name of the flow run. Defaults to a random slug if not specified."),examples=["my-flow-run"],)flow_id:UUID=Field(default=...,description="The id of the flow being run.")state_id:Optional[UUID]=Field(default=None,description="The id of the flow run's current state.")deployment_id:Optional[UUID]=Field(default=None,description=("The id of the deployment associated with this flow run, if available."),)deployment_version:Optional[str]=Field(default=None,description="The version of the deployment associated with this flow run.",examples=["1.0"],)work_queue_name:Optional[str]=Field(default=None,description="The work queue that handled this flow run.")flow_version:Optional[str]=Field(default=None,description="The version of the flow executed in this flow run.",examples=["1.0"],)parameters:Dict[str,Any]=Field(default_factory=dict,description="Parameters for the flow run.")idempotency_key:Optional[str]=Field(default=None,description=("An optional idempotency key for the flow run. Used to ensure the same flow"" run is not created multiple times."),)context:Dict[str,Any]=Field(default_factory=dict,description="Additional context for the flow run.",examples=[{"my_var":"my_val"}],)empirical_policy:objects.FlowRunPolicy=Field(default_factory=objects.FlowRunPolicy,)tags:List[str]=Field(default_factory=list,description="A list of tags on the flow run",examples=[["tag-1","tag-2"]],)parent_task_run_id:Optional[UUID]=Field(default=None,description=("If the flow run is a subflow, the id of the 'dummy' task in the parent"" flow used to track subflow state."),)run_count:int=Field(default=0,description="The number of times the flow run was executed.")expected_start_time:Optional[DateTimeTZ]=Field(default=None,description="The flow run's expected start time.",)next_scheduled_start_time:Optional[DateTimeTZ]=Field(default=None,description="The next time the flow run is scheduled to start.",)start_time:Optional[DateTimeTZ]=Field(default=None,description="The actual start time.")end_time:Optional[DateTimeTZ]=Field(default=None,description="The actual end time.")total_run_time:datetime.timedelta=Field(default=datetime.timedelta(0),description=("Total run time. If the flow run was executed multiple times, the time of"" each run will be summed."),)estimated_run_time:datetime.timedelta=Field(default=datetime.timedelta(0),description="A real-time estimate of the total run time.",)estimated_start_time_delta:datetime.timedelta=Field(default=datetime.timedelta(0),description="The difference between actual and expected start time.",)auto_scheduled:bool=Field(default=False,description="Whether or not the flow run was automatically scheduled.",)infrastructure_document_id:Optional[UUID]=Field(default=None,description="The block document defining infrastructure to use this flow run.",)infrastructure_pid:Optional[str]=Field(default=None,description="The id of the flow run as returned by an infrastructure block.",)created_by:Optional[CreatedBy]=Field(default=None,description="Optional information about the creator of this flow run.",)work_queue_id:Optional[UUID]=Field(default=None,description="The id of the run's work pool queue.")work_pool_id:Optional[UUID]=Field(description="The work pool with which the queue is associated.")work_pool_name:Optional[str]=Field(default=None,description="The name of the flow run's work pool.",examples=["my-work-pool"],)state:Optional[objects.State]=Field(default=None,description="The state of the flow run.",examples=[objects.State(type=objects.StateType.COMPLETED)],)job_variables:Optional[dict]=Field(default=None,description="Job variables for the flow run.")# These are server-side optimizations and should not be present on client models# TODO: Deprecate these fieldsstate_type:Optional[objects.StateType]=Field(default=None,description="The type of the current flow run state.")state_name:Optional[str]=Field(default=None,description="The name of the current flow run state.")def__eq__(self,other:Any)->bool:""" Check for "equality" to another flow run schema Estimates times are rolling and will always change with repeated queries for a flow run so we ignore them during equality checks. """ifisinstance(other,objects.FlowRun):exclude_fields={"estimated_run_time","estimated_start_time_delta"}returnself.dict(exclude=exclude_fields)==other.dict(exclude=exclude_fields)returnsuper().__eq__(other)
classGlobalConcurrencyLimitResponse(ObjectBaseModel):""" A response object for global concurrency limits. """active:bool=Field(default=True,description="Whether the global concurrency limit is active.")name:str=Field(default=...,description="The name of the global concurrency limit.")limit:int=Field(default=...,description="The concurrency limit.")active_slots:int=Field(default=...,description="The number of active slots.")slot_decay_per_second:float=Field(default=2.0,description="The decay rate for active slots when used as a rate limit.",)
A schedule formed by adding interval increments to an anchor_date. If no
anchor_date is supplied, the current UTC time is used. If a
timezone-naive datetime is provided for anchor_date, it is assumed to be
in the schedule's timezone (or UTC). Even if supplied with an IANA timezone,
anchor dates are always stored as UTC offsets, so a timezone can be
provided to determine localization behaviors like DST boundary handling. If
none is provided it will be inferred from the anchor date.
NOTE: If the IntervalScheduleanchor_date or timezone is provided in a
DST-observing timezone, then the schedule will adjust itself appropriately.
Intervals greater than 24 hours will follow DST conventions, while intervals
of less than 24 hours will follow UTC intervals. For example, an hourly
schedule will fire every UTC hour, even across DST boundaries. When clocks
are set back, this will result in two runs that appear to both be
scheduled for 1am local time, even though they are an hour apart in UTC
time. For longer intervals, like a daily schedule, the interval schedule
will adjust for DST boundaries so that the clock-hour remains constant. This
means that a daily schedule that always fires at 9am will observe DST and
continue to fire at 9am in the local time zone.
Parameters:
Name
Type
Description
Default
interval
timedelta
an interval to schedule on
required
anchor_date
DateTimeTZ
an anchor date to schedule increments against;
if not provided, the current timestamp will be used
required
timezone
str
a valid timezone string
required
Source code in src/prefect/client/schemas/schedules.py
classIntervalSchedule(PrefectBaseModel):""" A schedule formed by adding `interval` increments to an `anchor_date`. If no `anchor_date` is supplied, the current UTC time is used. If a timezone-naive datetime is provided for `anchor_date`, it is assumed to be in the schedule's timezone (or UTC). Even if supplied with an IANA timezone, anchor dates are always stored as UTC offsets, so a `timezone` can be provided to determine localization behaviors like DST boundary handling. If none is provided it will be inferred from the anchor date. NOTE: If the `IntervalSchedule` `anchor_date` or `timezone` is provided in a DST-observing timezone, then the schedule will adjust itself appropriately. Intervals greater than 24 hours will follow DST conventions, while intervals of less than 24 hours will follow UTC intervals. For example, an hourly schedule will fire every UTC hour, even across DST boundaries. When clocks are set back, this will result in two runs that *appear* to both be scheduled for 1am local time, even though they are an hour apart in UTC time. For longer intervals, like a daily schedule, the interval schedule will adjust for DST boundaries so that the clock-hour remains constant. This means that a daily schedule that always fires at 9am will observe DST and continue to fire at 9am in the local time zone. Args: interval (datetime.timedelta): an interval to schedule on anchor_date (DateTimeTZ, optional): an anchor date to schedule increments against; if not provided, the current timestamp will be used timezone (str, optional): a valid timezone string """classConfig:extra="forbid"exclude_none=Trueinterval:PositiveDurationanchor_date:Optional[DateTimeTZ]=Nonetimezone:Optional[str]=Field(default=None,examples=["America/New_York"])@validator("anchor_date",always=True)defvalidate_anchor_date(cls,v):returndefault_anchor_date(v)@validator("timezone",always=True)defvalidate_default_timezone(cls,v,values):returndefault_timezone(v,values=values)
NOTE: If the timezone is a DST-observing one, then the schedule will adjust
itself appropriately. Cron's rules for DST are based on schedule times, not
intervals. This means that an hourly cron schedule will fire on every new
schedule hour, not every elapsed hour; for example, when clocks are set back
this will result in a two-hour pause as the schedule will fire the first
time 1am is reached and the first time 2am is reached, 120 minutes later.
Longer schedules, such as one that fires at 9am every morning, will
automatically adjust for DST.
Parameters:
Name
Type
Description
Default
cron
str
a valid cron string
required
timezone
str
a valid timezone string in IANA tzdata format (for example,
America/New_York).
required
day_or
bool
Control how croniter handles day and day_of_week
entries. Defaults to True, matching cron which connects those values using
OR. If the switch is set to False, the values are connected using AND. This
behaves like fcron and enables you to e.g. define a job that executes each
2nd friday of a month by setting the days of month and the weekday.
required
Source code in src/prefect/client/schemas/schedules.py
classCronSchedule(PrefectBaseModel):""" Cron schedule NOTE: If the timezone is a DST-observing one, then the schedule will adjust itself appropriately. Cron's rules for DST are based on schedule times, not intervals. This means that an hourly cron schedule will fire on every new schedule hour, not every elapsed hour; for example, when clocks are set back this will result in a two-hour pause as the schedule will fire *the first time* 1am is reached and *the first time* 2am is reached, 120 minutes later. Longer schedules, such as one that fires at 9am every morning, will automatically adjust for DST. Args: cron (str): a valid cron string timezone (str): a valid timezone string in IANA tzdata format (for example, America/New_York). day_or (bool, optional): Control how croniter handles `day` and `day_of_week` entries. Defaults to True, matching cron which connects those values using OR. If the switch is set to False, the values are connected using AND. This behaves like fcron and enables you to e.g. define a job that executes each 2nd friday of a month by setting the days of month and the weekday. """classConfig:extra="forbid"cron:str=Field(default=...,examples=["0 0 * * *"])timezone:Optional[str]=Field(default=None,examples=["America/New_York"])day_or:bool=Field(default=True,description=("Control croniter behavior for handling day and day_of_week entries."),)@validator("timezone")defvalid_timezone(cls,v):returndefault_timezone(v)@validator("cron")defvalid_cron_string(cls,v):returnvalidate_cron_string(v)
RRule schedule, based on the iCalendar standard
(RFC 5545) as
implemented in dateutils.rrule.
RRules are appropriate for any kind of calendar-date manipulation, including
irregular intervals, repetition, exclusions, week day or day-of-month
adjustments, and more.
Note that as a calendar-oriented standard, RRuleSchedules are sensitive to
to the initial timezone provided. A 9am daily schedule with a daylight saving
time-aware start date will maintain a local 9am time through DST boundaries;
a 9am daily schedule with a UTC start date will maintain a 9am UTC time.
Parameters:
Name
Type
Description
Default
rrule
str
a valid RRule string
required
timezone
str
a valid timezone string
required
Source code in src/prefect/client/schemas/schedules.py
classRRuleSchedule(PrefectBaseModel):""" RRule schedule, based on the iCalendar standard ([RFC 5545](https://datatracker.ietf.org/doc/html/rfc5545)) as implemented in `dateutils.rrule`. RRules are appropriate for any kind of calendar-date manipulation, including irregular intervals, repetition, exclusions, week day or day-of-month adjustments, and more. Note that as a calendar-oriented standard, `RRuleSchedules` are sensitive to to the initial timezone provided. A 9am daily schedule with a daylight saving time-aware start date will maintain a local 9am time through DST boundaries; a 9am daily schedule with a UTC start date will maintain a 9am UTC time. Args: rrule (str): a valid RRule string timezone (str, optional): a valid timezone string """classConfig:extra="forbid"rrule:strtimezone:Optional[str]=Field(default=None,examples=["America/New_York"])@validator("rrule")defvalidate_rrule_str(cls,v):returnvalidate_rrule_string(v)@classmethoddeffrom_rrule(cls,rrule:dateutil.rrule.rrule):ifisinstance(rrule,dateutil.rrule.rrule):ifrrule._dtstart.tzinfoisnotNone:timezone=rrule._dtstart.tzinfo.nameelse:timezone="UTC"returnRRuleSchedule(rrule=str(rrule),timezone=timezone)elifisinstance(rrule,dateutil.rrule.rruleset):dtstarts=[rr._dtstartforrrinrrule._rruleifrr._dtstartisnotNone]unique_dstarts=set(pendulum.instance(d).in_tz("UTC")fordindtstarts)unique_timezones=set(d.tzinfofordindtstartsifd.tzinfoisnotNone)iflen(unique_timezones)>1:raiseValueError(f"rruleset has too many dtstart timezones: {unique_timezones}")iflen(unique_dstarts)>1:raiseValueError(f"rruleset has too many dtstarts: {unique_dstarts}")ifunique_dstartsandunique_timezones:timezone=dtstarts[0].tzinfo.nameelse:timezone="UTC"rruleset_string=""ifrrule._rrule:rruleset_string+="\n".join(str(r)forrinrrule._rrule)ifrrule._exrule:rruleset_string+="\n"ifrruleset_stringelse""rruleset_string+="\n".join(str(r)forrinrrule._exrule).replace("RRULE","EXRULE")ifrrule._rdate:rruleset_string+="\n"ifrruleset_stringelse""rruleset_string+="RDATE:"+",".join(rd.strftime("%Y%m%dT%H%M%SZ")forrdinrrule._rdate)ifrrule._exdate:rruleset_string+="\n"ifrruleset_stringelse""rruleset_string+="EXDATE:"+",".join(exd.strftime("%Y%m%dT%H%M%SZ")forexdinrrule._exdate)returnRRuleSchedule(rrule=rruleset_string,timezone=timezone)else:raiseValueError(f"Invalid RRule object: {rrule}")defto_rrule(self)->dateutil.rrule.rrule:""" Since rrule doesn't properly serialize/deserialize timezones, we localize dates here """rrule=dateutil.rrule.rrulestr(self.rrule,dtstart=DEFAULT_ANCHOR_DATE,cache=True,)timezone=dateutil.tz.gettz(self.timezone)ifisinstance(rrule,dateutil.rrule.rrule):kwargs=dict(dtstart=rrule._dtstart.replace(tzinfo=timezone))ifrrule._until:kwargs.update(until=rrule._until.replace(tzinfo=timezone),)returnrrule.replace(**kwargs)elifisinstance(rrule,dateutil.rrule.rruleset):# update rruleslocalized_rrules=[]forrrinrrule._rrule:kwargs=dict(dtstart=rr._dtstart.replace(tzinfo=timezone))ifrr._until:kwargs.update(until=rr._until.replace(tzinfo=timezone),)localized_rrules.append(rr.replace(**kwargs))rrule._rrule=localized_rrules# update exruleslocalized_exrules=[]forexrinrrule._exrule:kwargs=dict(dtstart=exr._dtstart.replace(tzinfo=timezone))ifexr._until:kwargs.update(until=exr._until.replace(tzinfo=timezone),)localized_exrules.append(exr.replace(**kwargs))rrule._exrule=localized_exrules# update rdateslocalized_rdates=[]forrdinrrule._rdate:localized_rdates.append(rd.replace(tzinfo=timezone))rrule._rdate=localized_rdates# update exdateslocalized_exdates=[]forexdinrrule._exdate:localized_exdates.append(exd.replace(tzinfo=timezone))rrule._exdate=localized_exdatesreturnrrule@validator("timezone",always=True)defvalid_timezone(cls,v):returnvalidate_rrule_timezone(v)
defconstruct_schedule(interval:Optional[Union[int,float,datetime.timedelta]]=None,anchor_date:Optional[Union[datetime.datetime,str]]=None,cron:Optional[str]=None,rrule:Optional[str]=None,timezone:Optional[str]=None,)->SCHEDULE_TYPES:""" Construct a schedule from the provided arguments. Args: interval: An interval on which to schedule runs. Accepts either a number or a timedelta object. If a number is given, it will be interpreted as seconds. anchor_date: The start date for an interval schedule. cron: A cron schedule for runs. rrule: An rrule schedule of when to execute runs of this flow. timezone: A timezone to use for the schedule. Defaults to UTC. """num_schedules=sum(1forentryin(interval,cron,rrule)ifentryisnotNone)ifnum_schedules>1:raiseValueError("Only one of interval, cron, or rrule can be provided.")ifanchor_dateandnotinterval:raiseValueError("An anchor date can only be provided with an interval schedule")iftimezoneandnot(intervalorcronorrrule):raiseValueError("A timezone can only be provided with interval, cron, or rrule")schedule=Noneifinterval:ifisinstance(interval,(int,float)):interval=datetime.timedelta(seconds=interval)schedule=IntervalSchedule(interval=interval,anchor_date=anchor_date,timezone=timezone)elifcron:schedule=CronSchedule(cron=cron,timezone=timezone)elifrrule:schedule=RRuleSchedule(rrule=rrule,timezone=timezone)ifscheduleisNone:raiseValueError("Either interval, cron, or rrule must be provided")returnschedule
Source code in src/prefect/client/schemas/sorting.py
4 5 6 7 8 9101112131415
classFlowRunSort(AutoEnum):"""Defines flow run sorting options."""ID_DESC=AutoEnum.auto()START_TIME_ASC=AutoEnum.auto()START_TIME_DESC=AutoEnum.auto()EXPECTED_START_TIME_ASC=AutoEnum.auto()EXPECTED_START_TIME_DESC=AutoEnum.auto()NAME_ASC=AutoEnum.auto()NAME_DESC=AutoEnum.auto()NEXT_SCHEDULED_START_TIME_ASC=AutoEnum.auto()END_TIME_DESC=AutoEnum.auto()
Source code in src/prefect/client/schemas/sorting.py
18192021222324252627
classTaskRunSort(AutoEnum):"""Defines task run sorting options."""ID_DESC=AutoEnum.auto()EXPECTED_START_TIME_ASC=AutoEnum.auto()EXPECTED_START_TIME_DESC=AutoEnum.auto()NAME_ASC=AutoEnum.auto()NAME_DESC=AutoEnum.auto()NEXT_SCHEDULED_START_TIME_ASC=AutoEnum.auto()END_TIME_DESC=AutoEnum.auto()