prefect.server.utilities.schemas.bases
Functions
get_class_fields_only
Classes
PrefectDescriptorBase
A base class for descriptor objects used with PrefectBaseModel
Pydantic needs to be told about any kind of non-standard descriptor
objects used on a model, in order for these not to be treated as a field
type instead.
This base class is registered as an ignored type with PrefectBaseModel
and any classes that inherit from it will also be ignored. This allows
such descriptors to be used as properties, methods or other bound
descriptor use cases.
PrefectBaseModel
A base pydantic.BaseModel for all Prefect schemas and pydantic models.
As the basis for most Prefect schemas, this base model ignores extra
fields that are passed to it at instantiation. Because adding new fields to
API payloads is not considered a breaking change, this ensures that any
Prefect client loading data from a server running a possibly-newer version
of Prefect will be able to process those new fields gracefully.
Methods:
model_dump_for_orm
BaseModel.model_dump
. Generate a Python dictionary
representation of the model suitable for passing to SQLAlchemy model
constructors, INSERT
statements, etc. The critical difference here is that
this method will return any nested BaseModel objects as BaseModel
instances,
rather than serialized Python dictionaries.
Accepts the standard Pydantic model_dump
arguments, except for mode
(which
is always “python”), round_trip
, and warnings
.
Usage docs: https://docs.pydantic.dev/2.6/concepts/serialization/#modelmodel_dump
Args:
include
: A list of fields to include in the output.exclude
: A list of fields to exclude from the output.by_alias
: Whether to use the field’s alias in the dictionary key if defined.exclude_unset
: Whether to exclude fields that have not been explicitly set.exclude_defaults
: Whether to exclude fields that are set to their default value.exclude_none
: Whether to exclude fields that have a value ofNone
.
- A dictionary representation of the model, suitable for passing
- to SQLAlchemy model constructors, INSERT statements, etc.
reset_fields
_reset_fields
set.
Returns:
- A new instance of the model with the reset fields.
IDBaseModel
A PrefectBaseModel with an auto-generated UUID ID value.
The ID is reset on copy() and not included in equality comparisons.
Methods:
model_validate_list
reset_fields
_reset_fields
set.
Returns:
- A new instance of the model with the reset fields.
TimeSeriesBaseModel
A PrefectBaseModel with a time-oriented UUIDv7 ID value. Used for models that
operate like timeseries, such as runs, states, and logs.
ORMBaseModel
A PrefectBaseModel with an auto-generated UUID ID value and created /
updated timestamps, intended for compatibility with our standard ORM models.
The ID, created, and updated fields are reset on copy() and not included in
equality comparisons.
ActionBaseModel
Methods:
model_validate_list
reset_fields
_reset_fields
set.
Returns:
- A new instance of the model with the reset fields.