ersilia.hub.bundle package

Submodules

ersilia.hub.bundle.bundle module

class ersilia.hub.bundle.bundle.BundleDockerfileFile(model_id, config_json=None)[source]

Bases: ErsiliaBase

Class to handle the Dockerfile for a model bundle.

It specifically provides methods to get the path to the Dockerfile, get the version required for the model, and more.

Parameters:
  • model_id (str) – The ID of the model.

  • config_json (dict, optional) – Configuration settings in JSON format.

check()[source]

Check if the Dockerfile exists.

Return type:

bool

get__version() dict[source]

Get the version required for the model.

Returns:

A dictionary containing the version, slim flag, and Python version.

Return type:

dict

get_file() str[source]

Get the path to the Dockerfile.

Returns:

The path to the Dockerfile.

Return type:

str

set_to_full()[source]

Set the Dockerfile to use the full version of the image.

set_to_slim()[source]

Set the Dockerfile to use the slim version of the image.

class ersilia.hub.bundle.bundle.BundleEnvironmentFile(model_id, config_json=None)[source]

Bases: ErsiliaBase

Class to handle the environment file for a model bundle.

Specifically provides methods to get the path, bundle Conda requirement, add model installation commands of environment file, and check if the environment file exists.

Parameters:
  • model_id (str) – The ID of the model.

  • config_json (dict, optional) – Configuration settings in JSON format.

add_model_install_commands()[source]

Add model installation commands to the environment file.

check()[source]

Check if the environment file exists.

Return type:

bool

get_file()[source]

Get the path to the environment file.

Returns:

The path to the environment file.

Return type:

str

needs_conda()[source]

Check if the environment file requires Conda.

Returns:

True if the environment file requires Conda, False otherwise.

Return type:

bool

class ersilia.hub.bundle.bundle.BundleRequirementsFile(model_id, config_json=None)[source]

Bases: ErsiliaBase

Class to handle the requirements file for a model bundle.

Specifically provides methods to add model installation commands to the requirements file and check if the requirements file exists.

Parameters:
  • model_id (str) – The ID of the model.

  • config_json (dict, optional) – Configuration settings in JSON format.

add_model_install_commands()[source]

Add model installation commands to the requirements file.

check()[source]

Check if the requirements file exists.

Return type:

bool

ersilia.hub.bundle.repo module

class ersilia.hub.bundle.repo.DockerfileFile(path)[source]

Bases: object

Class to handle Dockerfile operations for models.

This class provides methods to get the path to the Dockerfile, get the version required for the model, check if the Dockerfile contains RUN commands, check if the Dockerfile requires Conda, get installation commands, and more.

Parameters:

path (str) – The directory path where the Dockerfile is located.

append_run_command(cmd: str)[source]

Append a RUN command to the Dockerfile.

Parameters:

cmd (str) – The RUN command to append.

check() bool[source]

Check if the Dockerfile exists.

Returns:

True if the Dockerfile exists, False otherwise.

Return type:

bool

get_file() str[source]

Get the path to the Dockerfile.

Returns:

The path to the Dockerfile.

Return type:

str

get_install_commands() dict[source]

Get the installation commands from the Dockerfile.

Returns:

A dictionary containing Conda requirement, commands, and exclusive Conda and pip flag.

Return type:

dict

get_install_commands_from_dockerfile(fn)[source]

Get the install commands from the Dockerfile.

Parameters:

fn (str) – The path to the Dockerfile.

Returns:

The list of RUN commands from the Dockerfile.

Return type:

list

get_python_version() dict[source]

Get the Python version required for the model.

Returns:

A dictionary containing the BentoML version, slim flag, and Python version.

Return type:

dict

has_runs() bool[source]

Check if the Dockerfile contains RUN commands.

Returns:

True if the Dockerfile contains RUN commands, False otherwise.

Return type:

bool

needs_conda() bool[source]

Check if the Dockerfile requires Conda.

Returns:

True if the Dockerfile requires Conda, False otherwise.

Return type:

bool

class ersilia.hub.bundle.repo.Integrity(path)[source]

Bases: object

Class to check the integrity of the model files.

It provides methods to check if the README file, service file, and pack file exist.

Parameters:

path (str) – The directory path where the model files are located.

has_readme() bool[source]

Check if the README file exists.

Returns:

True if the README file exists, False otherwise.

Return type:

bool

class ersilia.hub.bundle.repo.ReadmeFile(path)[source]

Bases: object

Class to handle README file operations.

Parameters:

path (str) – The directory path where the README file is located.

check()[source]

Check if the README file exists.

Returns:

True if the README file exists, False otherwise.

Return type:

bool

get_file()[source]

Get the path to the README file.

Returns:

The path to the README file.

Return type:

str

class ersilia.hub.bundle.repo.RepoUtils(path, config_json=None)[source]

Bases: ErsiliaBase

Utility class for handling repository operations.

It provides methods to get the model ID, get the path to the Conda environment YAML file, get the Docker repository image, and rename the service.

Parameters:
  • path (str) – The directory path where the repository is located.

  • config_json (dict, optional) – Configuration settings in JSON format.

get_conda_env_yml_file() str[source]

Get the path to the Conda environment YAML file.

Returns:

The path to the Conda environment YAML file.

Return type:

str

get_docker_repo_image(model_id: str) str[source]

Get the Docker repository image for the model.

Parameters:

model_id (str) – The ID of the model.

Returns:

The Docker repository image for the model.

Return type:

str

get_model_id() str[source]

Get the model ID from the repository.

Returns:

The model ID.

Return type:

str

static rename_service(model_id: str) str[source]

Rename the service to the model ID.

Parameters:

model_id (str) – The ID of the model.

Returns:

The command to rename the service.

Return type:

str

ersilia.hub.bundle.status module

class ersilia.hub.bundle.status.ModelStatus(config_json=None)[source]

Bases: ErsiliaBase

Class to check the status of a model in terms of its installation and deployment.

It specifically provides methods to check if a model is downloaded, available as a Docker image, pulled from Docker Hub, available in a Conda environment, available as a pip package, available as a bundle.

Parameters:

config_json (dict, optional) – Configuration settings in JSON format.

is_bundle(model_id: str) bool[source]

Check if the model is available as a bundle.

Parameters:

model_id (str) – The ID of the model.

Returns:

True if the model is available as a bundle, False otherwise.

Return type:

bool

is_conda(model_id: str) bool[source]

Check if the model is available in a Conda environment.

Parameters:

model_id (str) – The ID of the model.

Returns:

True if the model is available in a Conda environment, False otherwise.

Return type:

bool

is_docker(model_id: str) bool[source]

Check if the model is available as a Docker image.

Parameters:

model_id (str) – The ID of the model.

Returns:

True if the model is available as a Docker image, False otherwise.

Return type:

bool

is_downloaded(model_id: str) bool[source]

Check if the model is downloaded.

Parameters:

model_id (str) – The ID of the model.

Returns:

True if the model is downloaded, False otherwise.

Return type:

bool

is_pip(model_id: str) bool[source]

Check if the model is available as a pip package.

Parameters:

model_id (str) – The ID of the model.

Returns:

True if the model is available as a pip package, False otherwise.

Return type:

bool

is_pulled_docker(model_id: str) bool[source]

Check if the Docker image for the model has been pulled.

Parameters:

model_id (str) – The ID of the model.

Returns:

True if the Docker image has been pulled, False otherwise.

Return type:

bool

status(model_id: str) dict[source]

Check the installation and deployment status of the model.

Parameters:

model_id (str) – The ID of the model.

Returns:

A dictionary with the status of the model in various formats.

Return type:

dict

Module contents