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: DBConfig, dataset_store: DatasetStoreConfig, dp_libraries: DPLibraryConfig)[source]
Bases:
BaseModel
Server runtime config.
- dataset_store: DatasetStoreConfig
- 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=DBConfig, required=True), 'dataset_store': FieldInfo(annotation=DatasetStoreConfig, required=True), 'develop_mode': FieldInfo(annotation=bool, required=True), 'dp_libraries': FieldInfo(annotation=DPLibraryConfig, required=True), '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.
- 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.
- 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.
- class lomas_server.utils.config.DBConfig(*, db_type: str = <enum 'AdminDBType'>)[source]
Bases:
BaseModel
BaseModel for database type config
- db_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]] = {'db_type': FieldInfo(annotation=str, required=False, default=<enum 'AdminDBType'>)}
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.DatasetStoreConfig(*, ds_store_type: DatasetStoreType)[source]
Bases:
BaseModel
BaseModel for dataset store configs
- ds_store_type: DatasetStoreType
- 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]] = {'ds_store_type': FieldInfo(annotation=DatasetStoreType, 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.LRUDatasetStoreConfig(*, ds_store_type: DatasetStoreType, max_memory_usage: int)[source]
Bases:
DatasetStoreConfig
BaseModel for dataset store configs in case of a LRU dataset store
- max_memory_usage: 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]] = {'ds_store_type': FieldInfo(annotation=DatasetStoreType, required=True), 'max_memory_usage': 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.config.MongoDBConfig(*, db_type: str = <enum 'AdminDBType'>, 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
- 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=str, required=False, default=<enum 'AdminDBType'>), '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.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: str = <enum 'AdminDBType'>, db_file: str)[source]
Bases:
DBConfig
BaseModel for dataset store configs in case of a Yaml database
- db_file: 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]] = {'db_file': FieldInfo(annotation=str, required=True), 'db_type': FieldInfo(annotation=str, required=False, default=<enum 'AdminDBType'>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.