ersilia.hub.content package

Submodules

ersilia.hub.content.base_information module

class ersilia.hub.content.base_information.BaseInformation(config_json=None)[source]

Bases: ErsiliaBase

Base class for handling and validating model information.

Parameters:

config_json (dict) – Configuration data in JSON format.

as_dict()[source]

Convert the model information to a dictionary.

Returns:

The model information as a dictionary.

Return type:

dict

property biomedical_area

Get the model biomedical area.

Returns:

The model biomedical area.

Return type:

list

property both_identifiers

Get both the model identifier and slug.

Returns:

The model identifier and slug.

Return type:

tuple

Raises:

BothIdentifiersBaseInformationError – If either the identifier or slug is not set.

property computational_performance_hund

Get the computational performance at level hundred.

Returns:

The computational performance metric at level hundred.

Return type:

int or float

property computational_performance_one

Get the computational performance at level one.

Returns:

The computational performance metric at level one.

Return type:

int or float

property computational_performance_ten

Get the computational performance at level ten.

Returns:

The computational performance metric at level ten.

Return type:

int or float

property contributor

Get the model contributor.

Returns:

The model contributor.

Return type:

str

property date

Get the model date.

Returns:

The model date.

Return type:

str

property description

Get the model description.

Returns:

The model description.

Return type:

str

property docker_architecture

Get the model Docker architecture.

Returns:

The model Docker architecture.

Return type:

list

property dockerhub

Get the model DockerHub URL.

Returns:

The model DockerHub URL.

Return type:

str

property environment_size

Get the model evironment Size in Mb.

Returns:

The model evironment Size in Mb.

Return type:

int

from_dict(data)[source]

Load the model information from a dictionary.

Parameters:

data (dict) – The model information as a dictionary.

property github

Get the model GitHub URL.

Returns:

The model GitHub URL.

Return type:

str

Raises:

GithubBaseInformationError – If the identifier is not set.

property identifier

Get the model identifier.

Returns:

The model identifier.

Return type:

str

property image_size_mb

Get the image size in megabytes.

Returns:

The size of the image in MB.

Return type:

int

property input

Get the model input.

Returns:

The model input.

Return type:

list

property input_shape

Get the model input shape.

Returns:

The model input shape.

Return type:

str

property interpretation

Get the model interpretation.

Returns:

The model interpretation.

Return type:

str

property license

Get the model license.

Returns:

The model license.

Return type:

str

property mode

Get the model mode.

Returns:

The model mode.

Return type:

str

property output

Get the model output.

Returns:

The model output.

Return type:

list

property output_consistency

Get the model output consistency.

Returns:

The model output consistency.

Return type:

str

property output_dimension

Get the model output dimension.

Returns:

The model output dimension.

Return type:

int

property output_shape

Get the model output shape.

Returns:

The model output shape.

Return type:

str

property output_type

Get the model output type.

Returns:

The model output type.

Return type:

list

property publication

Get the model publication URL.

Returns:

The model publication URL.

Return type:

str

property publication_type

Get the model publication type.

Returns:

The model publication type.

Return type:

str

property publication_year

Get the model publication year.

Returns:

The model publication year.

Return type:

int

property s3

Get the model S3 URL.

Returns:

The model S3 URL.

Return type:

str

property slug

Get the model slug.

Returns:

The model slug.

Return type:

str

property source

Get the model source.

Returns:

The model source.

Return type:

str

property source_code

Get the model source code URL.

Returns:

The model source code URL.

Return type:

str

property source_type

Get the model source type.

Returns:

The model source type.

Return type:

str

property status

Get the model status.

Returns:

The model status.

Return type:

str

property subtask

Get the model subtask.

Returns:

The model subtask.

Return type:

list

property tag

Get the model tags.

Returns:

The model tags.

Return type:

list

property target_organism

Get the model target organism.

Returns:

The model target organism.

Return type:

list

property task

Get the model task.

Returns:

The model task.

Return type:

list

property title

Get the model title.

Returns:

The model title.

Return type:

str

ersilia.hub.content.card module

class ersilia.hub.content.card.LakeCard(config_json=None)[source]

Bases: ErsiliaBase

Class to handle the lake card of a model.

The lake in ersilia refers to a result storage platform powered by isaura package to store repeated result as a cache and allows user to reuse them. It uses HDF5 explorer to explore and retrieve information from HDF5 files.

Parameters:

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

get(model_id: str | None = None, slug: str | None = None, as_json: bool = False) dict[source]

Get the lake card of a model from the HDF5 explorer.

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

  • slug (str, optional) – The slug of the model.

  • as_json (bool, optional) – Whether to return the lake card in JSON format.

Returns:

The lake card of the model.

Return type:

dict

class ersilia.hub.content.card.LocalCard(config_json)[source]

Bases: ErsiliaBase

