ersilia.hub.fetch.actions package

Submodules

ersilia.hub.fetch.actions.check module

class ersilia.hub.fetch.actions.check.ModelChecker(model_id, config_json)[source]

Bases: BaseAction

Checks the model by running an autoservice class.

Parameters:
  • model_id (str) – The model identifier.

  • config_json (dict) – The configuration settings in JSON format.

check()[source]

Check that the autoservice works.

ersilia.hub.fetch.actions.content module

class ersilia.hub.fetch.actions.content.CardGetter(model_id, config_json)[source]

Bases: BaseAction

Gets the model card and saves it locally.

Parameters:
  • model_id (str) – The model identifier.

  • config_json (dict) – The configuration settings in JSON format.

get()[source]

Get the model card.

Returns:

The model card of the model.

Return type:

dict

ersilia.hub.fetch.actions.get module

class ersilia.hub.fetch.actions.get.DockerfileCreator(model_id: str, config_json: dict, commands: list)[source]

Bases: ErsiliaBase

Class to create a Dockerfile for the model.

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

  • config_json (dict) – Configuration settings for the model.

  • commands (list) – List of commands to be added to the Dockerfile.

run()[source]

Create the Dockerfile and append necessary commands.

class ersilia.hub.fetch.actions.get.ModelGetter(model_id: str, repo_path: str, config_json: dict, force_from_github: bool, force_from_s3: bool)[source]

Bases: BaseAction

Class to get the model repository and parameters.

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

  • repo_path (str) – Path to the local repository.

  • config_json (dict) – Configuration settings for the model.

  • force_from_github (bool) – Force download from GitHub.

  • force_from_s3 (bool) – Force download from S3.

get(**kwargs)
class ersilia.hub.fetch.actions.get.ModelParametersGetter(model_id: str, config_json: dict)[source]

Bases: BaseAction

Class to get the model parameters. Getting the checkpoints, weights.

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

  • config_json (dict) – Configuration settings for the model.

get(**kwargs)
class ersilia.hub.fetch.actions.get.ModelRepositoryGetter(model_id: str, config_json: dict, force_from_github: bool, force_from_s3: bool, repo_path: str)[source]

Bases: BaseAction

Class to get the model repository from local, GitHub, or S3.

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

  • config_json (dict) – Configuration settings for the model.

  • force_from_github (bool) – Force download from GitHub.

  • force_from_s3 (bool) – Force download from S3.

  • repo_path (str) – Path to the local repository.

get(**kwargs)
class ersilia.hub.fetch.actions.get.PackCreator(model_id: str, config_json: dict)[source]

Bases: ErsiliaBase

Class to create a pack for the model. The pack.py file loads a model, packs it into a BentoML Service instance, and saves the service for deployment.

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

  • config_json (dict) – Configuration settings for the model.

run()[source]

Copy the pack creator script to the destination directory.

class ersilia.hub.fetch.actions.get.ServiceCreator(model_id: str, config_json: dict)[source]

Bases: ErsiliaBase

Class to create a service file for the model. The ‘service.py’ specifically facilitates the deployment of a custom model as a BENTOML REST API service.

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

  • config_json (dict) – Configuration settings for the model.

run()[source]

Create the service.py file in the src directory.

class ersilia.hub.fetch.actions.get.TemplatePreparer(model_id: str, config_json: dict)[source]

Bases: BaseAction

Class to prepare the template for the model.

In this context, a template refers to a predefined structure or set of files that are necessary for setting up the model environment. This includes configuration files, scripts, and other resources required to deploy and run the model.

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

  • config_json (dict) – Configuration settings for the model.

prepare()[source]

Prepare the template by creating pack, service, and Dockerfile.

ersilia.hub.fetch.actions.inform module

class ersilia.hub.fetch.actions.inform.ModelInformer(model_id, config_json)[source]

Bases: BaseAction

Class to inform about the model by writing information to a JSON file. Contains detail metadata about the model.

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

  • config_json (dict) – Configuration settings for the model.

inform()[source]

Write information to a JSON file and add API info for bentoml models.

ersilia.hub.fetch.actions.lake module

class ersilia.hub.fetch.actions.lake.LakeGetter(model_id: str, config_json: dict)[source]

Bases: BaseAction

Class to fetch data from precalculated data from the DVC repository.

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

  • config_json (dict) – Configuration settings for the model.

get()[source]

Fetch data using DVCFetcher.

ersilia.hub.fetch.actions.modify module

class ersilia.hub.fetch.actions.modify.ModelModifier(model_id: str, config_json: dict)[source]

Bases: BaseAction

Modifies model bundles to ensure compatibility and consistency.

Compatibility: Ensures that the model bundle can run in the target environment without issues. Consistency: Ensures that the model bundle follows the same structure and conventions as other bundles.

Parameters:
  • model_id (str) – Identifier of the model to be modified.

  • config_json (dict) – Configuration settings for the modifier.

modify()[source]

Modifies the model bundle.

modify()[source]

Modifies the model bundle to ensure compatibility and consistency.

ersilia.hub.fetch.actions.pack_bentoml module

class ersilia.hub.fetch.actions.pack_bentoml.ModelPacker(model_id: str, mode: str, config_json: dict)[source]

Bases: BaseAction

Packs a model using BentoML.

Parameters:
  • model_id (str) – Identifier of the model to be packed.

  • mode (str) – Packing mode to be used.

  • config_json (dict) – Configuration settings for the packer.

pack()[source]

Packs the model using BentoML.

pack()[source]

Packs the model using BentoML.

ersilia.hub.fetch.actions.pack_fastapi module

class ersilia.hub.fetch.actions.pack_fastapi.ModelPacker(model_id: str, mode: str, config_json: dict)[source]

