ersilia.store package

Submodules

ersilia.store.api module

class ersilia.store.api.InferenceStoreApi(model_id: str)[source]

Bases: ErsiliaBase

A class to interact with the Inference Store API.

This class provides methods to upload input data to the inference store, request predictions, and retrieve the results. It handles the creation of unique request IDs, obtaining presigned URLs for file uploads, and managing the input data format.

Parameters:

model_id (str) – The ID of the model for which the inference is being performed.

Examples

api = InferenceStoreApi(model_id="eosxxxx")
inputs = ["CCO", "CCN"]
api.get_precalculations(inputs)

Mechanism

  1. Initialize the class with a model ID.

  2. Generate a unique request ID for each inference request.

  3. Obtain a presigned URL from the inference store for uploading input data.

  4. Adapt the input data to the required format and upload it using the presigned URL.

  5. Request the predictions from the inference store using the request ID.

  6. Retrieve and return the URL of the output predictions.

get_precalculations(inputs: list) str[source]

Get precalculations for the given inputs.

Parameters:

inputs (list) – A list of input data for which precalculations are to be fetched.

Returns:

The URL of the output presigned URL or an error message.

Return type:

str

ersilia.store.utils module

class ersilia.store.utils.InferenceStoreMessage(model_id)[source]

Bases: object

Base class for inference store messages.

Parameters:

model_id (str) – The ID of the model for which the message is being generated.

class ersilia.store.utils.ModelNotInStore(model_id)[source]

Bases: InferenceStoreMessage

Message class for models not found in the inference store.

Parameters:

model_id (str) – The ID of the model that is not found.

echo()[source]

Echo the message for model not found in inference store.

class ersilia.store.utils.OutputSource[source]

Bases: object

Class to define output source options.

ALL = ['local-only', 'cloud-only']
CLOUD_ONLY = 'cloud-only'
LOCAL_ONLY = 'local-only'
classmethod is_cloud(option)[source]

Check if the option is cloud.

Parameters:

option (str) – The option to check.

Returns:

True if the option is cloud, False otherwise.

Return type:

bool

classmethod is_local(option)[source]

Check if the option is local.

Parameters:

option (str) – The option to check.

Returns:

True if the option is local, False otherwise.

Return type:

bool

class ersilia.store.utils.PrecalculationsInStore(model_id, output_url)[source]

Bases: InferenceStoreMessage

Message class for precalculations found in the inference store.

Parameters:
  • model_id (str) – The ID of the model for which precalculations are found.

  • output_url (str) – The URL where the precalculations can be downloaded.

echo()[source]

Echo the message for precalculations available for download.

Parameters:

output_url (str) – The URL for downloading the precalculations.

class ersilia.store.utils.PrecalculationsNotInStore(model_id)[source]

Bases: InferenceStoreMessage

Message class for precalculations not found in the inference store.

Parameters:

model_id (str) – The ID of the model for which precalculations are not found.

echo()[source]

Echo the message for precalculations not found in inference store.

ersilia.store.utils.delete_file_upon_upload(response_code: int, file_path: str)[source]

Delete the file upon successful upload.

Parameters:
  • response_code (int) – The HTTP response code from the upload request.

  • file_path (str) – The path of the file to delete.

ersilia.store.utils.store_has_model(model_id: str) bool[source]

Check if the model exists in the inference store.

Parameters:

model_id (str) – The ID of the model to check.

Returns:

True if the model exists in the store, False otherwise.

Return type:

bool

Module contents