# package

Allow to handles model package either on localhost or from a remote location. the model packages can be stored in github organization to be downloaded and installed locally. The classes below are used by macsydata, which is the entry point to manipulate models package.

## package API reference

## AbstractModelIndex

class macsypy.package.AbstractModelIndex(cache: str | None = None)

  This the base class for ModelIndex. This class cannot be implemented, it must be subclassed

  __init__(cache: str | None = None) → None
  __weakref__

    list of weak references to the object

  unarchive_package(path: str) → str

    Unarchive and uncompress a package under <remote cache>/<organization name>/<package name>/<vers>/<package name>

    Parameters:

      path (str)

    Returns:

      The path to the package

## LocalModelIndex

class macsypy.package.LocalModelIndex(cache: str | None = None)

  It allow to manage installation from a local package (tarball)

  __init__(cache: str | None = None) → None

## RemoteModelIndex

class macsypy.package.RemoteModelIndex(org: str = 'macsy-models', cache: str | None = None)

  This class allow to interact with ModelIndex on github

  __init__(org: str = 'macsy-models', cache: str | None = None) → None
    Parameters:

      org – The name of the organization on github where are stored the models

  _url_json(url: str) → dict

    Get the url, deserialize the data as json

    Parameters:

      url (str) – the url to download

    Returns:

      the json corresponding to the response url

  download(pack_name: str, vers: str, dest: str | None = None) → str

    Download a package from a GitHub repos and save it as <remote cache>/<organization name>/<package name>/<vers>.tar.gz

    Parameters:

      - pack_name (str) – the name of the package to download

      - vers (str) – the version of the package to download

      - dest (str) – The path to the directory where save the package This directory must exist If dest is None, the macsyfinder cache will be used

    Returns:

      The package archive path.

  get_metadata(pack_name: str, vers: str = 'latest') → dict

    Fetch the metadata_path from a remote package

    Parameters:

      - pack_name (str) – The package name

      - vers (str) – The package version

    Returns:

      the metadata_path corresponding to this package/version

    Return type:

      dictionary corresponding of the yaml parsing of the metadata_path file.

  list_package_vers(pack_name: str) → list[str]

    List all available versions from GitHub model repos for a given package

    Parameters:

      pack_name (str) – the name of the package

    Returns:

      the list of the versions

  list_packages() → list[str]

    list all model packages available on a model repos

    Returns:

      The list of package names.

  remote_exists() → bool

    check if the remote exists and is an organization

    Returns:

      True if the Remote url point to a GitHub Organization, False otherwise

## Package

class macsypy.package.Package(path: str)

  This class Modelize a package of Models a package is a directory with the name of the models family it must contain at least - a subdirectory definitions - a subdirectory profiles - a file metadata.yml it is also recommended to add a file for licensing and copyright and a README. for further explanation see documentation: modeler guide > package

  __init__(path: str) → None
    Parameters:

      path (str) – The of the package root directory

  __weakref__

    list of weak references to the object

  _check_metadata() → tuple[list[str], list[str]]

    Check the QA of package metadata_path

    Returns:

      errors and warnings

    Return type:

      tuple of 2 lists ([str error_1, …], [str warning_1, …])

  _check_model_conf() → tuple[list[str], list[str]]

    check if a model configuration file is present in the package (model_conf.xml) if the syntax of this file is good.

    Returns:

  _check_model_consistency() → tuple[list, list]

    check if each xml seems well write, each genes have an associated profile, etc.

    Returns:

  _check_structure() → tuple[list[str], list[str]]

    Check the QA structure of the package

    Returns:

      errors and warnings

    Return type:

      tuple of 2 lists ([str error_1, …], [str warning_1, …])

  _find_readme() → str | None

    find the README file

    Returns:

      The path to the README file or None if there is no file.

  _load_metadata() → dict[slice(<class 'str'>, <class 'str'>, None)]

    Open the metadata_path file and de-serialize it’s content :return:

  check() → tuple[list[str], list[str]]

    Check the QA of this package

  help() → str

    return the content of the README file

  info() → str
    Returns:

      some information about the package

  property metadata: dict[slice(<class 'str'>, <class 'str'>, None)]
    Returns:

      The parsed metadata as a dict

Fork me on GitHub