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: ColumnMetadata

Model for boolean column metadata.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'private_id': FieldInfo(annotation=bool, required=False, default=False), 'type': FieldInfo(annotation=Literal[<MetadataColumnType.BOOLEAN: 'boolean'>], 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.

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: ColumnMetadata

Model for columns with bounded data.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'private_id': FieldInfo(annotation=bool, required=False, default=False)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

validate_bounds()[source]

Validates column bounds.

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: ColumnMetadata

Model for categorical column metadata.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'private_id': FieldInfo(annotation=bool, required=False, default=False)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

validate_categories()[source]

Makes sure number of categories matches cardinality.

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: BaseModel

Base 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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'private_id': FieldInfo(annotation=bool, required=False, default=False)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

nullable: bool
private_id: bool
class lomas_core.models.collections.DSAccess(*, database_type: str)[source]

Bases: BaseModel

BaseModel for access info to a private dataset.

database_type: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'database_type': 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.

class lomas_core.models.collections.DSInfo(*, dataset_name: str, dataset_access: DSPathAccess | DSS3Access, metadata_access: DSPathAccess | DSS3Access)[source]

Bases: BaseModel

BaseModel 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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_access': FieldInfo(annotation=Union[DSPathAccess, DSS3Access], required=True, discriminator='database_type'), 'dataset_name': FieldInfo(annotation=str, required=True), 'metadata_access': FieldInfo(annotation=Union[DSPathAccess, DSS3Access], required=True, discriminator='database_type')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class lomas_core.models.collections.DSPathAccess(*, database_type: Literal[PrivateDatabaseType.PATH], path: str)[source]

Bases: DSAccess

BaseModel for a local dataset.

database_type: Literal[PrivateDatabaseType.PATH]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'database_type': FieldInfo(annotation=Literal[<PrivateDatabaseType.PATH: 'PATH_DB'>], required=True), 'path': 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.

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: DSAccess

BaseModel 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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'access_key_id': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'bucket': FieldInfo(annotation=str, required=True), 'credentials_name': FieldInfo(annotation=str, required=True), 'database_type': FieldInfo(annotation=Literal[<PrivateDatabaseType.S3: 'S3_DB'>], required=True), 'endpoint_url': FieldInfo(annotation=str, required=True), 'key': FieldInfo(annotation=str, required=True), 'secret_access_key': FieldInfo(annotation=Union[str, 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.

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: BaseModel

BaseModel for informations of a user on a dataset.

dataset_name: str
initial_delta: float
initial_epsilon: float
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'initial_delta': FieldInfo(annotation=float, required=True), 'initial_epsilon': FieldInfo(annotation=float, required=True), 'total_spent_delta': FieldInfo(annotation=float, required=True), 'total_spent_epsilon': 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.

total_spent_delta: float
total_spent_epsilon: float
class lomas_core.models.collections.DatasetsCollection(*, datasets: List[DSInfo])[source]

Bases: BaseModel

BaseModel for datasets collection.

datasets: List[DSInfo]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'datasets': FieldInfo(annotation=List[DSInfo], 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.

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: BoundedColumnMetadata

Model for datetime column metadata.

lower: datetime
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'lower': FieldInfo(annotation=datetime, required=True), 'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'private_id': FieldInfo(annotation=bool, required=False, default=False), 'type': FieldInfo(annotation=Literal[<MetadataColumnType.DATETIME: 'datetime'>], required=True), 'upper': FieldInfo(annotation=datetime, 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.

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: BoundedColumnMetadata

Model for float column metadata.

lower: float
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'lower': FieldInfo(annotation=float, required=True), 'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'precision': FieldInfo(annotation=Precision, required=True), 'private_id': FieldInfo(annotation=bool, required=False, default=False), 'type': FieldInfo(annotation=Literal[<MetadataColumnType.FLOAT: 'float'>], required=True), 'upper': 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.

precision: Precision
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: CategoricalColumnMetadata

Model for integer categorical column metadata.

cardinality: int
categories: List[int]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'cardinality': FieldInfo(annotation=int, required=True), 'categories': FieldInfo(annotation=List[int], required=True), 'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'precision': FieldInfo(annotation=Precision, required=True), 'private_id': FieldInfo(annotation=bool, required=False, default=False), 'type': FieldInfo(annotation=Literal[<MetadataColumnType.INT: 'int'>], 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.

precision: Precision
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: BoundedColumnMetadata

Model for integer column metadata.

lower: int
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'lower': FieldInfo(annotation=int, required=True), 'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'precision': FieldInfo(annotation=Precision, required=True), 'private_id': FieldInfo(annotation=bool, required=False, default=False), 'type': FieldInfo(annotation=Literal[<MetadataColumnType.INT: 'int'>], required=True), 'upper': FieldInfo(annotation=int, 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.

precision: Precision
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: BaseModel

BaseModel 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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'censor_dims': FieldInfo(annotation=Union[bool, NoneType], required=False, default=False), 'columns': FieldInfo(annotation=Dict[str, Annotated[Union[Annotated[StrMetadata, Tag], Annotated[StrCategoricalMetadata, Tag], Annotated[IntMetadata, Tag], Annotated[IntCategoricalMetadata, Tag], Annotated[FloatMetadata, Tag], Annotated[BooleanMetadata, Tag], Annotated[DatetimeMetadata, Tag]], Discriminator]], required=True), 'max_ids': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)]), 'row_privacy': FieldInfo(annotation=bool, required=True), 'rows': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

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: CategoricalColumnMetadata

Model for categorical string metadata.

cardinality: int
categories: List[str]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'cardinality': FieldInfo(annotation=int, required=True), 'categories': FieldInfo(annotation=List[str], required=True), 'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'private_id': FieldInfo(annotation=bool, required=False, default=False), 'type': FieldInfo(annotation=Literal[<MetadataColumnType.STRING: 'string'>], 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.

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: ColumnMetadata

Model for string metadata.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'max_influenced_partitions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_contributions': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'max_partition_length': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])], NoneType], required=False, default=None), 'nullable': FieldInfo(annotation=bool, required=False, default=False), 'private_id': FieldInfo(annotation=bool, required=False, default=False), 'type': FieldInfo(annotation=Literal[<MetadataColumnType.STRING: 'string'>], 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.

type: Literal[MetadataColumnType.STRING]
class lomas_core.models.collections.User(*, user_name: str, may_query: bool, datasets_list: List[DatasetOfUser])[source]

Bases: BaseModel

BaseModel for a user in a user collection.

datasets_list: List[DatasetOfUser]
may_query: bool
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'datasets_list': FieldInfo(annotation=List[DatasetOfUser], required=True), 'may_query': FieldInfo(annotation=bool, required=True), 'user_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.

user_name: str
class lomas_core.models.collections.UserCollection(*, users: List[User])[source]

Bases: BaseModel

BaseModel for users collection.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'users': FieldInfo(annotation=List[User], 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.

users: List[User]
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

class lomas_core.models.config.Config(*, develop_mode: bool, server: Server, submit_limit: float, admin_database: MongoDBConfig | YamlDBConfig, private_db_credentials: List[S3CredentialsConfig], dp_libraries: DPLibraryConfig)[source]

Bases: BaseModel

Server runtime config.

admin_database: Annotated[MongoDBConfig | YamlDBConfig, FieldInfo(annotation=NoneType, required=True, discriminator='db_type')]
develop_mode: bool
dp_libraries: DPLibraryConfig
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'admin_database': FieldInfo(annotation=Union[MongoDBConfig, YamlDBConfig], required=True, discriminator='db_type'), 'develop_mode': FieldInfo(annotation=bool, required=True), 'dp_libraries': FieldInfo(annotation=DPLibraryConfig, required=True), 'private_db_credentials': FieldInfo(annotation=List[S3CredentialsConfig], required=True, discriminator='db_type'), 'server': FieldInfo(annotation=Server, required=True), 'submit_limit': 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.

private_db_credentials: List[S3CredentialsConfig]
server: Server
submit_limit: float
class lomas_core.models.config.DBConfig[source]

Bases: BaseModel

BaseModel for database type config.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class lomas_core.models.config.DPLibraryConfig(*, opendp: OpenDPConfig)[source]

Bases: BaseModel

BaseModel for DP librairies config.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'opendp': FieldInfo(annotation=OpenDPConfig, 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.

opendp: OpenDPConfig
class lomas_core.models.config.MongoDBConfig(*, db_type: Literal[AdminDBType.MONGODB], address: str, port: int, username: str, password: str, db_name: str, max_pool_size: int, min_pool_size: int, max_connecting: int)[source]

Bases: DBConfig

BaseModel for dataset store configs in case of a MongoDB database.

address: str
db_name: str
db_type: Literal[AdminDBType.MONGODB]
max_connecting: int
max_pool_size: int
min_pool_size: int
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'address': FieldInfo(annotation=str, required=True), 'db_name': FieldInfo(annotation=str, required=True), 'db_type': FieldInfo(annotation=Literal[<AdminDBType.MONGODB: 'mongodb'>], required=True), 'max_connecting': FieldInfo(annotation=int, required=True), 'max_pool_size': FieldInfo(annotation=int, required=True), 'min_pool_size': FieldInfo(annotation=int, required=True), 'password': FieldInfo(annotation=str, required=True), 'port': FieldInfo(annotation=int, required=True), 'username': 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.

password: str
port: int
username: str
class lomas_core.models.config.OpenDPConfig(*, contrib: bool, floating_point: bool, honest_but_curious: bool)[source]

Bases: BaseModel

BaseModel for openDP librairy config.

contrib: bool
floating_point: bool
honest_but_curious: bool
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'contrib': FieldInfo(annotation=bool, required=True), 'floating_point': FieldInfo(annotation=bool, required=True), 'honest_but_curious': FieldInfo(annotation=bool, 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.

class lomas_core.models.config.PrivateDBCredentials[source]

Bases: BaseModel

BaseModel for private database credentials.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class lomas_core.models.config.S3CredentialsConfig(*, db_type: Literal[PrivateDatabaseType.S3], credentials_name: str, access_key_id: str, secret_access_key: str, **extra_data: Any)[source]

Bases: PrivateDBCredentials

BaseModel for S3 database credentials.

access_key_id: str
credentials_name: str
db_type: Literal[PrivateDatabaseType.S3]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'access_key_id': FieldInfo(annotation=str, required=True), 'credentials_name': FieldInfo(annotation=str, required=True), 'db_type': FieldInfo(annotation=Literal[<PrivateDatabaseType.S3: 'S3_DB'>], required=True), 'secret_access_key': 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.

secret_access_key: str
class lomas_core.models.config.Server(*, time_attack: TimeAttack, host_ip: str, host_port: int, log_level: str, reload: bool, workers: int)[source]

Bases: BaseModel

BaseModel for uvicorn server configs.

host_ip: str
host_port: int
log_level: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'host_ip': FieldInfo(annotation=str, required=True), 'host_port': FieldInfo(annotation=int, required=True), 'log_level': FieldInfo(annotation=str, required=True), 'reload': FieldInfo(annotation=bool, required=True), 'time_attack': FieldInfo(annotation=TimeAttack, required=True), 'workers': FieldInfo(annotation=int, 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.

reload: bool
time_attack: TimeAttack
workers: int
class lomas_core.models.config.TimeAttack(*, method: TimeAttackMethod, magnitude: float)[source]

Bases: BaseModel

BaseModel for configs to prevent timing attacks.

magnitude: float
method: TimeAttackMethod
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'magnitude': FieldInfo(annotation=float, required=True), 'method': FieldInfo(annotation=TimeAttackMethod, 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.

class lomas_core.models.config.YamlDBConfig(*, db_type: Literal[AdminDBType.YAML], db_file: str)[source]

Bases: DBConfig

BaseModel for dataset store configs in case of a Yaml database.

db_file: str
db_type: Literal[AdminDBType.YAML]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'db_file': FieldInfo(annotation=str, required=True), 'db_type': FieldInfo(annotation=Literal[<AdminDBType.YAML: 'yaml'>], 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.

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: StrEnum

Types of administration databases.

MONGODB: str = 'mongodb'
YAML: str = 'yaml'
class lomas_core.models.constants.ConfigKeys(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Keys of the configuration file.

RUNTIME_ARGS: str = 'runtime_args'
SETTINGS: str = 'settings'
class lomas_core.models.constants.MetadataColumnType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Column 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: IntEnum

Precision of integer and float data.

DOUBLE = 64
SINGLE = 32
class lomas_core.models.constants.PrivateDatabaseType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Type of Private Database for the private data.

PATH = 'PATH_DB'
S3 = 'S3_DB'
class lomas_core.models.constants.TimeAttackMethod(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Possible methods against timing attacks.

JITTER = 'jitter'
STALL = 'stall'

lomas_core.models.requests module

class lomas_core.models.requests.DiffPrivLibDummyQueryModel(*, dataset_name: str, dummy_nb_rows: Annotated[int, Gt(gt=0)], dummy_seed: int, diffprivlib_json: str, feature_columns: list, target_columns: list | None, test_size: Annotated[float, Gt(gt=0.0), Lt(lt=1.0)], test_train_split_seed: int, imputer_strategy: str)[source]

Bases: DiffPrivLibQueryModel, DummyQueryModel

Input model for a DiffPrivLib query on a dummy dataset.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'diffprivlib_json': FieldInfo(annotation=str, required=True), 'dummy_nb_rows': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)]), 'dummy_seed': FieldInfo(annotation=int, required=True), 'feature_columns': FieldInfo(annotation=list, required=True), 'imputer_strategy': FieldInfo(annotation=str, required=True), 'target_columns': FieldInfo(annotation=Union[list, NoneType], required=True), 'test_size': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0.0), Lt(lt=1.0)]), 'test_train_split_seed': FieldInfo(annotation=int, 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.

class lomas_core.models.requests.DiffPrivLibQueryModel(*, dataset_name: str, diffprivlib_json: str, feature_columns: list, target_columns: list | None, test_size: Annotated[float, Gt(gt=0.0), Lt(lt=1.0)], test_train_split_seed: int, imputer_strategy: str)[source]

Bases: DiffPrivLibRequestModel, QueryModel

Base input model for a diffprivlib query.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'diffprivlib_json': FieldInfo(annotation=str, required=True), 'feature_columns': FieldInfo(annotation=list, required=True), 'imputer_strategy': FieldInfo(annotation=str, required=True), 'target_columns': FieldInfo(annotation=Union[list, NoneType], required=True), 'test_size': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0.0), Lt(lt=1.0)]), 'test_train_split_seed': FieldInfo(annotation=int, 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.

class lomas_core.models.requests.DiffPrivLibRequestModel(*, dataset_name: str, diffprivlib_json: str, feature_columns: list, target_columns: list | None, test_size: Annotated[float, Gt(gt=0.0), Lt(lt=1.0)], test_train_split_seed: int, imputer_strategy: str)[source]

Bases: LomasRequestModel

Base input model for a diffprivlib request.

diffprivlib_json: str
feature_columns: list
imputer_strategy: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'diffprivlib_json': FieldInfo(annotation=str, required=True), 'feature_columns': FieldInfo(annotation=list, required=True), 'imputer_strategy': FieldInfo(annotation=str, required=True), 'target_columns': FieldInfo(annotation=Union[list, NoneType], required=True), 'test_size': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0.0), Lt(lt=1.0)]), 'test_train_split_seed': FieldInfo(annotation=int, 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.

target_columns: list | None
test_size: float
test_train_split_seed: int
class lomas_core.models.requests.DummyQueryModel(*, dataset_name: str, dummy_nb_rows: Annotated[int, Gt(gt=0)], dummy_seed: int)[source]

Bases: QueryModel

Input model for a query on a dummy dataset.

dummy_nb_rows: int
dummy_seed: int
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'dummy_nb_rows': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)]), 'dummy_seed': FieldInfo(annotation=int, 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.

class lomas_core.models.requests.GetDummyDataset(*, dataset_name: str, dummy_nb_rows: Annotated[int, Gt(gt=0)], dummy_seed: int)[source]

Bases: LomasRequestModel

Model input to get a dummy dataset.

dummy_nb_rows: int
dummy_seed: int
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'dummy_nb_rows': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)]), 'dummy_seed': FieldInfo(annotation=int, 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.

class lomas_core.models.requests.LomasRequestModel(*, dataset_name: str)[source]

Bases: BaseModel

Base class for all types of requests to the lomas server.

We differentiate between requests and queries:
  • a request does not necessarily require an algorithm to be executed on the private dataset (e.g. some cost requests).

  • a query requires executing an algorithm on a private dataset (or a potentially a dummy).

dataset_name: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_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.

class lomas_core.models.requests.OpenDPDummyQueryModel(*, dataset_name: str, dummy_nb_rows: Annotated[int, Gt(gt=0)], dummy_seed: int, opendp_json: str, fixed_delta: float | None = None)[source]

Bases: OpenDPRequestModel, DummyQueryModel

Input model for an opendp query on a dummy dataset.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'dummy_nb_rows': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)]), 'dummy_seed': FieldInfo(annotation=int, required=True), 'fixed_delta': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'opendp_json': FieldInfo(annotation=str, required=True, description='Opendp pipeline.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class lomas_core.models.requests.OpenDPQueryModel(*, dataset_name: str, opendp_json: str, fixed_delta: float | None = None)[source]

Bases: OpenDPRequestModel, QueryModel

Base input model for an opendp query.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'fixed_delta': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'opendp_json': FieldInfo(annotation=str, required=True, description='Opendp pipeline.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class lomas_core.models.requests.OpenDPRequestModel(*, dataset_name: str, opendp_json: str, fixed_delta: float | None = None)[source]

Bases: LomasRequestModel

Base input model for an opendp request.

fixed_delta: float | None
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'fixed_delta': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'opendp_json': FieldInfo(annotation=str, required=True, description='Opendp pipeline.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

opendp_json: str

Opendp pipeline.

class lomas_core.models.requests.QueryModel(*, dataset_name: str)[source]

Bases: LomasRequestModel

Base input model for any query on a dataset.

We differentiate between requests and queries:
  • a request does not necessarily require an algorithm to be executed on the private dataset (e.g. some cost requests).

  • a query requires executing an algorithm on a private dataset (or a potentially a dummy).

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_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.

class lomas_core.models.requests.SmartnoiseSQLDummyQueryModel(*, dataset_name: str, dummy_nb_rows: Annotated[int, Gt(gt=0)], dummy_seed: int, query_str: str, epsilon: Annotated[float, Gt(gt=0)], delta: Annotated[float, Gt(gt=0)], mechanisms: dict, postprocess: bool)[source]

Bases: SmartnoiseSQLQueryModel, DummyQueryModel

Input model for a smartnoise-sql query on a dummy dataset.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'delta': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'dummy_nb_rows': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)]), 'dummy_seed': FieldInfo(annotation=int, required=True), 'epsilon': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'mechanisms': FieldInfo(annotation=dict, required=True), 'postprocess': FieldInfo(annotation=bool, required=True), 'query_str': 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.

