ersilia.api.commands package¶
Submodules¶
ersilia.api.commands.catalog module¶
- ersilia.api.commands.catalog.catalog(hub=False, file_name=None, more=False, card=False, model=None, as_json=False, verbose=False)[source]¶
API-compatible version of the catalog command with echo-based output.
This command allows users to list a catalog of models available either locally or in the model hub. It provides options to display the catalog in various formats(such as tables by default or json), show more detailed information, and view model cards for specific models.
- Parameters:
hub (bool) – If True, fetch the catalog from the hub.
file_name (str or None) – If specified, write the catalog to this file.
more (bool) – If True, show more detail in catalog.
card (bool) – If True, display the model card for a given model.
model (str or None) – The model ID for which to display metadata.
as_json (bool) – If True, return JSON output instead of a formatted table.
verbose (bool) – If True, enable verbose logging.
- Returns:
A DataFrame of the last two catalog columns (for non-card mode), the model card metadata as dict (for card mode), or None on failure.
- Return type:
pandas.DataFrame or dict or None
ersilia.api.commands.close module¶
- ersilia.api.commands.close.close(model_id)[source]¶
This command closes the current session of the served model and cleans up any associated resources.
- Parameters:
(str) (model_id)
- Returns:
str
- Return type:
Confirmation message on success or warning message on failure.
- Raises:
RuntimeError – If no model was served in the current session.:
ersilia.api.commands.delete module¶
- ersilia.api.commands.delete.delete(model_id: str, verbose=False)[source]¶
Deletes a specified model from local storage.
- Parameters:
model_id (str) – ID of the model to delete.
- Returns:
Confirmation message on success or warning message on failure.
- Return type:
str
- Raises:
RuntimeError – If the model cannot be deleted.
ersilia.api.commands.example module¶
- ersilia.api.commands.example.example(n_samples, mode)[source]¶
This command can sample inputs for a given model and save them as a CSV file.
- Parameters:
n_samples (Specify the number of example inputs to generate for the given model.)
mode (random, deterministic or predefined)
- Returns:
Function (The exmaple command function to be used by the API.)
Str (Error message if no model was served in the current session.)
ersilia.api.commands.fetch module¶
ersilia.api.commands.info module¶
- ersilia.api.commands.info.info(model_id)[source]¶
Provides information about a specified model.
This command allows users to get detailed information about a current active session, including information about Model Identifiers, Code and Parameters, Docker Hub link and Architectures.
- Parameters:
(str) (model_id)
- Returns:
function (The info command function to be used by the API.)
str (Confirmation message on success or warning message on failure.)
- Raises:
RuntimeError – If no model was served in the current session.:
ersilia.api.commands.is_fetched module¶
- ersilia.api.commands.is_fetched.is_fetched(model_id: str) bool [source]¶
Check whether a given Ersilia model ID has been fetched locally.
- Parameters:
model_id (str) – The identifier of the model to check
- Returns:
True if ‘model_id’ exists in the local catalog (i.e., has been fetched), False otherwise.
- Return type:
bool
ersilia.api.commands.run module¶
- ersilia.api.commands.run.run(model_id, input_list, batch_size=100)[source]¶
Runs the current model on input strings, optionall saving the results to a file and always returning a DataFarme.
- Parameters:
model_id (str) – Identifier of the Ersilia model to invoke.
input (list of str or str) – A list of input strings or a filepath to a CSV file (.csv) containing inputs
batch_size (int, default=100) – Number of input rows to process per batch
- Returns:
DataFrame containing the model’s prediction results.
- Return type:
pandas.DataFrame
- Raises:
SystemExit – If input or output validation fails.
ersilia.api.commands.serve module¶
- ersilia.api.commands.serve.serve(model: str, port: int | None = None, track: bool = False, tracking_use_case: str = 'local', enable_local_cache: bool = True, local_cache_only: bool = False, cloud_cache_only: bool = False, cache_only: bool = False, max_cache_memory_frac: float | None = None, verbose_flag: bool = False)[source]¶
Serves a specified model as an API.
- Parameters:
model (The model ID to be served. Can either be the eos identifier or the slug identifier.)
port (The port to use when creating a model server. If unspecified, Ersilia looks for empty ports to use on the user's system.)
track (Whether the model's runs should be tracked to monitor model and system performance.)
tracking_use_case (If --track is true, this command allows specification of the tracking use case. Current options are: local, hosted, self-service and test.)
enable_local_cache (Toggle Redis-based local caching on or off. If enabled, the results from model APIs will be cached for 7 days.)
local_cache_only (Specifies to fetch stored model results from local cache. The local caching system is powered by Redis.)
cloud_cache_only (Specifies to fetch stored model results from cloud cache. This allows to fetch model precalculated results in csv file in Ersilia model output format.)
cache_only (Specifies to fetch stored model results from both local and cloud cache. More details are given in a dump CLI.)
max_cache_memory_frac (Sets the maximum fraction of memory to use by Redis for caching. Recommended value 0.2-0.7.)
- Return type:
Model ID, URL, SRV, Session, SRV, Session, Caching Mode Status, Local Cache Status, Tracking Status
- Raises:
RuntimeError – If the model/URL is not valid or not found,:
or if the maximum cache memory fraction is outside of the recommended range. –