akkudoktoreos.core.pydantic

Module for managing and serializing Pydantic-based models with custom support.

This module provides classes that extend Pydantic’s functionality to include robust handling of pendulum.DateTime fields, offering seamless serialization and deserialization into ISO 8601 format. These enhancements facilitate the use of Pydantic models in applications requiring timezone-aware datetime fields and consistent data serialization.

Key Features: - Custom type adapter for pendulum.DateTime fields with automatic serialization to ISO 8601 strings. - Utility methods for converting models to and from dictionaries and JSON strings. - Validation tools for maintaining data consistency, including specialized support for

pandas DataFrames and Series with datetime indexes.

Functions

del_private_attr(model, key)

Delete a private attribute.

get_private_attr(model, key[, default])

Get a private attribute or return default.

merge_models(source, update_dict)

Merge a Pydantic model instance with an update dictionary.

set_private_attr(model, key, value)

Set a private attribute for a model instance (not stored in model itself).

Classes

PydanticBaseModel()

Base model with pendulum datetime support, nested value utilities, and stable hashing.

PydanticDateTimeData([root])

Pydantic model for time series data with consistent value lengths.

PydanticDateTimeDataFrame(*, data, ...)

Pydantic model for validating pandas DataFrame data with datetime index.

PydanticDateTimeSeries(*, data[, dtype, tz])

Pydantic model for validating pandas Series with datetime index in JSON format.

PydanticModelNestedValueMixin()

A mixin providing methods to get, set and track nested values within a Pydantic model.