class lomas_core.models.requests.SmartnoiseSQLQueryModel(*, dataset_name: str, query_str: str, epsilon: Annotated[float, Gt(gt=0)], delta: Annotated[float, Gt(gt=0)], mechanisms: dict, postprocess: bool)[source]

Bases: SmartnoiseSQLRequestModel, QueryModel

Base input model for a smartnoise-sql query.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'delta': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'epsilon': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'mechanisms': FieldInfo(annotation=dict, required=True), 'postprocess': FieldInfo(annotation=bool, required=True), 'query_str': 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.

postprocess: bool
class lomas_core.models.requests.SmartnoiseSQLRequestModel(*, dataset_name: str, query_str: str, epsilon: Annotated[float, Gt(gt=0)], delta: Annotated[float, Gt(gt=0)], mechanisms: dict)[source]

Bases: LomasRequestModel

Base input model for a smarnoise-sql request.

delta: float
epsilon: float
mechanisms: dict
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dataset_name': FieldInfo(annotation=str, required=True), 'delta': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'epsilon': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'mechanisms': FieldInfo(annotation=dict, required=True), 'query_str': 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.

query_str: str
class lomas_core.models.requests.SmartnoiseSynthDummyQueryModel(*, dataset_name: str, dummy_nb_rows: Annotated[int, Gt(gt=0)], dummy_seed: int, synth_name: SSynthMarginalSynthesizer | SSynthGanSynthesizer, epsilon: Annotated[float, Gt(gt=0)], delta: float | None = None, select_cols: List, synth_params: dict, nullable: bool, constraints: str, return_model: bool, condition: str, nb_samples: int)[source]