Class to handle the local card of a model.

This class provides methods to get the local card of a model from the local repository stored in eos directory.

Parameters:

config_json (dict) – Configuration settings in JSON format.

get(model_id: str | None = None, slug: str | None = None) dict[source]

Get the local card of a model from the local repository.

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

  • slug (str, optional) – The slug of the model.

Returns:

The local card of the model.

Return type:

dict

class ersilia.hub.content.card.MetadataCard(config_json)[source]

Bases: ErsiliaBase

Class to handle the metadata card of a model.

This class provides methods to get the metadata card of a model from the local repository.

Parameters:

config_json (dict) – Configuration settings in JSON format.

get(model_id: str | None = None, slug: str | None = None) dict[source]

Get the metadata card of a model from the local repository.

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

  • slug (str, optional) – The slug of the model.

Returns:

The metadata card of the model.

Return type:

dict

class ersilia.hub.content.card.ModelCard(config_json=None)[source]

Bases: object

Class to handle the model card.

This class provides methods to get the model card from various sources, such as local repository, metadata card, S3 JSON card, and README card.

Parameters:

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

get(model_id: str | None = None, slug: str | None = None, as_json: bool = False) dict[source]

Get the model card from various sources.

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

  • slug (str, optional) – The slug of the model.

  • as_json (bool, optional) – Whether to return the model card in JSON format.

Returns:

The model card.

Return type:

dict

class ersilia.hub.content.card.ReadmeCard(config_json)[source]

Bases: ErsiliaBase

Class to handle the README card of a model.

This class provides methods to get the README card of a model from GitHub.

Parameters:

config_json (dict) – Configuration settings in JSON format.

get(model_id: str | None = None, slug: str | None = None) dict[source]

Get the README card of a model from GitHub.

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

  • slug (str, optional) – The slug of the model.

Returns:

The README card of the model.

Return type:

dict

parse(model_id)[source]

Parse the model information from the README file.

Parameters:

model_id (str) – The model identifier.

class ersilia.hub.content.card.RepoMetadataFile(model_id=None, config_json=None)[source]

Bases: ErsiliaBase

Class to handle the metadata file of a model repository.

This class provides methods to get the URL of the metadata file from GitHub, read information from the metadata file, and write information to the metadata file.

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

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

get_json_or_yaml_file(org: str | None = None, branch: str | None = None) dict[source]

Get the metadata file from GitHub in JSON or YAML format. JSON format typically used for bentoml packed models and YAML format typically used for ersilia pack models.

Parameters:
  • org (str, optional) – The GitHub organization.

  • branch (str, optional) – The GitHub branch.

Returns:

The metadata file content.

Return type:

dict

read_information(org: str | None = None, branch: str | None = None, json_or_yaml_path: str | None = None) BaseInformation[source]

Read information from the metadata file.

Parameters:
  • org (str, optional) – The GitHub organization.

  • branch (str, optional) – The GitHub branch.

  • json_or_yaml_path (str, optional) – The path to the JSON or YAML file.

Returns:

The base information read from the metadata file.

Return type:

BaseInformation

write_information(data: BaseInformation, json_or_yaml_path: str | None = None) dict[source]

Write information to the metadata file.

Parameters:
  • data (BaseInformation) – The base information to write.

  • json_or_yaml_path (str, optional) – The path to the JSON or YAML file.

Returns:

The written data.

Return type:

dict

class ersilia.hub.content.card.S3JsonCard(config_json=None)[source]

Bases: JsonModelsInterface

Class to handle the S3 JSON card of a model.

This class provides methods to get the S3 JSON card of a model from the S3 bucket.

Parameters:

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

get(model_id: str | None = None, slug: str | None = None) dict[source]

Get the S3 JSON card of a model from the S3 bucket by model id or slug.

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

  • slug (str, optional) – The slug of the model.

Returns:

The S3 JSON card of the model.

Return type:

dict

get_card_by_model_id(model_id)[source]

Get the card information by model identifier.

Parameters:

model_id (str) – The model identifier.

Returns:

The card information.

Return type:

dict

get_card_by_slug(slug)[source]

Get the card information by model slug.

Parameters:

slug (str) – The model slug.

Returns:

The card information.

Return type:

dict

ersilia.hub.content.catalog module

See available models in the Ersilia Model Hub

class ersilia.hub.content.catalog.CatalogTable(data, columns)[source]

Bases: object

Class to handle the catalog table of models.

This class provides methods to convert the model catalog into various formats, such as list of dictionaries, JSON, and table format. It also provides methods to write the catalog table to a file.

Parameters:
  • data (list) – The data of the catalog table.

  • columns (list) – The columns of the catalog table.

as_json() str[source]

Convert the catalog table to JSON format.

Returns:

The catalog table in JSON format.

Return type:

str

as_list_of_dicts() list[source]

