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

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

__init__(cache: str | None = None) None[source]
__weakref__

list of weak references to the object

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

LocalModelIndex

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

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

__init__(cache: str | None = None) None[source]

RemoteModelIndex

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

This class allow to interact with ModelIndex on github

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

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

_url_json(url: str) dict[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 = None) str[source]

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

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

Returns

The list of package names.

remote_exists() bool[source]

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

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

path (str) – The of the package root directory

__weakref__

list of weak references to the object

_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.

Returns

_check_model_consistency() tuple[list, list][source]

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

Returns

_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() str | None[source]

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

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

The parsed metadata as a dict