Bases: BaseAction

Packs a model using FastAPI (aka ersilia-pack).

For more information about the ersilia-pack, visit: https://github.com/ersilia-os/ersilia-pack.git

Parameters:
  • model_id (str) – Identifier of the model to be packed.

  • mode (str) – Packing mode to be used.

  • config_json (dict) – Configuration settings for the packer.

pack()[source]

Packs the model using FastAPI.

pack()[source]

Packs the model using FastAPI.

ersilia.hub.fetch.actions.prepare module

class ersilia.hub.fetch.actions.prepare.ModelPreparer(model_id: str, overwrite: bool, config_json: dict)[source]

Bases: BaseAction

Prepares a model for use by deleting existing data if necessary.

Parameters:
  • model_id (str) – Identifier of the model to be prepared.

  • overwrite (bool) – Whether to overwrite existing data.

  • config_json (dict) – Configuration settings for the preparer.

prepare()

Prepares the model by deleting existing data if necessary.

prepare(**kwargs)

ersilia.hub.fetch.actions.setup module

class ersilia.hub.fetch.actions.setup.SetupChecker(model_id: str, config_json: dict)[source]

Bases: BaseAction

Checks the setup requirements for the model to be installed and run.

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

  • config_json (dict) – Configuration settings for the setup checker.

check()[source]

Checks all setup requirements.

check()[source]

Checks all setup requirements.

ersilia.hub.fetch.actions.sniff_bentoml module

class ersilia.hub.fetch.actions.sniff_bentoml.BuiltinExampleReader(model_id: str, config_json: dict)[source]

Bases: ErsiliaBase

Reads built-in examples for a BentoML model.

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

  • config_json (dict) – Configuration settings for the reader.

has_builtin_example() bool[source]

Checks if a built-in example exists.

example(n=3) list[source]

Returns a list of examples.

example(n: int = 3) list[source]

Returns a list of examples.

Parameters:

n (int, optional) – Number of examples to return, by default 3.

Returns:

List of examples.

Return type:

list

has_builtin_example() bool[source]

Checks if a built-in example exists.

Returns:

True if a built-in example exists, False otherwise.

Return type:

bool

class ersilia.hub.fetch.actions.sniff_bentoml.ModelSniffer(model_id: str, config_json: dict)[source]

Bases: BaseAction

Infers the structure of a model by sniffing its inputs and outputs.

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

  • config_json (dict) – Configuration settings for the sniffer.

sniff()

Infers the structure of the model.

sniff(**kwargs)

ersilia.hub.fetch.actions.sniff_fastapi module

class ersilia.hub.fetch.actions.sniff_fastapi.BuiltinExampleReader(model_id: str, config_json: dict)[source]

Bases: ErsiliaBase

Reads built-in examples for a FastAPI model.

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

  • config_json (dict) – Configuration settings for the reader.

input_example() list[source]

Returns a list of input examples.

output_example() list[source]

Returns a list of output examples.

input_example() list[source]

Returns a list of input examples.

Returns:

List of input examples.

Return type:

list

output_example() list[source]

Returns a list of output examples.

Returns:

List of output examples.

Return type:

list

class ersilia.hub.fetch.actions.sniff_fastapi.ModelSniffer(model_id: str, config_json: dict)[source]

Bases: BaseAction

Infers the structure of a model by sniffing its inputs and outputs.

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

  • config_json (dict) – Configuration settings for the sniffer.

sniff()

Infers the structure of the model.

sniff(**kwargs)

ersilia.hub.fetch.actions.template_resolver module

class ersilia.hub.fetch.actions.template_resolver.TemplateResolver(model_id: str, repo_path: str | None = None, config_json: dict | None = None)[source]

Bases: BaseAction

Resolves the template type (BentoML or FastAPI) for a model by checking the presence of specific files.

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

  • repo_path (str, optional) – Path to the local repository, by default None.

  • config_json (dict, optional) – Configuration settings for the resolver, by default None.

is_fastapi() bool[source]

Checks if the model uses or built with FastAPI.

is_bentoml() bool[source]

Checks if the model uses or built with BentoML.

is_bentoml() bool[source]

Checks if the model uses BentoML.

Returns:

True if the model uses BentoML, False otherwise.

Return type:

bool

is_fastapi() bool[source]

Checks if the model uses FastAPI.

Returns:

True if the model uses FastAPI, False otherwise.

Return type:

bool

ersilia.hub.fetch.actions.toolize module

class ersilia.hub.fetch.actions.toolize.ModelToolizer(model_id: str, config_json: dict)[source]

Bases: BaseAction

Toolizes a model by distributing it as a Python package or containerizing it using Docker.

Parameters:
  • model_id (str) – Identifier of the model to be toolized.

  • config_json (dict) – Configuration settings for the toolizer.

toolize(do_pip, do_docker)[source]

Toolizes the model by distributing it as a Python package or containerizing it using Docker.

dockerize(model_id: str)[source]

Containerizes the model using BentoML with Docker.

Parameters:

model_id (str) – Identifier of the model to be containerized.

pip_install(model_id: str)[source]

Installs the model and distributes it as a Python package.

Parameters:

model_id (str) – Identifier of the model to be installed.

toolize(do_pip: bool, do_docker: bool)[source]

Toolizes the model by distributing it as a Python package or containerizing it using Docker.

Parameters:
  • do_pip (bool) – Whether to distribute the model as a Python package.

  • do_docker (bool) – Whether to containerize the model using Docker.

Module contents

class ersilia.hub.fetch.actions.BaseAction(model_id, config_json, credentials_json)[source]

Bases: ErsiliaBase

Base class for actions.

This class provides common methods for actions.

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

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

  • credentials_json (dict) – Credentials settings in JSON format.