# 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(*args, **kwargs)

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

  __init__(cache: str = '')
  static __new__(cls, *args, **kwargs)
  __weakref__

    list of weak references to the object (if defined)

  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(*args, **kwargs)

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

  __init__(cache=None) → None

## RemoteModelIndex

class macsypy.package.RemoteModelIndex(*args, **kwargs)

  This class allow to interact with ModelIndex on github

  __init__(org: str = 'macsy-models', cache=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) → 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 exists 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 contains at least - a subdirectory definitions - a subdirectory profiles - a file metadata.yml it is also recomanded to add a file for licensing and copyright and a README. for further explanation see TODO

  __init__(path: str) → None
    Parameters

      path (str) – The of the package root directory

  __weakref__

    list of weak references to the object (if defined)

  _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() → Optional[str]

    find the README file

    Returns

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

  _load_metadata() → Dict

    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
    Returns

      The parsed metadata as a dict