lomas_server.utils package

Submodules

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.query_examples module

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

Make dummy example dummy query based on example query

Module contents