nannyml.io.db.entities module
Contains the definitions of the database entities that map directly to the underlying table definitions.
Every Result class has a matching Entity class, which implies that each calculator or estimator will export
its results into a specific table.
- class nannyml.io.db.entities.CBPEPerformanceMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float], lower_threshold: Optional[float])[source]
Bases:
MetricRepresents results of the
CBPEestimator.Stored in the
cbpe_performance_metricstable.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'lower_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'upper_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.DLEPerformanceMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float], lower_threshold: Optional[float])[source]
Bases:
MetricRepresents results of the
DLE estimator.Stored in the
dle_performance_metricstable.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'lower_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'upper_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.DataReconstructionFeatureDriftMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float], lower_threshold: Optional[float])[source]
Bases:
MetricDataReconstructionDriftCalculatorresults.Stored in the
data_reconstruction_feature_drift_metricstable.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'lower_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'upper_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.Metric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool)[source]
Bases:
SQLModelBase
Metricdefinition.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: Optional[int]
The technical identifier for this database row
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'registry': PydanticUndefined}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- value: float
The value returned by the method
- class nannyml.io.db.entities.MissingValuesMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool, column_name: str, upper_threshold: Optional[float], lower_threshold: Optional[float])[source]
Bases:
MetricCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- column_name: str
The name of the column this metric belongs to
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'column_name': FieldInfo(annotation=str, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'lower_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'upper_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.Model(*, id: Optional[int] = None, name: str)[source]
Bases:
SQLModelRepresents a
Model.Only created when the
model_nameproperty of theDatabaseWriterwas given. Theidfield here will act as a foreign key in theruntable and allmetrictables.Stored in the
modeltable.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: Optional[int]
A technical key that is used as a foreign key in the other tables
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'name': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- name: str
Optional model name that might be useful in visualizations e.g. in Grafana dashboards
- class nannyml.io.db.entities.RealizedPerformanceMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float], lower_threshold: Optional[float])[source]
Bases:
MetricRepresents results of the
PerformanceCalculator.Stored in the
realized_performance_metricstable.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'lower_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'upper_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.Run(*, id: Optional[int] = None, model_id: Optional[int] = None, execution_timestamp: datetime = datetime.datetime(2024, 7, 19, 21, 20, 25, 688896))[source]
Bases:
SQLModelRepresents a NannyML run, allowing to filter results based on what run generated them.
The
idfield here will act as a foreign key in allmetrictables.Stored in the
runtable.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- execution_timestamp: datetime
Execution time of NannyML run
- id: Optional[int]
Foreign key in all
metrictables
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'execution_timestamp': FieldInfo(annotation=datetime, required=False, default=datetime.datetime(2024, 7, 19, 21, 20, 25, 688896)), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Used to link a run to a model
- class nannyml.io.db.entities.UnivariateDriftMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool, column_name: str)[source]
Bases:
MetricRepresents results of the
UnivariateDriftCalculator.Stored in the
univariate_drift_metricstable.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- column_name: str
The name of the column this metric belongs to
- id: Optional[int]
The technical identifier for this database row
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'column_name': FieldInfo(annotation=str, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- value: float
The value returned by the method
- class nannyml.io.db.entities.UnseenValuesMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime, end_timestamp: datetime, timestamp: datetime, metric_name: str, value: float, alert: bool, column_name: str, upper_threshold: Optional[float], lower_threshold: Optional[float])[source]
Bases:
MetricCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- column_name: str
The name of the column this metric belongs to
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannonorchi2
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'protected_namespaces': (), 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'alert': FieldInfo(annotation=bool, required=True), 'column_name': FieldInfo(annotation=str, required=True), 'end_timestamp': FieldInfo(annotation=datetime, required=True), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'lower_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'metric_name': FieldInfo(annotation=str, required=True), 'model_id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'run_id': FieldInfo(annotation=int, required=False, default=None), 'start_timestamp': FieldInfo(annotation=datetime, required=True), 'timestamp': FieldInfo(annotation=datetime, required=True), 'upper_threshold': FieldInfo(annotation=Union[float, NoneType], required=True), 'value': FieldInfo(annotation=float, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- model_id: Optional[int]
Foreign key pointing to a record in the
modeltable
- run_id: int
Foreign key pointing to a record in the
runtable
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method