ersilia.store package¶
Submodules¶
ersilia.store.api module¶
- class ersilia.store.api.InferenceStoreApi(model_id: str, output: str | None = None, n_samples: int = -1, output_source: str = 'cloud-cache-only', click_iface: ClickInterface | None = None, api_client: ApiClient | None = None, file_manager: FileManager | None = None)[source]¶
Bases:
ErsiliaBase
Synchronous client for the Inference Store API orchestrating end-to-end batch cloud precalculation fetcher.
- Parameters:
model_id (str) – Identifier of the model to query.
output (str, optional) – Path to save the merged CSV (default is “<model_id>_precalc.csv”).
n_samples (int, optional) – Number of samples to retrieve (default is -1 for all available).
output_source (OutputSource, optional) – Source of input data (default is OutputSource.CLOUD_ONLY).
click_iface (ClickInterface, optional) – CLI helper instance for styled output (default creates new one).
api_client (ApiClient, optional) – HTTP client for API interactions (default creates new one).
file_manager (FileManager, optional) – File operations helper (default creates new one).
- get_precalculations(inputs: list) str [source]¶
Execute full inference workflow: upload inputs, submit job, poll status, retrieve result shards, and merge them into a single CSV.
- Parameters:
inputs (list) – List of input records to process.
- Returns:
File path to the merged CSV containing inference results.
- Return type:
str
- Raises:
RuntimeError – If the job fails, no shards are returned, or polling times out.
ersilia.store.dump module¶
ersilia.store.utils module¶
- class ersilia.store.utils.ApiClient(base_url: str | None = None, timeout: int = 3600)[source]¶
Bases:
object
HTTP client wrapper for JSON-based and streaming API requests.
- Parameters:
base_url (str, optional) – Base URL for all HTTP requests.
timeout (int, optional) – Default timeout in seconds for HTTP requests.
- download_stream(url: str, chunk_size: int = 65536)[source]¶
Stream binary data from a URL in configurable chunk sizes.
- Parameters:
url (str) – URL to download data from.
chunk_size (int, optional) – Size of each chunk in bytes (default is 65536).
- Yields:
bytes – Chunks of data from the response.
- get_json(endpoint: str, params: dict | None = None)[source]¶
Perform a GET request and return parsed JSON.
- Parameters:
endpoint (str) – API endpoint path (appended to base_url).
params (dict, optional) – Query parameters for the request.
- Returns:
Parsed JSON response.
- Return type:
dict
- class ersilia.store.utils.ClickInterface(colourize: bool = True)[source]¶
Bases:
object
Interactive CLI helper for styled console output and progress bars.
- Parameters:
colourize (bool, optional) – Whether to enable ANSI styling in output (default is True).
- echo(message: str, fg: str | None = None, bg: str | None = None, bold: bool = False, blink: bool = False)[source]¶
Print a styled message with optional colors and text effects.
- Parameters:
message (str) – The text to display.
fg (str, optional) – Foreground color name or code.
bg (str, optional) – Background color name or code.
bold (bool, optional) – Whether to use bold text.
blink (bool, optional) – Whether to use blinking text.
- class ersilia.store.utils.FileManager[source]¶
Bases:
object
Utility class for temporary CSV creation, S3 uploads, and merging result shards.
- static create_temp_csv(records, input_adapter) str [source]¶
Write records to a temporary CSV file via a GenericInputAdapter.
- Parameters:
records (list) – Iterable of input records to write.
input_adapter (GenericInputAdapter) – Adapter that yields dicts with ‘input’ key.
- Returns:
Path of the created temporary CSV file.
- Return type:
str
- static merge_shards(shards: list, header: list, output_path: Path, downloader, click_iface: ClickInterface, local_cache_csv_path: str)[source]¶
Download, decompress, and concatenate multiple CSV shards into a single file.
- Parameters:
shards (list) – List of dicts with keys ‘url’, ‘key’, and optional ‘size’.
header (list) – CSV header row.
output_path (Path) – Path to write the merged CSV.
downloader (ApiClient) – Used for HEAD and streaming GET requests.
click_iface (ClickInterface) – CLI interface for printing progress and warnings.
- 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.JobStatus[source]¶
Bases:
object
Class to define job completetion status.
- FAILED = 'FAILED'¶
- PENDING = 'PENDING'¶
- RUNNING = 'RUNNING'¶
- SUCCEEDED = 'SUCCEEDED'¶
- 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.
- class ersilia.store.utils.OutputSource[source]¶
Bases:
object
Class to define output source options.
- ALL = ['local-cache-only', 'cloud-cache-only']¶
- CACHE_ONLY = 'cache-only'¶
- CLOUD = 'cloud-cache'¶
- CLOUD_ONLY = 'cloud-cache-only'¶
- LOCAL = 'local-cache'¶
- LOCAL_ONLY = 'local-cache-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
- 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.
- 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.