ersilia.api.commands package¶
Submodules¶
ersilia.api.commands.catalog module¶
- ersilia.api.commands.catalog.catalog(hub=False, file_name=None, browser=False, 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.
browser (bool) – Unused in current version; reserved for future.
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(model, simple=True, random=True, n_samples=5, deterministic=False)[source]¶
This command can sample inputs for a given model and save them as a CSV file.
- Parameters:
model (The model ID to be served. Can either be the eos identifier or slug.)
file_name (Path where the CSV examples should be saved. Must end with .csv.)
simple (If True, only SMILES strings are returned. If False, outputs include InChiKey and name.)
random (If the model source contains an example input file, when the predefined flag is set, then inputs are sampled from that file. Only the number of samples present in the file are returned, especially if --n_samples is greater than that number. By default, Ersilia samples inputs randomly.)
n_samples (Specify the number of example inputs to generate for the given model.)
deterministic (Used to generate examples data deterministically instead of random sampling. This allows when every time you run with example command with this flag you get the same types of examples.)
- 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, output=None, batch_size=100)[source]¶
Runs the current model on SMILES inouts, 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 SMILES strings or a filepath to a CSV file (.csv) containing SMILES
output (str, optional) – Filepath to save the model predictions, Supported extensions: .csv, .json, .h5 If None, a temporary CSV file will be generated and cleaned up after loading.
batch_size (int, default=100) – Number of SMILES 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.run.validate_input_output_types(input, output)[source]¶
Validate that the provided input and output parameters are of supported types.
- Parameters:
input (list of str or str) – A list of SMILES strings or a filepath pointing to a CSV file (.csv) containing SMILES with ‘input’ header
output (str or None) – Optional filepath for saving the model output. If provided, must end with one of: .csv, .json, .h5
- Raises:
If 'input' is neither a list nor a .csv filepath, or if 'output' (when not None) does not end with a supported –
extension. –
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. –