lomas_core.models package
Submodules
lomas_core.models.collections module
- class lomas_core.models.collections.BooleanMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.BOOLEAN])[source]
Bases:
ColumnMetadataModel for boolean column metadata.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.BOOLEAN]
- class lomas_core.models.collections.BoundedColumnMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None)[source]
Bases:
ColumnMetadataModel for columns with bounded data.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.CategoricalColumnMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None)[source]
Bases:
ColumnMetadataModel for categorical column metadata.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.ColumnMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None)[source]
Bases:
BaseModelBase model for column metadata.
- max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None
- max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None
- max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- nullable: bool
- private_id: bool
- class lomas_core.models.collections.DSAccess(*, database_type: str)[source]
Bases:
BaseModelBaseModel for access info to a private dataset.
- database_type: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.DSInfo(*, dataset_name: str, dataset_access: DSPathAccess | DSS3Access, metadata_access: DSPathAccess | DSS3Access)[source]
Bases:
BaseModelBaseModel for a dataset.
- dataset_access: Annotated[DSPathAccess | DSS3Access, FieldInfo(annotation=NoneType, required=True, discriminator='database_type')]
- dataset_name: str
- metadata_access: Annotated[DSPathAccess | DSS3Access, FieldInfo(annotation=NoneType, required=True, discriminator='database_type')]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.DSPathAccess(*, database_type: Literal[PrivateDatabaseType.PATH], path: str)[source]
Bases:
DSAccessBaseModel for a local dataset.
- database_type: Literal[PrivateDatabaseType.PATH]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- path: str
- class lomas_core.models.collections.DSS3Access(*, database_type: Literal[PrivateDatabaseType.S3], endpoint_url: str, bucket: str, key: str, access_key_id: str | None = None, secret_access_key: str | None = None, credentials_name: str)[source]
Bases:
DSAccessBaseModel for a dataset on S3.
- access_key_id: str | None
- bucket: str
- credentials_name: str
- database_type: Literal[PrivateDatabaseType.S3]
- endpoint_url: str
- key: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- secret_access_key: str | None
- class lomas_core.models.collections.DatasetOfUser(*, dataset_name: str, initial_epsilon: float, initial_delta: float, total_spent_epsilon: float, total_spent_delta: float)[source]
Bases:
BaseModelBaseModel for informations of a user on a dataset.
- dataset_name: str
- initial_delta: float
- initial_epsilon: float
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- total_spent_delta: float
- total_spent_epsilon: float
- class lomas_core.models.collections.DatasetsCollection(*, datasets: List[DSInfo])[source]
Bases:
BaseModelBaseModel for datasets collection.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.collections.DatetimeMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.DATETIME], lower: datetime, upper: datetime)[source]
Bases:
BoundedColumnMetadataModel for datetime column metadata.
- lower: datetime
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.DATETIME]
- upper: datetime
- class lomas_core.models.collections.FloatMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.FLOAT], precision: Precision, lower: float, upper: float)[source]
Bases:
BoundedColumnMetadataModel for float column metadata.
- lower: float
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.FLOAT]
- upper: float
- class lomas_core.models.collections.IntCategoricalMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.INT], precision: Precision, cardinality: int, categories: List[int])[source]
Bases:
CategoricalColumnMetadataModel for integer categorical column metadata.
- cardinality: int
- categories: List[int]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.INT]
- class lomas_core.models.collections.IntMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.INT], precision: Precision, lower: int, upper: int)[source]
Bases:
BoundedColumnMetadataModel for integer column metadata.
- lower: int
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.INT]
- upper: int
- class lomas_core.models.collections.Metadata(*, max_ids: Annotated[int, Gt(gt=0)], rows: Annotated[int, Gt(gt=0)], row_privacy: bool, censor_dims: bool | None = False, columns: Dict[str, Annotated[Annotated[StrMetadata, Tag(tag=string)] | Annotated[StrCategoricalMetadata, Tag(tag=categorical_string)] | Annotated[IntMetadata, Tag(tag=int)] | Annotated[IntCategoricalMetadata, Tag(tag=categorical_int)] | Annotated[FloatMetadata, Tag(tag=float)] | Annotated[BooleanMetadata, Tag(tag=boolean)] | Annotated[DatetimeMetadata, Tag(tag=datetime)], Discriminator(discriminator=get_column_metadata_discriminator, custom_error_type=None, custom_error_message=None, custom_error_context=None)]])[source]
Bases:
BaseModelBaseModel for a metadata format.
- censor_dims: bool | None
- columns: Dict[str, Annotated[Annotated[StrMetadata, Tag(tag=string)] | Annotated[StrCategoricalMetadata, Tag(tag=categorical_string)] | Annotated[IntMetadata, Tag(tag=int)] | Annotated[IntCategoricalMetadata, Tag(tag=categorical_int)] | Annotated[FloatMetadata, Tag(tag=float)] | Annotated[BooleanMetadata, Tag(tag=boolean)] | Annotated[DatetimeMetadata, Tag(tag=datetime)], Discriminator(discriminator=get_column_metadata_discriminator, custom_error_type=None, custom_error_message=None, custom_error_context=None)]]
- max_ids: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- row_privacy: bool
- rows: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])]
- class lomas_core.models.collections.StrCategoricalMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.STRING], cardinality: int, categories: List[str])[source]
Bases:
CategoricalColumnMetadataModel for categorical string metadata.
- cardinality: int
- categories: List[str]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.STRING]
- class lomas_core.models.collections.StrMetadata(*, private_id: bool = False, nullable: bool = False, max_partition_length: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_influenced_partitions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, max_partition_contributions: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])] | None = None, type: Literal[MetadataColumnType.STRING])[source]
Bases:
ColumnMetadataModel for string metadata.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[MetadataColumnType.STRING]
- class lomas_core.models.collections.User(*, user_name: str, may_query: bool, datasets_list: List[DatasetOfUser])[source]
Bases:
BaseModelBaseModel for a user in a user collection.
- datasets_list: List[DatasetOfUser]
- may_query: bool
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- user_name: str
- class lomas_core.models.collections.UserCollection(*, users: List[User])[source]
Bases:
BaseModelBaseModel for users collection.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- lomas_core.models.collections.get_column_metadata_discriminator(v: Any) str[source]
Discriminator function for determining the type of column metadata.
- Parameters:
v (Any) – The unparsed column metadata (either dict or class object)
- Raises:
ValueError – If the column type cannot be found.
- Returns:
The metadata string type.
- Return type:
str
lomas_core.models.config module
lomas_core.models.constants module
- class lomas_core.models.constants.AdminDBType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumTypes of administration databases.
- MONGODB = 'mongodb'
- YAML = 'yaml'
- class lomas_core.models.constants.ConfigKeys(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumKeys of the configuration file.
- RUNTIME_ARGS = 'runtime_args'
- SETTINGS = 'settings'
- class lomas_core.models.constants.ExceptionType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumLomas server exception types.
To be used as discriminator when parsing corresponding models
- EXTERNAL_LIBRARY = 'ExternalLibraryException'
- INTERNAL_SERVER = 'InternalServerException'
- INVALID_QUERY = 'InvalidQueryException'
- UNAUTHORIZED_ACCESS = 'UnauthorizedAccessException'
- class lomas_core.models.constants.MetadataColumnType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnumColumn types for metadata.
- BOOLEAN = 'boolean'
- CAT_INT = 'categorical_int'
- CAT_STRING = 'categorical_string'
- DATETIME = 'datetime'
- FLOAT = 'float'
- INT = 'int'
- STRING = 'string'
- class lomas_core.models.constants.Precision(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnumPrecision of integer and float data.
- DOUBLE = 64
- SINGLE = 32
lomas_core.models.exceptions module
- class lomas_core.models.exceptions.ExternalLibraryExceptionModel(*, type: Literal[ExceptionType.EXTERNAL_LIBRARY] = ExceptionType.EXTERNAL_LIBRARY, library: DPLibraries, message: str)[source]
Bases:
LomasServerExceptionModelFor exceptions from libraries external to the lomas packages.
- library: DPLibraries
The external library that caused the exception.
- message: str
Exception error message.
For exceptions from libraries external to the lomas packages.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.EXTERNAL_LIBRARY]
Exception type.
- class lomas_core.models.exceptions.InternalServerExceptionModel(*, type: Literal[ExceptionType.INTERNAL_SERVER] = ExceptionType.INTERNAL_SERVER)[source]
Bases:
LomasServerExceptionModelFor any unforseen internal exception.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.INTERNAL_SERVER]
Exception type.
For any unforseen internal exception.
- class lomas_core.models.exceptions.InvalidQueryExceptionModel(*, type: Literal[ExceptionType.INVALID_QUERY] = ExceptionType.INVALID_QUERY, message: str)[source]
Bases:
LomasServerExceptionModelException directly related to the query.
For example if it does not contain a DP mechanism or there is not enough DP budget.
- message: str
Exception error message.
This is for exceptions directly related to the query. For example if it does not contain a DP mechanism or there is not enough DP budget.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.INVALID_QUERY]
Exception type.
- class lomas_core.models.exceptions.LomasServerExceptionModel(*, type: str)[source]
Bases:
BaseModelBase model for lomas server exceptions.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: str
Exception type.
- class lomas_core.models.exceptions.UnauthorizedAccessExceptionModel(*, type: Literal[ExceptionType.UNAUTHORIZED_ACCESS] = ExceptionType.UNAUTHORIZED_ACCESS, message: str)[source]
Bases:
LomasServerExceptionModelException related to rights with regards to the query.
(e.g. no user access for this dataset).
- message: str
Exception error message.
Exception related to rights with regards to the query. (e.g. no user access for this dataset).
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal[ExceptionType.UNAUTHORIZED_ACCESS]
Exception type.
lomas_core.models.requests module
lomas_core.models.requests_examples module
lomas_core.models.responses module
- class lomas_core.models.responses.CostResponse(*, epsilon: float, delta: float)[source]
Bases:
ResponseModelModel for responses to cost estimation requests or queries.
- delta: float
The delta cost of the query.
- epsilon: float
The epsilon cost of the query.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- 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, json_schema_input_type=Any)])[source]
Bases:
BaseModelModel for diffprivlib query result.
- model: Annotated[DiffprivlibMixin, PlainSerializer(func=serialize_model, return_type=PydanticUndefined, when_used=always), PlainValidator(func=deserialize_model, json_schema_input_type=Any)]
The trained model.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- res_type: Literal[DPLibraries.DIFFPRIVLIB]
Result type description.
- score: float
The trained model score.
- 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:
ResponseModelModel for responses to dummy dataset requests.
- datetime_columns: List[str]
The list of columns with datetime type.
- 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]
The dummy_df column data types.
- dummy_df: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always)]
The dummy dataframe.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.responses.InitialBudgetResponse(*, initial_epsilon: float, initial_delta: float)[source]
Bases:
ResponseModelModel for responses to initial budget queries.
- initial_delta: float
The initial delta privacy loss budget.
- initial_epsilon: float
The initial epsilon privacy loss budget.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class lomas_core.models.responses.OpenDPQueryResult(*, res_type: Literal[DPLibraries.OPENDP] = DPLibraries.OPENDP, value: int | float | List[int | float])[source]
Bases:
BaseModelType for opendp result.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- res_type: Literal[DPLibraries.OPENDP]
Result type description.
- value: int | float | List[int | float]
The result value of the query.
- 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:
CostResponseResponse to Lomas queries.
- model_config: ClassVar[ConfigDict] = {'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- requested_by: str
The user that triggered the query.
- result: Annotated[DiffPrivLibQueryResult | SmartnoiseSQLQueryResult | SmartnoiseSynthModel | SmartnoiseSynthSamples | OpenDPQueryResult, Discriminator(discriminator=res_type, custom_error_type=None, custom_error_message=None, custom_error_context=None)]
The query result object.
- class lomas_core.models.responses.RemainingBudgetResponse(*, remaining_epsilon: float, remaining_delta: float)[source]
Bases:
ResponseModelModel for responses to remaining budget queries.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- remaining_delta: float
The remaining delta privacy loss budget.
- remaining_epsilon: float
The remaining epsilon privacy loss budget.
- class lomas_core.models.responses.ResponseModel[source]
Bases:
BaseModelBase model for any response from the server.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- 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, json_schema_input_type=Any)])[source]
Bases:
BaseModelType for smartnoise_sql result type.
- df: Annotated[DataFrame, PlainSerializer(func=dataframe_to_dict, return_type=PydanticUndefined, when_used=always), PlainValidator(func=dataframe_from_dict, json_schema_input_type=Any)]
Dataframe containing the query result.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- res_type: Literal[DPLibraries.SMARTNOISE_SQL]
Result type description.
- 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, json_schema_input_type=Any)])[source]
Bases:
BaseModelType 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, json_schema_input_type=Any)]
Synthetic data generator model.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- res_type: Literal[DPLibraries.SMARTNOISE_SYNTH]
Result type description.
- 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, json_schema_input_type=Any)])[source]
Bases:
BaseModelType 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, json_schema_input_type=Any)]
Dataframe containing the generated synthetic samples.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- res_type: Literal['sn_synth_samples']
Result type description.
- class lomas_core.models.responses.SpentBudgetResponse(*, total_spent_epsilon: float, total_spent_delta: float)[source]
Bases:
ResponseModelModel for responses to spent budget queries.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- total_spent_delta: float
The total spent delta privacy loss budget.
- total_spent_epsilon: float
The total spent epsilon privacy loss budget.
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