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.


class macsypy.package.AbstractModelIndex(cache: str = '')[source]

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

__init__(cache: str = '')[source]
static __new__(cls, *args, **kwargs)[source]

Create and return a new object. See help(type) for accurate signature.


list of weak references to the object (if defined)

unarchive_package(path: str) → str[source]

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

Parameters:path (str) –
Returns:The path to the package
class macsypy.package.LocalModelIndex(cache=None)[source]

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

__init__(cache=None) → None[source]
class macsypy.package.RemoteModelIndex(org: str = 'macsy-models', cache=None)[source]

This class allow to interact with ModelIndex on github

__init__(org: str = 'macsy-models', cache=None) → None[source]
Parameters:org – The name of the organization on github where are stored the models
_url_json(url: str) → Dict[KT, VT][source]

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[source]

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

  • 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

The package archive path.

get_metadata(pack_name: str, vers: str = 'latest') → Dict[KT, VT][source]

Fetch the metadata_path from a remote package

  • pack_name (str) – The package name
  • vers (str) – The package version

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][source]

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][source]

list all model packages available on a model repos :return: The list of package names.

remote_exists() → bool[source]

check if the remote exists and is an organization :return: True if the Remote url point to a github Organization, False otherwise


class macsypy.package.Package(path: str)[source]

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[source]
Parameters:path (str) – The of the package root directory

list of weak references to the object (if defined)

_check_metadata() → Tuple[List[str], List[str]][source]

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]][source]

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

_check_model_consistency() → Tuple[List[T], List[T]][source]

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

_check_structure() → Tuple[List[str], List[str]][source]

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][source]

find the README file

Returns:The path to the README file or None if there is no file.
_load_metadata() → Dict[KT, VT][source]

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

check() → Tuple[List[str], List[str]][source]

Check the QA of this package

help() → str[source]

return the content of the README file

info() → str[source]
Returns:some information about the package
Returns:The parsed metadata as a dict