Convert the catalog table to a list of dictionaries.

Returns:

The catalog table as a list of dictionaries.

Return type:

list

as_table() str[source]

Convert the catalog table to table format.

Returns:

The catalog table in table format.

Return type:

str

generate_separator_line(left, middle, right, horizontal, widths)[source]

Generates a separator line for the table based on the given borders and column widths.

Parameters:
  • left (str) – The character to use for the left border of the line.

  • middle (str) – The character to use between columns (as separators).

  • right (str) – The character to use for the right border of the line.

  • horizontal (str) – The character used to draw the horizontal border.

  • widths (list of int) – A list of column widths to determine how much horizontal space each column takes.

Returns:

The formatted separator line as a string.

Return type:

str

write(file_name: str)[source]

Write the catalog table to a file.

Parameters:

file_name (str) – The name of the file to write the catalog table to.

class ersilia.hub.content.catalog.ModelCatalog(config_json=None, less=True)[source]

Bases: ErsiliaBase

Class to handle the model catalog.

This class provides methods to manage the model catalog, including adding, updating, and retrieving models.

LESS_FIELDS

List of fields with less information.

Type:

list

MORE_FIELDS

List of fields with more information.

Type:

list

LESS_FIELDS = ['Identifier', 'Slug']
MORE_FIELDS = ['Identifier', 'Slug', 'Title', 'Task', 'Input Shape', 'Output', 'Output Shape']
airtable()[source]

List models available in AirTable Ersilia Model Hub base.

bentoml() CatalogTable[source]

List models available as BentoServices.

Returns:

The catalog table containing the models available as BentoServices.

Return type:

CatalogTable

hub()[source]

List models available in Ersilia model hub from the S3 JSON

local() CatalogTable[source]

List models metadata from the local repository.

Returns:

The catalog table containing the models available locally.

Return type:

CatalogTable

ersilia.hub.content.columns_information module

class ersilia.hub.content.columns_information.ColumnsInformation(model_id, api_name, config_json=None)[source]

Bases: ErsiliaBase

Class to handle the columns information of a model.

This class provides methods to get columns information from local files or GitHub, and validate the columns data.

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

  • api_name (str) – The API name.

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

load()[source]

Load the columns information.

Returns:

The columns information.

Return type:

dict

ersilia.hub.content.information module

class ersilia.hub.content.information.Information(model_id, config_json=None)[source]

Bases: ErsiliaBase

Class to handle the information of a models.

This class provides methods to get various information about a model, such as pack mode, service class, model source, API schema, size, metadata, and card.

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

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

get() dict[source]

Get various information about the model.

Returns:

A dictionary containing several information about the model.

Return type:

dict

class ersilia.hub.content.information.InformationDisplayer(info_data, config_json=None)[source]

Bases: ErsiliaBase

Class to display the information of a model.

This class provides methods to display various information about a model, such as description, identifiers, code, and Docker information.

Parameters:
  • info_data (dict) – The information data of the model.

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

echo()[source]

Display the information about the model.

ersilia.hub.content.search module

Search for models

class ersilia.hub.content.search.ModelSearcher(catalog)[source]

Bases: object

Class to handle model search operations.

This class provides methods to search for models in the catalog table using text and mode of training.

Parameters:

catalog (CatalogTable) – The catalog table containing the models.

levenshtein_ratio_and_distance(s: str, t: str) float[source]

Algorithm to fuzzy match strings using Levenshtein distance.

Parameters:
  • s (str) – The first string.

  • t (str) – The second string.

Returns:

The Levenshtein distance ratio between the two strings.

Return type:

float

search_mode(s: str) CatalogTable[source]

Search the mode of training.

Parameters:

s (str) – The mode of training to search for.

Returns:

The catalog table containing the models with the specified mode of training.

Return type:

CatalogTable

search_text(s: str) CatalogTable[source]

Search using text and return the closest matching string.

Parameters:

s (str) – The text to search for.

Returns:

The catalog table containing the closest matching models.

Return type:

CatalogTable

ersilia.hub.content.slug module

class ersilia.hub.content.slug.Slug(config_json=None)[source]

Bases: ErsiliaBase

Class to handle slug operations.

This class provides methods to encode and decode slugs to model IDs and vice versa, using local and remote sources.

Parameters:

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

decode(model_id: str) str[source]

Given a model_id, get the slug.

Parameters:

model_id (str) – The model_id to decode.

Returns:

The slug corresponding to the model_id.

Return type:

str

encode(slug: str) str[source]

Given a slug, get the model_id.

Parameters:

slug (str) – The slug to encode.

Returns:

The model_id corresponding to the slug.

Return type:

str

is_slug(text: str) bool[source]

Check if the given text is a slug.

Parameters:

text (str) – The text to check.

Returns:

True if the text is a slug, False otherwise.

Return type:

bool

Module contents