lomas_client package
Subpackages
Submodules
lomas_client.client module
- class lomas_client.client.Client(url: str, user_name: str, dataset_name: str)[source]
Bases:
object
Client class to send requests to the server.
Handle all serialisation and deserialisation steps
- get_dataset_metadata() LomasRequestModel | None [source]
This function retrieves metadata for the dataset.
- Returns:
A dictionary containing dataset metadata.
- Return type:
Optional[LomasRequestModel]
- get_dummy_dataset(nb_rows: int = 100, seed: int = 42) DummyDsResponse | None [source]
This function retrieves a dummy dataset with optional parameters.
- Parameters:
nb_rows (int, optional) –
The number of rows in the dummy dataset.
Defaults to DUMMY_NB_ROWS.
seed (int, optional) –
The random seed for generating the dummy dataset.
Defaults to DUMMY_SEED.
- Returns:
- A Pandas DataFrame
representing the dummy dataset.
- Return type:
Optional[DummyDsResponse]
- get_initial_budget() InitialBudgetResponse | None [source]
This function retrieves the initial budget.
- Returns:
- A dictionary
containing the initial budget.
- Return type:
Optional[InitialBudgetResponse]
- get_previous_queries() List[dict] | None [source]
This function retrieves the previous queries of the user.
- Raises:
ValueError – If an unknown query type is encountered during deserialization.
- Returns:
A list of dictionary containing the different queries on the private dataset.
- Return type:
Optional[List[dict]]
- get_remaining_budget() RemainingBudgetResponse | None [source]
This function retrieves the remaining budget.
- Returns:
- A dictionary
containing the remaining budget.
- Return type:
Optional[RemainingBudgetResponse]
- get_total_spent_budget() SpentBudgetResponse | None [source]
This function retrieves the total spent budget.
- Returns:
- A dictionary containing
the total spent budget.
- Return type:
Optional[SpentBudgetResponse]
lomas_client.constants module
lomas_client.http_client module
- class lomas_client.http_client.LomasHttpClient(url: str, user_name: str, dataset_name: str)[source]
Bases:
object
A client for interacting with the Lomas API.
- post(endpoint: str, body: LomasRequestModel, read_timeout: int = 10) Response [source]
Executes a POST request to endpoint with the provided JSON body.
- Parameters:
endpoint (str) – The API endpoint to which the request will be sent.
body_json (dict, optional) – The JSON body to include in the POST request. Defaults to {}.
request_model – (BaseModel, optional): The pydantic model to validate the body_json against. Must be non-null if body_json contains data.
read_timeout (int) – number of seconds that client wait for the server to send a response. Defaults to DEFAULT_READ_TIMEOUT.
- Returns:
The response object resulting from the POST request.
- Return type:
requests.Response
lomas_client.utils module
- lomas_client.utils.raise_error(response: Response) str [source]
Raise error message based on the HTTP response.
- Parameters:
res (requests.Response) – The response object from an HTTP request.
- Raises:
Server Error –
- lomas_client.utils.validate_model_response(response: Response, response_model: Any) Any [source]
Validate and process a HTTP response.
- Parameters:
response (requests.Response) – The response object from an HTTP request.
- Returns:
Model for responses requests.
- Return type:
response_model
- lomas_client.utils.validate_synthesizer(synth_name: str, return_model: bool = False)[source]
Validate smartnoise synthesizer (some model are not accepted).
- Parameters:
synth_name (str) – name of the Synthesizer model to use.
return_model (bool) – True to get Synthesizer model, False to get samples
- Raises:
ValueError – if a synthesizer or its parameters are not valid