lomas_core package

Subpackages

Submodules

lomas_core.constants module

class lomas_core.constants.DPLibraries(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Name of DP Library used in the query.

DIFFPRIVLIB = 'diffprivlib'
OPENDP = 'opendp'
SMARTNOISE_SQL = 'smartnoise_sql'
SMARTNOISE_SYNTH = 'smartnoise_synth'
class lomas_core.constants.SSynthGanSynthesizer(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

GAN Synthesizer models for smartnoise synth.

DP_CTGAN = 'dpctgan'
DP_GAN = 'dpgan'
PATE_CTGAN = 'patectgan'
PATE_GAN = 'pategan'
class lomas_core.constants.SSynthMarginalSynthesizer(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Marginal Synthesizer models for smartnoise synth.

AIM = 'aim'
MST = 'mst'
MWEM = 'mwem'
PAC_SYNTH = 'pacsynth'

lomas_core.error_handler module

exception lomas_core.error_handler.ExternalLibraryException(library: DPLibraries, 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_core.error_handler.InternalServerException(error_message: str)[source]

Bases: Exception

Custom exception for issues within server internal functionalities.

exception lomas_core.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_core.error_handler.UnauthorizedAccessException(error_message: str)[source]

Bases: Exception

Custom exception for unauthorized access:

(unknown user, no access to dataset, etc)

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

Translates custom exceptions to JSONResponses.

Parameters:

app (FastAPI) – A fastapi App.

lomas_core.instrumentation module

lomas_core.instrumentation.get_ressource(service_name: str, host_name: str)[source]

Creates a Resource object with metadata describing the service.

Returns:

The resource object containing service metadata.

Return type:

Resource

lomas_core.instrumentation.init_logs_exporter(resource: Resource) None[source]

Initializes the OpenTelemetry logs exporter with a given resource.

Parameters:

resource (Resource) – The resource to associate with the log telemetry.

lomas_core.instrumentation.init_metrics_exporter(resource: Resource) None[source]

Initializes the OpenTelemetry metrics exporter with a given resource.

Parameters:

resource (Resource) – The resource to associate with the metric telemetry.

lomas_core.instrumentation.init_telemetry(resource: Resource) None[source]

Initializes all OpenTelemetry exporters with a shared resource.

Parameters:

resource (Resource) – The resource to associate with the app and instance.

lomas_core.instrumentation.init_traces_exporter(resource: Resource) None[source]

Initializes the OpenTelemetry trace exporter with a given resource.

Parameters:

resource (Resource) – The resource to associate with the trace telemetry.

Module contents