docs/v3/api-ref/python/prefect-server-schemas-states.mdx
prefect.server.schemas.statesState schemas.
Scheduled <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L315" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Scheduled(scheduled_time: Optional[DateTime] = None, cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Scheduled states.
Returns:
Completed <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L337" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Completed(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Completed states.
Returns:
Running <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L346" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Running(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Running states.
Returns:
Failed <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L355" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Failed(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Failed states.
Returns:
Crashed <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L364" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Crashed(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Crashed states.
Returns:
Cancelling <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L373" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Cancelling(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Cancelling states.
Returns:
Cancelled <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L382" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Cancelled(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Cancelled states.
Returns:
Pending <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L391" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Pending(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Pending states.
Returns:
Paused <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L400" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Paused(cls: type[_State] = State, timeout_seconds: Optional[int] = None, pause_expiration_time: Optional[DateTime] = None, reschedule: bool = False, pause_key: Optional[str] = None, **kwargs: Any) -> _State
Convenience function for creating Paused states.
Returns:
Suspended <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L434" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Suspended(cls: type[_State] = State, timeout_seconds: Optional[int] = None, pause_expiration_time: Optional[DateTime] = None, pause_key: Optional[str] = None, **kwargs: Any) -> _State
Convenience function for creating Suspended states.
Returns:
AwaitingRetry <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L457" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>AwaitingRetry(cls: type[_State] = State, scheduled_time: Optional[DateTime] = None, **kwargs: Any) -> _State
Convenience function for creating AwaitingRetry states.
Returns:
AwaitingConcurrencySlot <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L472" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>AwaitingConcurrencySlot(cls: type[_State] = State, scheduled_time: Optional[DateTime] = None, **kwargs: Any) -> _State
Convenience function for creating AwaitingConcurrencySlot states.
Returns:
Submitting <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L490" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Submitting(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Submitting states.
Returns:
InfrastructurePending <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L499" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>InfrastructurePending(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating InfrastructurePending states.
Returns:
Retrying <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L508" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Retrying(cls: type[_State] = State, **kwargs: Any) -> _State
Convenience function for creating Retrying states.
Returns:
Late <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L517" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Late(cls: type[_State] = State, scheduled_time: Optional[DateTime] = None, **kwargs: Any) -> _State
Convenience function for creating Late states.
Returns:
StateType <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L40" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Enumeration of state types.
Methods:
auto <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/utilities/collections.py#L70" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>auto() -> str
Exposes enum.auto() to avoid requiring a second import to use AutoEnum
CountByState <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L54" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
check_key <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L67" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>check_key(cls, value: Optional[Any], info: ValidationInfo) -> Optional[Any]
model_validate_list <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/_internal/schemas/bases.py#L56" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_validate_list(cls, obj: Any) -> list[Self]
reset_fields <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/_internal/schemas/bases.py#L85" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>reset_fields(self: Self) -> Self
Reset the fields of the model that are in the _reset_fields set.
Returns:
StateDetails <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L81" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
model_validate_list <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/_internal/schemas/bases.py#L56" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_validate_list(cls, obj: Any) -> list[Self]
reset_fields <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/_internal/schemas/bases.py#L85" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>reset_fields(self: Self) -> Self
Reset the fields of the model that are in the _reset_fields set.
Returns:
StateBaseModel <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
orm_dict <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L107" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>orm_dict(self, *args: Any, **kwargs: Any) -> dict[str, Any]
This method is used as a convenience method for constructing fixtues by first
building a State schema object and converting it into an ORM-compatible
format. Because the data field is not writable on ORM states, this method
omits the data field entirely for the purposes of constructing an ORM model.
If state data is required, an artifact must be created separately.
State <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L122" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Represents the state of a run.
Methods:
default_name_from_type <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L167" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>default_name_from_type(self) -> Self
If a name is not provided, use the type
default_scheduled_start_time <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L177" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>default_scheduled_start_time(self) -> Self
fresh_copy <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L216" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>fresh_copy(self, **kwargs: Any) -> Self
Return a fresh copy of the state with a new ID.
from_orm_without_result <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L141" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>from_orm_without_result(cls, orm_state: Union['ORMFlowRunState', 'ORMTaskRunState'], with_data: Optional[Any] = None) -> Self
During orchestration, ORM states can be instantiated prior to inserting results
into the artifact table and the data field will not be eagerly loaded. In
these cases, sqlalchemy will attempt to lazily load the the relationship, which
will fail when called within a synchronous pydantic method.
This method will construct a State object from an ORM model without a loaded
artifact and attach data passed using the with_data argument to the data
field.
is_cancelled <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L204" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_cancelled(self) -> bool
is_cancelling <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L207" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_cancelling(self) -> bool
is_completed <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L195" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_completed(self) -> bool
is_crashed <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L201" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_crashed(self) -> bool
is_failed <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L198" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_failed(self) -> bool
is_final <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L210" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_final(self) -> bool
is_paused <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L213" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_paused(self) -> bool
is_pending <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L189" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_pending(self) -> bool
is_running <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L192" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_running(self) -> bool
is_scheduled <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L186" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_scheduled(self) -> bool
orm_dict <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L107" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>orm_dict(self, *args: Any, **kwargs: Any) -> dict[str, Any]
This method is used as a convenience method for constructing fixtues by first
building a State schema object and converting it into an ORM-compatible
format. Because the data field is not writable on ORM states, this method
omits the data field entirely for the purposes of constructing an ORM model.
If state data is required, an artifact must be created separately.
result <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L232" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>result(self, raise_on_failure: Literal[True] = ...) -> Any
result <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L235" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>result(self, raise_on_failure: Literal[False] = False) -> Union[Any, Exception]
result <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L240" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>result(self, raise_on_failure: bool = ...) -> Union[Any, Exception]
result <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L242" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>result(self, raise_on_failure: bool = True) -> Union[Any, Exception]
to_state_create <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/schemas/states.py#L259" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>to_state_create(self) -> 'StateCreate'