lomas_core.models package
Submodules
lomas_core.models.collections module
- class lomas_core.models.collections.BooleanMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.BOOLEAN])[source]
Bases:
ColumnMetadataModel for boolean column metadata.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.BOOLEAN]
- class lomas_core.models.collections.BoundedColumnMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None)[source]
Bases:
ColumnMetadataModel for columns with bounded data.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.CategoricalColumnMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None)[source]
Bases:
ColumnMetadataModel for categorical column metadata.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.ColumnMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None)[source]
Bases:
BaseModelBase model for column metadata.
- max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None
- max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None
- max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- nullable: bool
- private_id: bool
- class lomas_core.models.collections.DSAccess(*, database_type: str)[source]
Bases:
BaseModelBaseModel for access info to a private dataset.
- database_type: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.DSInfo(*, dataset_name: str, dataset_access: DSPathAccess | DSS3Access, metadata_access: DSPathAccess | DSS3Access)[source]
Bases:
BaseModelBaseModel for a dataset.
- dataset_access: Annotated[DSPathAccess | DSS3Access, FieldInfo(annotation=NoneType, required=True, discriminator='database_type')]
- dataset_name: str
- metadata_access: Annotated[DSPathAccess | DSS3Access, FieldInfo(annotation=NoneType, required=True, discriminator='database_type')]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.DSPathAccess(*, database_type: Literal[PrivateDatabaseType.PATH], path: str)[source]
Bases:
DSAccessBaseModel for a local dataset.
- database_type: Literal[PrivateDatabaseType.PATH]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- path: str
- class lomas_core.models.collections.DSS3Access(*, database_type: Literal[PrivateDatabaseType.S3], endpoint_url: str, bucket: str, key: str, access_key_id: str | None = None, secret_access_key: str | None = None, credentials_name: str)[source]
Bases:
DSAccessBaseModel for a dataset on S3.
- access_key_id: str | None
- bucket: str
- credentials_name: str
- database_type: Literal[PrivateDatabaseType.S3]
- endpoint_url: str
- key: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- secret_access_key: str | None
- class lomas_core.models.collections.DatasetOfUser(*, dataset_name: str, initial_epsilon: float, initial_delta: float, total_spent_epsilon: float, total_spent_delta: float)[source]
Bases:
BaseModelBaseModel for informations of a user on a dataset.
- dataset_name: str
- initial_delta: float
- initial_epsilon: float
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- total_spent_delta: float
- total_spent_epsilon: float
- class lomas_core.models.collections.DatasetsCollection(*, datasets: List[DSInfo])[source]
Bases:
BaseModelBaseModel for datasets collection.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.DatetimeMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.DATETIME], lower: datetime, upper: datetime)[source]
Bases:
BoundedColumnMetadataModel for datetime column metadata.
- lower: datetime
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.DATETIME]
- upper: datetime
- class lomas_core.models.collections.FloatMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.FLOAT], precision: Precision, lower: float, upper: float)[source]
Bases:
BoundedColumnMetadataModel for float column metadata.
- lower: float
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.FLOAT]
- upper: float
- class lomas_core.models.collections.IntCategoricalMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.INT], precision: Precision, cardinality: int, categories: List[int])[source]
Bases:
CategoricalColumnMetadataModel for integer categorical column metadata.
- cardinality: int
- categories: List[int]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.INT]
- class lomas_core.models.collections.IntMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.INT], precision: Precision, lower: int, upper: int)[source]
Bases:
BoundedColumnMetadataModel for integer column metadata.
- lower: int
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.INT]
- upper: int
- class lomas_core.models.collections.Metadata(*, max_ids: Annotated[int, Gt(gt=0)], rows: Annotated[int, Gt(gt=0)], row_privacy: bool, censor_dims: bool | None = False, columns: Dict[str, Annotated[Annotated[StrMetadata, Tag(tag=string)] | Annotated[StrCategoricalMetadata, Tag(tag=categorical_string)] | Annotated[IntMetadata, Tag(tag=int)] | Annotated[IntCategoricalMetadata, Tag(tag=categorical_int)] | Annotated[FloatMetadata, Tag(tag=float)] | Annotated[BooleanMetadata, Tag(tag=boolean)] | Annotated[DatetimeMetadata, Tag(tag=datetime)], Discriminator(discriminator=get_column_metadata_discriminator, custom_error_type=None, custom_error_message=None, custom_error_context=None)]])[source]
Bases:
BaseModelBaseModel for a metadata format.
- censor_dims: bool | None
- columns: Dict[str, Annotated[Annotated[StrMetadata, Tag(tag=string)] | Annotated[StrCategoricalMetadata, Tag(tag=categorical_string)] | Annotated[IntMetadata, Tag(tag=int)] | Annotated[IntCategoricalMetadata, Tag(tag=categorical_int)] | Annotated[FloatMetadata, Tag(tag=float)] | Annotated[BooleanMetadata, Tag(tag=boolean)] | Annotated[DatetimeMetadata, Tag(tag=datetime)], Discriminator(discriminator=get_column_metadata_discriminator, custom_error_type=None, custom_error_message=None, custom_error_context=None)]]
- max_ids: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- row_privacy: bool
- rows: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])]
- class lomas_core.models.collections.StrCategoricalMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.STRING], cardinality: int, categories: List[str])[source]
Bases:
CategoricalColumnMetadataModel for categorical string metadata.
- cardinality: int
- categories: List[str]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.STRING]
- class lomas_core.models.collections.StrMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.STRING])[source]
Bases:
ColumnMetadataModel for string metadata.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.STRING]
- class lomas_core.models.collections.User(*, user_name: str, may_query: bool, datasets_list: List[DatasetOfUser])[source]
Bases:
BaseModelBaseModel for a user in a user collection.
- datasets_list: List[DatasetOfUser]
- may_query: bool
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- user_name: str
- class lomas_core.models.collections.UserCollection(*, users: List[User])[source]
Bases:
BaseModelBaseModel for users collection.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- lomas_core.models.collections.get_column_metadata_discriminator(v: Any) str[source]
Discriminator function for determining the type of column metadata.
- Parameters:
v (Any) – The unparsed column metadata (either dict or class object)
- Raises:
ValueError – If the column type cannot be found.
- Returns:
The metadata string type.
- Return type:
str
lomas_core.models.config module
lomas_core.models.constants module
- class lomas_core.models.constants.AdminDBType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumTypes of administration databases.
- MONGODB = 'mongodb'
- YAML = 'yaml'
- class lomas_core.models.constants.ConfigKeys(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumKeys of the configuration file.
- RUNTIME_ARGS = 'runtime_args'
- SETTINGS = 'settings'
- class lomas_core.models.constants.ExceptionType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumLomas server exception types.
To be used as discriminator when parsing corresponding models
- EXTERNAL_LIBRARY = 'ExternalLibraryException'
- INTERNAL_SERVER = 'InternalServerException'
- INVALID_QUERY = 'InvalidQueryException'
- UNAUTHORIZED_ACCESS = 'UnauthorizedAccessException'
- class lomas_core.models.constants.MetadataColumnType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumColumn types for metadata.
- BOOLEAN = 'boolean'
- CAT_INT = 'categorical_int'
- CAT_STRING = 'categorical_string'
- DATETIME = 'datetime'
- FLOAT = 'float'
- INT = 'int'
- STRING = 'string'
- class lomas_core.models.constants.Precision(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnumPrecision of integer and float data.
- DOUBLE = 64
- SINGLE = 32
lomas_core.models.exceptions module
- class lomas_core.models.exceptions.ExternalLibraryExceptionModel(*, type: Literal[ExceptionType.EXTERNAL_LIBRARY] = ExceptionType.EXTERNAL_LIBRARY, library: DPLibraries, message: str)[source]
Bases:
LomasServerExceptionModelFor exceptions from libraries external to the lomas packages.
- library: DPLibraries
The external library that caused the exception.
- message: str
Exception error message.
For exceptions from libraries external to the lomas packages.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.EXTERNAL_LIBRARY]
Exception type.
- class lomas_core.models.exceptions.InternalServerExceptionModel(*, type: Literal[ExceptionType.INTERNAL_SERVER] = ExceptionType.INTERNAL_SERVER)[source]
Bases:
LomasServerExceptionModelFor any unforseen internal exception.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.INTERNAL_SERVER]
Exception type.
For any unforseen internal exception.
- class lomas_core.models.exceptions.InvalidQueryExceptionModel(*, type: Literal[ExceptionType.INVALID_QUERY] = ExceptionType.INVALID_QUERY, message: str)[source]
Bases:
LomasServerExceptionModelException directly related to the query.
For example if it does not contain a DP mechanism or there is not enough DP budget.
- message: str
Exception error message.
This is for exceptions directly related to the query. For example if it does not contain a DP mechanism or there is not enough DP budget.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.INVALID_QUERY]
Exception type.
- class lomas_core.models.exceptions.LomasServerExceptionModel(*, type: str)[source]
Bases:
BaseModelBase model for lomas server exceptions.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: str
Exception type.
- class lomas_core.models.exceptions.UnauthorizedAccessExceptionModel(*, type: Literal[ExceptionType.UNAUTHORIZED_ACCESS] = ExceptionType.UNAUTHORIZED_ACCESS, message: str)[source]
Bases:
LomasServerExceptionModelException related to rights with regards to the query.
(e.g. no user access for this dataset).
- message: str
Exception error message.
Exception related to rights with regards to the query. (e.g. no user access for this dataset).
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.UNAUTHORIZED_ACCESS]
Exception type.
lomas_core.models.requests module
lomas_core.models.requests_examples module
lomas_core.models.responses module
lomas_core.models.utils module
- lomas_core.models.utils.dataframe_from_dict(serialized_df: DataFrame | dict) DataFrame[source]
Transforms input dict into pandas dataframe.
If the input is already a dataframe, it is simply returned unmodified.
- Parameters:
serialized_df (pd.DataFrame | dict) – Dataframe in dict format. Or pd.Dataframe.
- Returns:
The transformed dataframe.
- Return type:
pd.DataFrame
- lomas_core.models.utils.dataframe_to_dict(df: DataFrame) dict[source]
Transforms pandas dataframe into a dictionary.
- Parameters:
df (pd.DataFrame) – The dataframe to “serialize”.
- Returns:
The pandas dataframe in dictionary format.
- Return type:
dict