Bases: SmartnoiseSynthQueryModel, DummyQueryModel

Input model for a smarnoise-synth query on a dummy dataset.

condition: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'condition': FieldInfo(annotation=str, required=True), 'constraints': FieldInfo(annotation=str, required=True), 'dataset_name': FieldInfo(annotation=str, required=True), 'delta': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'dummy_nb_rows': FieldInfo(annotation=int, required=True, metadata=[Gt(gt=0)]), 'dummy_seed': FieldInfo(annotation=int, required=True), 'epsilon': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'nb_samples': FieldInfo(annotation=int, required=True), 'nullable': FieldInfo(annotation=bool, required=True), 'return_model': FieldInfo(annotation=bool, required=True), 'select_cols': FieldInfo(annotation=List, required=True), 'synth_name': FieldInfo(annotation=Union[SSynthMarginalSynthesizer, SSynthGanSynthesizer], required=True), 'synth_params': FieldInfo(annotation=dict, 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.

nb_samples: int
return_model: bool
class lomas_core.models.requests.SmartnoiseSynthQueryModel(*, dataset_name: str, synth_name: SSynthMarginalSynthesizer | SSynthGanSynthesizer, epsilon: Annotated[float, Gt(gt=0)], delta: float | None = None, select_cols: List, synth_params: dict, nullable: bool, constraints: str, return_model: bool, condition: str, nb_samples: int)[source]

Bases: SmartnoiseSynthRequestModel, QueryModel

Base input model for a smarnoise-synth query.

condition: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'condition': FieldInfo(annotation=str, required=True), 'constraints': FieldInfo(annotation=str, required=True), 'dataset_name': FieldInfo(annotation=str, required=True), 'delta': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'epsilon': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'nb_samples': FieldInfo(annotation=int, required=True), 'nullable': FieldInfo(annotation=bool, required=True), 'return_model': FieldInfo(annotation=bool, required=True), 'select_cols': FieldInfo(annotation=List, required=True), 'synth_name': FieldInfo(annotation=Union[SSynthMarginalSynthesizer, SSynthGanSynthesizer], required=True), 'synth_params': FieldInfo(annotation=dict, 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.

nb_samples: int
return_model: bool
class lomas_core.models.requests.SmartnoiseSynthRequestModel(*, dataset_name: str, synth_name: SSynthMarginalSynthesizer | SSynthGanSynthesizer, epsilon: Annotated[float, Gt(gt=0)], delta: float | None = None, select_cols: List, synth_params: dict, nullable: bool, constraints: str)[source]

Bases: LomasRequestModel

Base input model for a SmartnoiseSynth request.

constraints: str
delta: float | None
epsilon: float
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'constraints': FieldInfo(annotation=str, required=True), 'dataset_name': FieldInfo(annotation=str, required=True), 'delta': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'epsilon': FieldInfo(annotation=float, required=True, metadata=[Gt(gt=0)]), 'nullable': FieldInfo(annotation=bool, required=True), 'select_cols': FieldInfo(annotation=List, required=True), 'synth_name': FieldInfo(annotation=Union[SSynthMarginalSynthesizer, SSynthGanSynthesizer], required=True), 'synth_params': FieldInfo(annotation=dict, 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.

nullable: bool
select_cols: List
synth_name: SSynthMarginalSynthesizer | SSynthGanSynthesizer
synth_params: dict
lomas_core.models.requests.model_input_to_lib(request: LomasRequestModel) DPLibraries[source]

Return the type of DP library given a LomasRequestModel.

Parameters:

request (LomasRequestModel) – The user request

Raises:

InternalServerException – If the library type cannot be determined.

Returns:

The type of library for the request.

Return type:

DPLibraries

lomas_core.models.responses module

class lomas_core.models.responses.CostResponse(*, epsilon: float, delta: float)[source]

Bases: ResponseModel

Model for responses to cost estimation requests.

delta: float
epsilon: float
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'delta': FieldInfo(annotation=float, required=True), 'epsilon': 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.

class lomas_core.models.responses.DiffPrivLibQueryResult(*, res_type: Literal[DPLibraries.DIFFPRIVLIB] = DPLibraries.DIFFPRIVLIB, score: float, model: Annotated[DiffprivlibMixin, PlainSerializer(func=serialize_model, return_type=PydanticUndefined, when_used=always), PlainValidator(func=deserialize_model)])[source]

Bases: BaseModel

Model for diffprivlib query result.

model: Annotated[DiffprivlibMixin, PlainSerializer(func=serialize_model, return_type=PydanticUndefined, when_used=always), PlainValidator(func=deserialize_model)]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'model': FieldInfo(annotation=DiffprivlibMixin, required=True, metadata=[PlainSerializer(func=<function serialize_model>, return_type=PydanticUndefined, when_used='always'), PlainValidator(func=<function deserialize_model>)]), 'res_type': FieldInfo(annotation=Literal[<DPLibraries.DIFFPRIVLIB: 'diffprivlib'>], required=False, default=<DPLibraries.DIFFPRIVLIB: 'diffprivlib'>), 'score': 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.

res_type: Literal[DPLibraries.DIFFPRIVLIB]
score: float
class lomas_core.models.responses.DummyDsResponse(*, dtypes: Dict[str, str], datetime_columns: List[str], dummy_df: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always)])[source]

Bases: ResponseModel

Model for responses to dummy dataset requests.

datetime_columns: List[str]
classmethod deserialize_dummy_df(v: DataFrame | dict, info: ValidationInfo) DataFrame[source]

Decodes the dict representation of the dummy df with correct types.

Only does so if the input value is not already a dataframe. :param v: The dataframe to decode. :type v: pd.DataFrame | dict :param info: Validation info to access other model fields. :type info: ValidationInfo

Returns:

The decoded dataframe.

Return type:

pd.DataFrame

dtypes: Dict[str, str]
dummy_df: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always)]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'datetime_columns': FieldInfo(annotation=List[str], required=True), 'dtypes': FieldInfo(annotation=Dict[str, str], required=True), 'dummy_df': FieldInfo(annotation=DataFrame, required=True, metadata=[PlainSerializer(func=<function dataframe_to_dict>, return_type=PydanticUndefined, when_used='always')])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class lomas_core.models.responses.InitialBudgetResponse(*, initial_epsilon: float, initial_delta: float)[source]

