ersilia.hub.fetch package

Subpackages

Submodules

ersilia.hub.fetch.fetch module

class ersilia.hub.fetch.fetch.FetchResult(fetch_success, reason)

Bases: tuple

fetch_success

Alias for field number 0

reason

Alias for field number 1

class ersilia.hub.fetch.fetch.ModelFetcher(config_json: dict | None = None, credentials_json: dict | None = None, overwrite: bool | None = None, repo_path: str | None = None, mode: str | None = None, pip: bool = False, dockerize: bool = False, force_from_github: bool = False, force_from_s3: bool = False, force_from_dockerhub: bool = False, img_version: str | None = None, force_from_hosted: bool = False, force_with_bentoml: bool = False, force_with_fastapi: bool = False, hosted_url: str | None = None, local_dir: str | None = None)[source]

Bases: ErsiliaBase

ModelFetcher is responsible for fetching models from various sources.

Parameters:
  • config_json (dict, optional) – Configuration settings for the fetcher.

  • credentials_json (dict, optional) – Credentials for accessing the model hub.

  • overwrite (bool, optional) – Whether to overwrite existing files.

  • repo_path (str, optional) – Path to the repository.

  • mode (str, optional) – Mode of operation, e.g., ‘docker’.

  • pip (bool, optional) – Whether to use pip for installation.

  • dockerize (bool, optional) – Whether to dockerize the model.

  • force_from_github (bool, optional) – Whether to force fetching from GitHub.

  • force_from_s3 (bool, optional) – Whether to force fetching from S3.

  • force_from_dockerhub (bool, optional) – Whether to force fetching from DockerHub.

  • img_version (str, optional) – Version of the model image.

  • force_from_hosted (bool, optional) – Whether to force fetching from hosted services.

  • force_with_bentoml (bool, optional) – Whether to force fetching with BentoML.

  • force_with_fastapi (bool, optional) – Whether to force fetching with FastAPI.

  • hosted_url (str, optional) – URL for hosted model.

  • local_dir (str, optional) – Local directory for the model.

Examples

fetcher = ModelFetcher(config_json=config)
await fetcher.fetch(model_id="eosxxxx")
exists(model_id: str) bool[source]

Check if the model exists locally.

Parameters:

model_id (str) – The ID of the model to be checked.

Returns:

True if the model exists locally, False otherwise.

Return type:

bool

async fetch(model_id: str) bool[source]

Fetch a model with the given eos identifier.

Parameters:

model_id (str) – The eos identifier of the model.

Returns:

True if the model was fetched successfully, False otherwise.

Return type:

bool

Examples

fetcher = ModelFetcher(config_json=config)
success = await fetcher.fetch(model_id="eosxxxx")

ersilia.hub.fetch.fetch_bentoml module

Fetch model from the Ersilia Model Hub using BentoML.

class ersilia.hub.fetch.fetch_bentoml.ModelFetcherFromBentoML(config_json: dict | None = None, credentials_json: dict | None = None, overwrite: bool | None = None, repo_path: str | None = None, mode: str | None = None, pip: bool = False, dockerize: bool = False, force_from_github: bool = False, force_from_s3: bool = False)[source]

Bases: ErsiliaBase

ModelFetcherFromBentoML is responsible for fetching models from the Ersilia Model Hub using BentoML.

Parameters:
  • config_json (dict, optional) – Configuration settings for the fetcher.

  • credentials_json (dict, optional) – Credentials for accessing the model hub.

  • overwrite (bool, optional) – Whether to overwrite existing files.

  • repo_path (str, optional) – Path to the repository.

  • mode (str, optional) – Mode of operation, e.g., ‘docker’.

  • pip (bool, optional) – Whether to use pip for installation.

  • dockerize (bool, optional) – Whether to dockerize the model.

  • force_from_github (bool, optional) – Whether to force fetching from GitHub.

  • force_from_s3 (bool, optional) – Whether to force fetching from S3.

Examples

fetcher = ModelFetcherFromBentoML(
    config_json=config
)
fetcher.fetch(model_id="eosxxxx")
fetch(model_id: str)[source]

Fetch the model from the Ersilia Model Hub.

This method initiates the fetching process for the model.

Parameters:

model_id (str) – The ID of the model to be fetched.

Examples

fetcher = ModelFetcherFromBentoML(
    config_json=config
)
fetcher.fetch(model_id="eosxxxx")
seems_installable(model_id: str) bool[source]

Check if the model is installable with BentoML.

Parameters:

model_id (str) – The ID of the model to be checked.

Returns:

True if the model is installable with BentoML, False otherwise.

Return type:

bool

ersilia.hub.fetch.fetch_fastapi module

Fetch model from the Ersilia Model Hub using FastAPI.

class ersilia.hub.fetch.fetch_fastapi.ModelFetcherFromFastAPI(config_json: dict | None = None, credentials_json: dict | None = None, overwrite: bool | None = None, repo_path: str | None = None, mode: str | None = None, force_from_github: bool = False, force_from_s3: bool = False)[source]

Bases: ErsiliaBase

ModelFetcherFromFastAPI is responsible for fetching models from the Ersilia Model Hub using FastAPI.

Parameters:
  • config_json (dict, optional) – Configuration settings for the fetcher.

  • credentials_json (dict, optional) – Credentials for accessing the model hub.

  • overwrite (bool, optional) – Whether to overwrite existing files.

  • repo_path (str, optional) – Path to the repository.

  • mode (str, optional) – Mode of operation, e.g., ‘docker’.

  • force_from_github (bool, optional) – Whether to force fetching from GitHub.

  • force_from_s3 (bool, optional) – Whether to force fetching from S3.

Examples

fetcher = ModelFetcherFromFastAPI(
    config_json=config
)
fetcher.fetch(model_id="eosxxxx")
fetch(model_id: str)[source]

Fetch the model from the Ersilia Model Hub.

This method initiates the fetching process for the model.

Parameters:

model_id (str) – The ID of the model to be fetched.

Examples

fetcher = ModelFetcherFromFastAPI(
    config_json=config
)
fetcher.fetch(model_id="eosxxxx")
seems_installable(model_id: str) bool[source]

Check if the model is installable with FastAPI.

Parameters:

model_id (str) – The ID of the model to be checked.

Returns:

True if the model is installable with FastAPI, False otherwise.

Return type:

bool

Module contents

class ersilia.hub.fetch.ModelURLResolver(model_id, config_json=None, credentials_json=None)[source]

Bases: ErsiliaBase

Class to resolve the URL of a model.

This class provides methods to resolve the URL of a model based on its ID.

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

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

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

resolve_valid_hosted_model_url(model_id)[source]

Resolves the URL of a hosted model

Parameters:

model_id (str) – Alpha numeric identifier literal of the model

Returns:

Tuple containing a boolean indicating if the URL is valid and the URL itself

Return type:

Tuple[bool, str]