lomas_server.utils package

Submodules

lomas_server.utils.anti_timing_att module

async lomas_server.utils.anti_timing_att.anti_timing_att(request: Request, call_next: Callable, config: Config) Response[source]

Anti-timing attack mechanism.

Changes the response time to either a minimum or by adding random noïse in order to avoid timing attacks.

Parameters:
  • request (Request) – The FastApi request.

  • call_next (Callable) – The FastApi endpoint to call.

  • config (Config) – The server config.

Returns:

The reponse from call_next.

Return type:

Response

lomas_server.utils.collection_models module

class lomas_server.utils.collection_models.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['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['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['boolean']
class lomas_server.utils.collection_models.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_server.utils.collection_models.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_server.utils.collection_models.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_server.utils.collection_models.Dataset(*, dataset_name: str, metadata: MetadataOfPathDB | MetadataOfS3DB)[source]

Bases: BaseModel

BaseModel for a dataset

dataset_name: str
metadata: MetadataOfPathDB | MetadataOfS3DB
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': FieldInfo(annotation=Union[MetadataOfPathDB, MetadataOfS3DB], 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_server.utils.collection_models.DatasetOfPathDB(*, dataset_name: str, metadata: MetadataOfPathDB | MetadataOfS3DB, database_type: Literal[PrivateDatabaseType.PATH], dataset_path: str)[source]

Bases: Dataset

BaseModel for a local dataset

database_type: Literal[PrivateDatabaseType.PATH]
dataset_path: 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=Literal[<PrivateDatabaseType.PATH: 'PATH_DB'>], required=True), 'dataset_name': FieldInfo(annotation=str, required=True), 'dataset_path': FieldInfo(annotation=str, required=True), 'metadata': FieldInfo(annotation=Union[MetadataOfPathDB, MetadataOfS3DB], 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_server.utils.collection_models.DatasetOfS3DB(*, dataset_name: str, metadata: MetadataOfPathDB | MetadataOfS3DB, database_type: Literal[PrivateDatabaseType.S3], endpoint_url: str, bucket: str, key: str, credentials_name: str)[source]

Bases: Dataset

BaseModel for a dataset on S3

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]] = {'bucket': FieldInfo(annotation=str, required=True), 'credentials_name': FieldInfo(annotation=str, required=True), 'database_type': FieldInfo(annotation=Literal[<PrivateDatabaseType.S3: 'S3_DB'>], required=True), 'dataset_name': FieldInfo(annotation=str, required=True), 'endpoint_url': FieldInfo(annotation=str, required=True), 'key': FieldInfo(annotation=str, required=True), 'metadata': FieldInfo(annotation=Union[MetadataOfPathDB, MetadataOfS3DB], 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_server.utils.collection_models.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_server.utils.collection_models.DatasetsCollection(*, datasets: List[DatasetOfPathDB | DatasetOfS3DB])[source]

Bases: BaseModel

BaseModel for datasets collection

datasets: Annotated[List[DatasetOfPathDB | DatasetOfS3DB], 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]] = {'datasets': FieldInfo(annotation=List[Union[DatasetOfPathDB, DatasetOfS3DB]], 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_server.utils.collection_models.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['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['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['datetime']
upper: datetime
class lomas_server.utils.collection_models.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['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['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['float']
upper: float
class lomas_server.utils.collection_models.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['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['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['int']
class lomas_server.utils.collection_models.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['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['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['int']
upper: int
class lomas_server.utils.collection_models.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_server.utils.collection_models.MetadataOfDataset[source]

Bases: BaseModel

BaseModel for metadata of a 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]] = {}

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_server.utils.collection_models.MetadataOfPathDB(*, database_type: Literal[PrivateDatabaseType.PATH], metadata_path: str)[source]

Bases: MetadataOfDataset

BaseModel for metadata of a dataset with PATH_DB

database_type: Literal[PrivateDatabaseType.PATH]
metadata_path: 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=Literal[<PrivateDatabaseType.PATH: 'PATH_DB'>], required=True), 'metadata_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.

class lomas_server.utils.collection_models.MetadataOfS3DB(*, 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: MetadataOfDataset

BaseModel for metadata of a dataset with S3_DB

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_server.utils.collection_models.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_server.utils.collection_models.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['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['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['string']
class lomas_server.utils.collection_models.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['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['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['string']
class lomas_server.utils.collection_models.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_server.utils.collection_models.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_server.utils.collection_models.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_server.utils.config module

class lomas_server.utils.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: MongoDBConfig | YamlDBConfig
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_server.utils.config.ConfigLoader[source]

Bases: object

Singleton object that holds the config for the server.

Initialises the config by calling load_config() with its default arguments.

The config can be reloaded by calling load_config with other arguments.

get_config() Config[source]

Get the config.

Returns:

The config.

Return type:

Config

load_config(config_path: str = '/usr/lomas_server/runtime.yaml', secrets_path: str = '/usr/lomas_server/secrets.yaml') None[source]

Loads the config and the secret data from disk, merges them and returns the config object.

Parameters:
  • config_path (str, optional) – The config filepath. Defaults to CONFIG_PATH.

  • secrets_path (str, optional) – The secrets filepath. Defaults to SECRETS_PATH.

Raises:

InternalServerException – If the config cannot be correctly interpreted.

set_config(config: Config) None[source]

Set the singleton’s config to config.

Parameters:

config (Config) – The new config.

class lomas_server.utils.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_server.utils.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_server.utils.config.MongoDBConfig(*, db_type: Literal[AdminDBType.MONGODB], address: str, port: int, username: str, password: str, db_name: str)[source]

Bases: DBConfig

BaseModel for dataset store configs in case of a MongoDB database

address: str
db_name: str
db_type: Literal[AdminDBType.MONGODB]
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), '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_server.utils.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_server.utils.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_server.utils.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_server.utils.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_server.utils.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_server.utils.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_server.utils.config.get_config() Config[source]

Get the config from the ConfigLoader Singleton instance.

Returns:

The config.

Return type:

Config

lomas_server.utils.error_handler module

exception lomas_server.utils.error_handler.ExternalLibraryException(library: str, error_message: str)[source]

Bases: Exception

Custom exception for issues within external libraries

This exception will occur when the processes fail within the external libraries (smartnoise-sql, opendp, diffprivlib)

exception lomas_server.utils.error_handler.InternalServerException(error_message: str)[source]

Bases: Exception

Custom exception for issues within server internal functionalities like unexpected match cases

exception lomas_server.utils.error_handler.InvalidQueryException(error_message: str)[source]

Bases: Exception

Custom exception for invalid queries

For example, this exception will occur when the query:
  • is not an opendp measurement

  • cannot be reconstructed properly (for opendp and diffprivlib)

exception lomas_server.utils.error_handler.UnauthorizedAccessException(error_message: str)[source]

Bases: Exception

Custom exception for unauthorized access: (unknown user, no access to dataset, etc)

lomas_server.utils.error_handler.add_exception_handlers(app: FastAPI) None[source]

Translates custom exceptions to JSONResponses. :param app: A fastapi App. :type app: FastAPI

lomas_server.utils.logger module

lomas_server.utils.query_examples module

lomas_server.utils.query_examples.make_dummy(example_query)[source]

Make dummy example dummy query based on example query

lomas_server.utils.query_models module

class lomas_server.utils.query_models.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_server.utils.query_models.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_server.utils.query_models.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: RequestModel

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_server.utils.query_models.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_server.utils.query_models.GetDbData(*, dataset_name: str)[source]

Bases: BaseModel

Model input to get information about a dataset

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_server.utils.query_models.GetDummyDataset(*, dataset_name: str, dummy_nb_rows: Annotated[int, Gt(gt=0)], dummy_seed: int)[source]

Bases: BaseModel

Model input to get a dummy dataset

dataset_name: str
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_server.utils.query_models.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] = {}

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)}

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_server.utils.query_models.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] = {}

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)}

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_server.utils.query_models.OpenDPRequestModel(*, dataset_name: str, opendp_json: str, fixed_delta: float | None = None)[source]

Bases: RequestModel

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] = {}

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)}

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
class lomas_server.utils.query_models.QueryModel(*, dataset_name: str)[source]

Bases: RequestModel

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_server.utils.query_models.RequestModel(*, dataset_name: str)[source]

Bases: BaseModel

Base input model for any request 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).

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_server.utils.query_models.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_server.utils.query_models.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_server.utils.query_models.SmartnoiseSQLRequestModel(*, dataset_name: str, query_str: str, epsilon: Annotated[float, Gt(gt=0)], delta: Annotated[float, Gt(gt=0)], mechanisms: dict)[source]

Bases: RequestModel

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_server.utils.query_models.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_server.utils.query_models.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_server.utils.query_models.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: RequestModel

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_server.utils.query_models.model_input_to_lib(request: RequestModel) DPLibraries[source]

Return the type of DP library given a RequestModel.

Parameters:

request (RequestModel) – The user request

Raises:

InternalServerException – If the library type cannot be determined.

Returns:

The type of library for the request.

Return type:

DPLibraries

Module contents