Bases: ResponseModel

Model for responses to initial budget queries.

initial_delta: float
initial_epsilon: float
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'initial_delta': FieldInfo(annotation=float, required=True), 'initial_epsilon': 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.

class lomas_core.models.responses.OpenDPQueryResult(*, res_type: Literal[DPLibraries.OPENDP] = DPLibraries.OPENDP, value: int | float | List[int | float])[source]

Bases: BaseModel

Type for opendp result.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'res_type': FieldInfo(annotation=Literal[<DPLibraries.OPENDP: 'opendp'>], required=False, default=<DPLibraries.OPENDP: 'opendp'>), 'value': FieldInfo(annotation=Union[int, float, List[Union[int, 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.

res_type: Literal[DPLibraries.OPENDP]
value: int | float | List[int | float]
class lomas_core.models.responses.QueryResponse(*, epsilon: float, delta: float, requested_by: str, result: Annotated[DiffPrivLibQueryResult | SmartnoiseSQLQueryResult | SmartnoiseSynthModel | SmartnoiseSynthSamples | OpenDPQueryResult, Discriminator(discriminator=res_type, custom_error_type=None, custom_error_message=None, custom_error_context=None)])[source]

Bases: CostResponse

Model for responses to queries.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'delta': FieldInfo(annotation=float, required=True), 'epsilon': FieldInfo(annotation=float, required=True), 'requested_by': FieldInfo(annotation=str, required=True), 'result': FieldInfo(annotation=Union[DiffPrivLibQueryResult, SmartnoiseSQLQueryResult, SmartnoiseSynthModel, SmartnoiseSynthSamples, OpenDPQueryResult], required=True, metadata=[Discriminator(discriminator='res_type', custom_error_type=None, custom_error_message=None, custom_error_context=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.

requested_by: str
result: Annotated[DiffPrivLibQueryResult | SmartnoiseSQLQueryResult | SmartnoiseSynthModel | SmartnoiseSynthSamples | OpenDPQueryResult, Discriminator(discriminator=res_type, custom_error_type=None, custom_error_message=None, custom_error_context=None)]
class lomas_core.models.responses.RemainingBudgetResponse(*, remaining_epsilon: float, remaining_delta: float)[source]

Bases: ResponseModel

Model for responses to remaining budget queries.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'remaining_delta': FieldInfo(annotation=float, required=True), 'remaining_epsilon': 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.

remaining_delta: float
remaining_epsilon: float
class lomas_core.models.responses.ResponseModel[source]

Bases: BaseModel

Base model for any response from the server.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class lomas_core.models.responses.SmartnoiseSQLQueryResult(*, res_type: Literal[DPLibraries.SMARTNOISE_SQL] = DPLibraries.SMARTNOISE_SQL, df: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always), PlainValidator(func=dataframe_from_dict)])[source]

Bases: BaseModel

Type for smartnoise_sql result type.

df: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always), PlainValidator(func=dataframe_from_dict)]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'df': FieldInfo(annotation=DataFrame, required=True, metadata=[PlainSerializer(func=<function dataframe_to_dict>, return_type=PydanticUndefined, when_used='always'), PlainValidator(func=<function dataframe_from_dict>)]), 'res_type': FieldInfo(annotation=Literal[<DPLibraries.SMARTNOISE_SQL: 'smartnoise_sql'>], required=False, default=<DPLibraries.SMARTNOISE_SQL: 'smartnoise_sql'>)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

res_type: Literal[DPLibraries.SMARTNOISE_SQL]
class lomas_core.models.responses.SmartnoiseSynthModel(*, res_type: Literal[DPLibraries.SMARTNOISE_SYNTH] = DPLibraries.SMARTNOISE_SYNTH, model: Annotated[Synthesizer, PlainSerializer(func=serialize_model, return_type=PydanticUndefined, when_used=always), PlainValidator(func=deserialize_model)])[source]

Bases: BaseModel

Type for smartnoise_synth result when it is a pickled model.

model: Annotated[Synthesizer, PlainSerializer(func=serialize_model, return_type=PydanticUndefined, when_used=always), PlainValidator(func=deserialize_model)]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'model': FieldInfo(annotation=Synthesizer, required=True, metadata=[PlainSerializer(func=<function serialize_model>, return_type=PydanticUndefined, when_used='always'), PlainValidator(func=<function deserialize_model>)]), 'res_type': FieldInfo(annotation=Literal[<DPLibraries.SMARTNOISE_SYNTH: 'smartnoise_synth'>], required=False, default=<DPLibraries.SMARTNOISE_SYNTH: 'smartnoise_synth'>)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

res_type: Literal[DPLibraries.SMARTNOISE_SYNTH]
class lomas_core.models.responses.SmartnoiseSynthSamples(*, res_type: Literal['sn_synth_samples'] = 'sn_synth_samples', df_samples: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always), PlainValidator(func=dataframe_from_dict)])[source]

Bases: BaseModel

Type for smartnoise_synth result when it is a dataframe of samples.

df_samples: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always), PlainValidator(func=dataframe_from_dict)]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'df_samples': FieldInfo(annotation=DataFrame, required=True, metadata=[PlainSerializer(func=<function dataframe_to_dict>, return_type=PydanticUndefined, when_used='always'), PlainValidator(func=<function dataframe_from_dict>)]), 'res_type': FieldInfo(annotation=Literal['sn_synth_samples'], required=False, default='sn_synth_samples')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

res_type: Literal['sn_synth_samples']
class lomas_core.models.responses.SpentBudgetResponse(*, total_spent_epsilon: float, total_spent_delta: float)[source]

Bases: ResponseModel

Model for responses to spent budget queries.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'total_spent_delta': FieldInfo(annotation=float, required=True), 'total_spent_epsilon': 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.

total_spent_delta: float
total_spent_epsilon: float

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

lomas_core.models.utils.deserialize_model(serialized_model: Any) Any[source]

Deserialize a base64 encoded byte string into a python object.

Parameters:

serialized_model (Any) – Encoded python object.

Returns:

Deserialized python object.

Return type:

Any

lomas_core.models.utils.serialize_model(model: Any) str[source]

Serialise a python object into an utf-8 string.

Fitted Smartnoise Synth synthesizer or fitted DiffPrivLib pipeline.

Parameters:

model (Any) – An object to serialise

Returns:

string of serialised model

Return type:

str

Module contents