ersilia.utils package¶
Subpackages¶
- ersilia.utils.exceptions_utils package
- Submodules
- ersilia.utils.exceptions_utils.api_exceptions module
- ersilia.utils.exceptions_utils.base_information_exceptions module
BaseInformationError
BiomedicalAreaBaseInformationError
BothIdentifiersBaseInformationError
ComputationalPerformanceHundredBaseInformationError
ComputationalPerformanceOneBaseInformationError
ComputationalPerformanceTenBaseInformationError
DescriptionBaseInformationError
DockerArchitectureBaseInformationError
DockerhubBaseInformationError
EnvironmentSizeMbBaseInformationError
GithubBaseInformationError
IdentifierBaseInformationError
ImageSizeMbBaseInformationError
InputBaseInformationError
InputShapeBaseInformationError
LicenseBaseInformationError
MemoryGbBaseInformationError
ModeBaseInformationError
OutputBaseInformationError
OutputConsistencyBaseInformationError
OutputDimensionBaseInformationError
OutputShapeBaseInformationError
OutputTypeBaseInformationError
PublicationBaseInformationError
PublicationTypeBaseInformationError
PublicationYearBaseInformationError
S3BaseInformationError
SlugBaseInformationError
SourceBaseInformationError
SourceCodeBaseInformationError
SourceTypeBaseInformationError
StatusBaseInformationError
SubtaskBaseInformationError
TagBaseInformationError
TargetOrganismBaseInformationError
TaskBaseInformationError
TitleBaseInformationError
- ersilia.utils.exceptions_utils.card_exceptions module
- ersilia.utils.exceptions_utils.catalog_exceptions module
- ersilia.utils.exceptions_utils.clear_exceptions module
- ersilia.utils.exceptions_utils.close_exceptions module
- ersilia.utils.exceptions_utils.delete_exceptions module
- ersilia.utils.exceptions_utils.example_exceptions module
- ersilia.utils.exceptions_utils.exceptions module
- ersilia.utils.exceptions_utils.fetch_exceptions module
CondaEnvironmentExistsError
DockerNotActiveError
FetchErsiliaError
FolderNotFoundError
GetFetchErsiliaError
InvalidUrlError
ModelPackageInstallError
NotInstallableError
NotInstallableWithBentoML
NotInstallableWithFastAPI
OutputDataTypesNotConsistentError
S3DownloaderError
StandardModelExampleError
VirtualEnvironmentSetupError
- ersilia.utils.exceptions_utils.handle_undecorated_exception module
- ersilia.utils.exceptions_utils.hubdata_exceptions module
- ersilia.utils.exceptions_utils.issue_reporting module
- ersilia.utils.exceptions_utils.pull_exceptions module
- ersilia.utils.exceptions_utils.serve_exceptions module
- ersilia.utils.exceptions_utils.setup_exceptions module
- ersilia.utils.exceptions_utils.test_exceptions module
- ersilia.utils.exceptions_utils.throw_ersilia_exception module
- Module contents
- ersilia.utils.identifiers package
- Submodules
- ersilia.utils.identifiers.arbitrary module
- ersilia.utils.identifiers.compound module
CompoundIdentifier
CompoundIdentifier.chemical_identifier_resolver()
CompoundIdentifier.convert_smiles_to_inchikey_with_rdkit()
CompoundIdentifier.encode()
CompoundIdentifier.encode_batch()
CompoundIdentifier.guess_type()
CompoundIdentifier.is_input_header()
CompoundIdentifier.is_key_header()
CompoundIdentifier.process_smiles()
CompoundIdentifier.unichem_resolver()
CompoundIdentifier.validate_smiles()
Identifier
- ersilia.utils.identifiers.file module
- ersilia.utils.identifiers.long module
- ersilia.utils.identifiers.model module
- ersilia.utils.identifiers.protein module
- ersilia.utils.identifiers.short module
- ersilia.utils.identifiers.text module
- ersilia.utils.identifiers.timestamp module
- Module contents
- ersilia.utils.supp package
Submodules¶
ersilia.utils.cli_query module¶
ersilia.utils.conda module¶
- class ersilia.utils.conda.BaseConda[source]¶
Bases:
object
Base class for managing conda environments.
- static conda_prefix(is_base)[source]¶
Get the conda prefix path.
- Parameters:
is_base (bool) – Whether the current environment is the base environment.
- Returns:
The conda prefix path.
- Return type:
str
- class ersilia.utils.conda.CondaUtils(config_json=None)[source]¶
Bases:
BaseConda
Utility class for managing conda environments and packages.
- Parameters:
config_json (dict, optional) – Configuration settings in JSON format. Default is None.
Examples
conda_utils = CondaUtils() conda_utils.create("myenv", "3.8")
- activate_base()[source]¶
Generate a script to activate the base conda environment.
- Returns:
The script to activate the base conda environment.
- Return type:
str
- static checksum_from_conda_yml_file(self, env_yml, overwrite)[source]¶
Generate a checksum for a conda environment YAML file.
- Parameters:
env_yml (str) – The path to the conda environment YAML file.
overwrite (bool) – Whether to overwrite the name and prefix in the YAML file with the checksum.
- Returns:
The checksum of the YAML file contents.
- Return type:
str
- checksum_from_dockerfile(dockerfile_dir, dest=None)[source]¶
Generate a checksum for a Dockerfile.
- Parameters:
dockerfile_dir (str) – The directory containing the Dockerfile.
dest (str, optional) – The destination directory for the checksum file. Default is None.
- Returns:
The checksum of the Dockerfile.
- Return type:
str
- checksum_from_file(filename)[source]¶
Generate a checksum for the contents of a file.
- Parameters:
filename (str) – The path to the file.
- Returns:
The checksum of the file contents.
- Return type:
str
- get_base_env(path)[source]¶
Get the base environment from a JSON file.
- Parameters:
path (str) – The path to the JSON file.
- Returns:
The base environment.
- Return type:
str
- get_conda_and_pip_install_commands_from_dockerfile_if_exclusive(path, force_exclusive=True)[source]¶
Identify install commands from a Dockerfile.
- Parameters:
path (str) – The path to the Dockerfile.
force_exclusive (bool, optional) – Whether to force exclusive conda and pip commands. Default is True.
- Returns:
A list of install commands.
- Return type:
list
- specs_from_dockerfile(dockerfile_dir, dest=None, use_checksum=False, name=None)[source]¶
Generate specs from a Dockerfile.
- Parameters:
dockerfile_dir (str) – The directory containing the Dockerfile.
dest (str, optional) – The destination directory for the specs file. Default is None.
use_checksum (bool, optional) – Whether to use a checksum for the specs. Default is False.
name (str, optional) – The name to use for the specs. Default is None.
- Returns:
The name or checksum of the specs.
- Return type:
str
- specs_from_dockerfile_as_json(dockerfile_dir, dest)[source]¶
Write a JSON file with the install requirements inferred from the Dockerfile.
- Parameters:
dockerfile_dir (str) – The directory containing the Dockerfile.
dest (str) – The destination directory for the JSON file.
- Returns:
The path to the JSON file.
- Return type:
str
- class ersilia.utils.conda.SimpleConda(config_json=None)[source]¶
Bases:
CondaUtils
A class to manage conda environments using simple commands.
- Parameters:
config_json (dict, optional) – Configuration settings in JSON format. Default is None.
Examples
simple_conda = SimpleConda() simple_conda.create("myenv", "3.8")
- active_env()[source]¶
Get the currently active conda environment.
- Returns:
The name of the currently active conda environment.
- Return type:
str
- clone(src_env, dst_env)[source]¶
Make an exact copy of a conda environment.
- Parameters:
src_env (str) – The name of the source environment.
dst_env (str) – The name of the destination environment.
- Raises:
Exception – If the source environment does not exist or the destination environment already exists.
- create(environment, python_version)[source]¶
Create a new conda environment.
- Parameters:
environment (str) – The name of the new environment.
python_version (str) – The Python version to use in the new environment.
- Return type:
None
- create_executable_bash_script(environment, commandlines, file_name)[source]¶
Create an executable bash script to run commands in a conda environment.
- Parameters:
environment (str) – The name of the environment.
commandlines (str or list) – The commands to run.
file_name (str) – The name of the bash script file.
- Returns:
The path to the bash script file.
- Return type:
str
- delete(environment)[source]¶
Delete a conda environment.
- Parameters:
environment (str) – The name of the environment to delete.
- delete_one(environment)[source]¶
Delete a conda environment.
- Parameters:
environment (str) – The name of the environment to delete.
- exists(environment)[source]¶
Check if a conda environment exists.
- Parameters:
environment (str) – The name of the environment to check.
- Returns:
True if the environment exists, False otherwise.
- Return type:
bool
- export_env_yml(environment, dest)[source]¶
Export a conda environment as an environment YAML file.
- Parameters:
environment (str) – The name of the environment to export.
dest (str) – The destination directory for the YAML file.
- get_python_path_env(environment)[source]¶
Get the Python path for a conda environment.
- Parameters:
environment (str) – The name of the environment.
- Returns:
The Python path for the environment.
- Return type:
str
- run_commandlines(**kwargs)¶
- class ersilia.utils.conda.StandaloneConda[source]¶
Bases:
object
A class to manage standalone conda environments.
ersilia.utils.config module¶
- class ersilia.utils.config.Config(json_file=None)[source]¶
Bases:
object
Config class.
An instance of this object holds config file section as attributes.
- Parameters:
json_file (str, optional) – The path to the JSON configuration file. Default is None.
ersilia.utils.cron module¶
ersilia.utils.csvfile module¶
ersilia.utils.docker module¶
- class ersilia.utils.docker.ContainerMetricsSampler(model_id, sampling_interval=0.01)[source]¶
Bases:
object
A class to sample metrics from Docker containers.
- Parameters:
model_id (str) – The model identifier.
sampling_interval (float, optional) – The interval between samples in seconds. Default is 0.01.
- class ersilia.utils.docker.SimpleDocker(use_udocker=None)[source]¶
Bases:
object
A class to manage Docker containers and images.
- Parameters:
use_udocker (bool, optional) – Whether to use udocker instead of Docker. Default is None.
- build(path, org, img, tag)[source]¶
Build a Docker image.
- Parameters:
path (str) – The path to the Dockerfile.
org (str) – The organization name.
img (str) – The image name.
tag (str) – The image tag.
- container_peak(model_id)[source]¶
Get the peak memory usage of a Docker container running an Ersilia model.
- Parameters:
model_id (str) – The model identifier.
- Returns:
The peak memory usage in MB, or None if the container is not found or an error occurs.
- Return type:
float or None
- containers(only_run)[source]¶
Get a dictionary of Docker containers.
- Parameters:
only_run (bool) – Whether to include only running containers.
- Returns:
A dictionary of Docker containers with container names as keys and image names as values.
- Return type:
dict
- static cp_from_container(name, img_path, local_path, org=None, img=None, tag=None)[source]¶
Copy files from a Docker container to the local filesystem.
- Parameters:
name (str) – The container name.
img_path (str) – The path inside the container.
local_path (str) – The local path to copy files to.
org (str, optional) – The organization name. Default is None.
img (str, optional) – The image name. Default is None.
tag (str, optional) – The image tag. Default is None.
None
- async cp_from_image(img_path, local_path, org, img, tag)[source]¶
Copy files from a Docker image to the local filesystem.
- Parameters:
img_path (str) – The path inside the image.
local_path (str) – The local path to copy files to.
org (str) – The organization name.
img (str) – The image name.
tag (str) – The image tag.
- delete(org, img, tag)[source]¶
Delete a Docker image.
- Parameters:
org (str) – The organization name.
img (str) – The image name.
tag (str) – The image tag.
- exec(cmd, org, img, tag, name)[source]¶
Execute a command in a Docker container and then kill the container.
- Parameters:
cmd (str) – The command to execute.
org (str) – The organization name.
img (str) – The image name.
tag (str) – The image tag.
name (str) – The container name.
- static exec_container(name, cmd)[source]¶
Execute a command in a Docker container.
- Parameters:
name (str) – The container name.
cmd (str) – The command to execute.
- exists(org, img, tag)[source]¶
Check if a Docker image exists.
- Parameters:
org (str) – The organization name.
img (str) – The image name.
tag (str) – The image tag.
- Returns:
True if the image exists, False otherwise.
- Return type:
bool
- images()[source]¶
Get a dictionary of Docker images.
- Returns:
A dictionary of Docker images with image names as keys and image IDs as values.
- Return type:
dict
- static remove(name)[source]¶
Remove a Docker container.
- Parameters:
name (str) – The container name.
- run(org, img, tag, name, memory=None)[source]¶
Run a Docker container.
- Parameters:
org (str) – The organization name.
img (str) – The image name.
tag (str) – The image tag.
name (str) – The container name.
memory (int, optional) – The memory limit for the container in GB. Default is None.
- Returns:
The name of the running container.
- Return type:
str
- class ersilia.utils.docker.SimpleDockerfileParser(path)[source]¶
Bases:
DockerfileParser
A class to parse Dockerfiles.
- Parameters:
path (str) – The path to the Dockerfile or the directory containing the Dockerfile.
ersilia.utils.download module¶
Download utilities
- class ersilia.utils.download.GitHubDownloader(overwrite, token=None)[source]¶
Bases:
object
A class to download files and repositories from GitHub.
- Parameters:
overwrite (bool) – Whether to overwrite existing files.
token (str, optional) – The GitHub token for authentication. Default is None.
- clone(org, repo, destination, ungit=False)[source]¶
Clone a GitHub repository.
- Parameters:
org (str) – The GitHub organization name.
repo (str) – The GitHub repository name.
destination (str) – The destination directory.
ungit (bool, optional) – Whether to remove Git-related files. Default is False.
- download_single(org, repo, repo_path, destination)[source]¶
Download a single file from a GitHub repository.
- Parameters:
org (str) – The GitHub organization name.
repo (str) – The GitHub repository name.
repo_path (str) – The path to the file in the repository.
destination (str) – The destination path.
- Returns:
True if the file was downloaded successfully, False otherwise.
- Return type:
bool
- class ersilia.utils.download.GoogleDriveDownloader[source]¶
Bases:
object
A class to download files from Google Drive.
- download_file_from_google_drive(file_id, destination)[source]¶
Download a file from Google Drive.
- Parameters:
file_id (str) – The Google Drive file ID.
destination (str) – The destination path.
- fetch_zip(file_id, destination)[source]¶
Download a ZIP file from Google Drive and extract it.
- Parameters:
file_id (str) – The Google Drive file ID.
destination (str) – The destination directory.
- class ersilia.utils.download.OsfDownloader(overwrite)[source]¶
Bases:
object
A class to download files from the Open Science Framework (OSF).
- Parameters:
overwrite (bool) – Whether to overwrite existing files.
- class ersilia.utils.download.PseudoDownloader(overwrite)[source]¶
Bases:
object
A class to simulate downloading by copying local directories.
- Parameters:
overwrite (bool) – Whether to overwrite existing files.
ersilia.utils.dvc module¶
- class ersilia.utils.dvc.DVCFetcher(local_repo_path)[source]¶
Bases:
object
A class to fetch data using DVC (Data Version Control).
- Parameters:
local_repo_path (str) – The local repository path.
- check_dvc_exists()[source]¶
Check if DVC file exists.
- Returns:
True if DVC file exists, False otherwise.
- Return type:
bool
- class ersilia.utils.dvc.DVCSetup(local_repo_path, model_id)[source]¶
Bases:
object
A class to set up DVC with Google Drive.
- Parameters:
local_repo_path (str) – The local repository path.
model_id (str) – The model identifier.
- gdrive_folder_id()[source]¶
Get the Google Drive folder ID for the model.
- Returns:
The Google Drive folder ID.
- Return type:
str
ersilia.utils.environment module¶
Utility functions to get information about the working environment.
ersilia.utils.hdf5 module¶
- class ersilia.utils.hdf5.Hdf5Data(values, keys, inputs, features)[source]¶
Bases:
object
A class to handle HDF5 data storage.
- Parameters:
values (array-like) – The data values.
keys (array-like) – The keys associated with the data.
inputs (array-like) – The inputs associated with the data.
features (array-like) – The features associated with the data.
- class ersilia.utils.hdf5.Hdf5DataLoader[source]¶
Bases:
object
A class to load data from HDF5 files.
ersilia.utils.import module¶
ersilia.utils.installers module¶
- class ersilia.utils.installers.BaseInstaller(check_install_log, config_json, credentials_json)[source]¶
Bases:
ErsiliaBase
Base class for managing installations in Ersilia.
- Parameters:
check_install_log (bool) – Whether to check the installation log.
config_json (dict, optional) – Configuration settings in JSON format. Default is None.
credentials_json (dict, optional) – Credentials settings in JSON format. Default is None.
- remove_from_log(task)[source]¶
Remove a task from the installation log.
- Parameters:
task (str) – The task to remove from the log.
- class ersilia.utils.installers.Installer(check_install_log=True, config_json=None, credentials_json=None)[source]¶
Bases:
BaseInstaller
A class to manage the installation of dependencies for Ersilia.
- Parameters:
check_install_log (bool, optional) – Whether to check the installation log. Default is True.
config_json (dict, optional) – Configuration settings in JSON format. Default is None.
credentials_json (dict, optional) – Credentials settings in JSON format. Default is None.
- class ersilia.utils.installers.Uninstaller(check_install_log=True, config_json=None, credentials_json=None)[source]¶
Bases:
BaseInstaller
A class to manage the uninstallation of dependencies for Ersilia.
- Parameters:
check_install_log (bool, optional) – Whether to check the installation log. Default is True.
config_json (dict, optional) – Configuration settings in JSON format. Default is None.
credentials_json (dict, optional) – Credentials settings in JSON format. Default is None.
- ersilia.utils.installers.base_installer(ignore_status=False)[source]¶
Perform a bare minimum installation of dependencies.
This function is mainly used to create a base environment for the models.
- Parameters:
ignore_status (bool, optional) – Whether to ignore the current installation status. Default is False.
- Return type:
None
ersilia.utils.logging module¶
ersilia.utils.paths module¶
- class ersilia.utils.paths.ErsiliaMetadataLoader(stream)[source]¶
Bases:
SafeLoader
Custom YAML loader for Ersilia metadata.
- yaml_constructors = {'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:map': <function metadata_constructor>, 'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:omap': <function SafeConstructor.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function SafeConstructor.construct_yaml_str>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>, None: <function SafeConstructor.construct_undefined>}¶
- class ersilia.utils.paths.Metadata(Identifier: str, Slug: str, Title: str, Description: str, Mode: str, Input: List[str], InputShape: str, Task: List[str], Output: List[str], OutputType: List[str], OutputShape: str, Interpretation: str, Tag: List[str], Publication: str, SourceCode: str, License: str, DockerHub: str | None = None, DockerArchitecture: List[str] | None = None, S3: str | None = None, Status: str | None = None, Contributor: str | None = None)[source]¶
Bases:
object
A dataclass to represent metadata for Ersilia models.
- Identifier¶
The model identifier.
- Type:
str
- Slug¶
The model slug.
- Type:
str
- Title¶
The model title.
- Type:
str
- Description¶
The model description.
- Type:
str
- Mode¶
The model mode.
- Type:
str
- Input¶
The model input types.
- Type:
List[str]
- InputShape¶
The shape of the model input.
- Type:
str
- Task¶
The tasks the model performs.
- Type:
List[str]
- Output¶
The model output types.
- Type:
List[str]
- OutputType¶
The types of the model output.
- Type:
List[str]
- OutputShape¶
The shape of the model output.
- Type:
str
- Interpretation¶
The interpretation of the model output.
- Type:
str
- Tag¶
The tags associated with the model.
- Type:
List[str]
- Publication¶
The publication associated with the model.
- Type:
str
- SourceCode¶
The source code repository for the model.
- Type:
str
- License¶
The license for the model.
- Type:
str
- DockerHub¶
The DockerHub repository for the model. Default is None.
- Type:
Optional[str], optional
- DockerArchitecture¶
The Docker architectures supported by the model. Default is None.
- Type:
Optional[List[str]], optional
- S3¶
The S3 bucket for the model. Default is None.
- Type:
Optional[str], optional
- Status¶
The status of the model. Default is None.
- Type:
Optional[str], optional
- Contributor¶
The contributor of the model. Default is None.
- Type:
Optional[str], optional
- Contributor: str | None = None¶
- Description: str¶
- DockerArchitecture: List[str] | None = None¶
- DockerHub: str | None = None¶
- Identifier: str¶
- Input: List[str]¶
- InputShape: str¶
- Interpretation: str¶
- License: str¶
- Mode: str¶
- Output: List[str]¶
- OutputShape: str¶
- OutputType: List[str]¶
- Publication: str¶
- S3: str | None = None¶
- Slug: str¶
- SourceCode: str¶
- Status: str | None = None¶
- Tag: List[str]¶
- Task: List[str]¶
- Title: str¶
- class ersilia.utils.paths.Paths[source]¶
Bases:
object
A class to handle various path-related operations in Ersilia.
- ersilia_development_path()[source]¶
Try to guess the package development path in the local computer.
- ersilia_development_path()[source]¶
Try to guess the package development path in the local computer.
- Returns:
The package development path if found, otherwise None.
- Return type:
str or None
- static exists(path)[source]¶
Check if a path exists.
- Parameters:
path (str) – The path to check.
- Returns:
True if the path exists, False otherwise.
- Return type:
bool
- ersilia.utils.paths.get_metadata_from_base_dir(path)[source]¶
Get metadata from the base directory of a model.
- Parameters:
path (str) – The path to the base directory.
- Returns:
The metadata dictionary.
- Return type:
dict
- Raises:
FileNotFoundError – If the metadata file is not found.
ersilia.utils.ports module¶
ersilia.utils.remove module¶
ersilia.utils.session module¶
- ersilia.utils.session.create_session_files(session_name)[source]¶
Create session directory and necessary files.
- Parameters:
session_name (str) – The name of the session.
- ersilia.utils.session.deregister_model_session(model_id)[source]¶
Remove a model from a session.
- Parameters:
model_id (str) – The model ID.
- ersilia.utils.session.determine_orphaned_session()[source]¶
Determine orphaned sessions.
- Returns:
A list of orphaned session names.
- Return type:
list
- ersilia.utils.session.get_current_pid()[source]¶
Get the current process ID.
- Returns:
The current process ID.
- Return type:
int
- ersilia.utils.session.get_model_session(model_id)[source]¶
Get the model session.
- Parameters:
model_id (str) – The model ID.
- Returns:
The session ID.
- Return type:
str
- ersilia.utils.session.get_parent_pid()[source]¶
Get the parent process ID.
- Returns:
The parent process ID.
- Return type:
int
- ersilia.utils.session.get_session_dir()[source]¶
Get the session directory.
- Returns:
The session directory path.
- Return type:
str
- ersilia.utils.session.get_session_id()[source]¶
Get the session ID.
- Returns:
The session ID.
- Return type:
str
- ersilia.utils.session.get_session_uuid()[source]¶
Get the session UUID.
- Returns:
The session UUID.
- Return type:
str
ersilia.utils.spinner module¶
ersilia.utils.system module¶
- class ersilia.utils.system.SystemChecker[source]¶
Bases:
object
A class to check various system properties.
- is_arm64()[source]¶
Check if the system architecture is ARM64.
- Returns:
True if the system architecture is ARM64, False otherwise.
- Return type:
bool
ersilia.utils.terminal module¶
- ersilia.utils.terminal.is_quiet()[source]¶
Check if the current session is in quiet mode.
- Returns:
True if the session is in quiet mode, False otherwise.
- Return type:
bool
- ersilia.utils.terminal.print_result_table(data)[source]¶
Print a result table with solid borders from JSON, CSV, or HDF5-like data. Supports formatted JSON strings.
- ersilia.utils.terminal.raw_input_with_timeout(prompt, default_answer, timeout=5)[source]¶
Prompt the user for input with a timeout.
- Parameters:
prompt (str) – The prompt message.
default_answer (str) – The default answer if the user does not respond within the timeout.
timeout (int, optional) – The timeout in seconds. Default is 5.
- Returns:
The user’s input or the default answer if the timeout is reached.
- Return type:
str
- ersilia.utils.terminal.run_command(cmd, quiet=None)[source]¶
Run a shell command.
- Parameters:
cmd (str or list) – The command to run.
quiet (bool, optional) – Whether to run the command in quiet mode. Default is None.
- ersilia.utils.terminal.run_command_check_output(cmd)[source]¶
Run a shell command and capture its output.
- Parameters:
cmd (str or list) – The command to run.
- Returns:
The output of the command.
- Return type:
str
- ersilia.utils.terminal.yes_no_input(prompt, default_answer, timeout=5)[source]¶
Prompt the user for a yes/no input with a timeout.
- Parameters:
prompt (str) – The prompt message.
default_answer (str) – The default answer if the user does not respond within the timeout.
timeout (int, optional) – The timeout in seconds. Default is 5.
- Returns:
True if the user’s input is ‘yes’, False otherwise.
- Return type:
bool
ersilia.utils.tracking module¶
ersilia.utils.uninstall module¶
ersilia.utils.upload module¶
ersilia.utils.venv module¶
- class ersilia.utils.venv.SimpleVenv(root)[source]¶
Bases:
ErsiliaBase
A class to manage virtual environments for Ersilia.
- Parameters:
root (str) – The root directory for the virtual environments.
- create(environment)¶
Create a new virtual environment.
- run_commandlines(environment, commandlines)¶
Run command lines in a virtual environment.
- create(**kwargs)¶
- delete(environment)[source]¶
Delete a virtual environment.
- Parameters:
environment (str) – The name of the virtual environment.
- Return type:
None
- exists(environment)[source]¶
Check if a virtual environment exists.
- Parameters:
environment (str) – The name of the virtual environment.
- Returns:
True if the virtual environment exists, False otherwise.
- Return type:
bool
- run_commandlines(**kwargs)¶
ersilia.utils.versioning module¶
- class ersilia.utils.versioning.Versioner(config_json=None)[source]¶
Bases:
ErsiliaBase
A class to manage versioning information for Ersilia.
- base_conda_name(org, tag)[source]¶
Get the base Conda environment name.
- Parameters:
org (str) – The organization name.
tag (str) – The tag for the Conda environment.
- Returns:
The base Conda environment name.
- Return type:
str
- bentoml_version()[source]¶
Get the current BentoML version.
- Returns:
The current BentoML version if available, otherwise None.
- Return type:
str or None
- ersilia_version()[source]¶
Get the current Ersilia version.
- Returns:
The current Ersilia version.
- Return type:
str
- ersilia_version_from_path(path)[source]¶
Get the Ersilia version from a given path.
- Parameters:
path (str) – The path to the Ersilia installation.
- Returns:
The Ersilia version if found, otherwise None.
- Return type:
str or None
- ersilia_version_with_py()[source]¶
Get the current Ersilia version with Python version.
- Returns:
The current Ersilia version with Python version.
- Return type:
str
- python_version(py_format=False)[source]¶
Get the current Python version.
- Parameters:
py_format (bool, optional) – Whether to return the version in Python format (e.g., ‘py38’). Default is False.
- Returns:
The current Python version.
- Return type:
str
- static reformat_py(v)[source]¶
Reformat a Python version string.
- Parameters:
v (str) – The Python version string.
- Returns:
The reformatted Python version string.
- Return type:
str
- Raises:
Exception – If the version string is too short.
- server_docker_name(tag=None, as_tuple=False)[source]¶
Get the server Docker image name.
- Parameters:
tag (str, optional) – The tag for the Docker image. Default is None.
as_tuple (bool, optional) – Whether to return the name as a tuple. Default is False.
- Returns:
The server Docker image name, or a tuple of (org, img, tag) if as_tuple is True.
- Return type:
str or tuple
ersilia.utils.zip module¶
- class ersilia.utils.zip.Zipper(remove)[source]¶
Bases:
object
A class to handle zipping and unzipping files.
- Parameters:
remove (bool) – Whether to remove the original files after zipping/unzipping.