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
LocalModelIndex
RemoteModelIndex
- class macsypy.package.RemoteModelIndex(*args, **kwargs)[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
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 TODO
- __weakref__
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.
- 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:
- property metadata: dict[slice(<class 'str'>, <class 'str'>, None)]
- Returns:
The parsed metadata as a dict