modelforge.utils.io

Module for handling importing external libraries that are optional dependencies.

The general approach here is to wrap an import in a try/except structure, where failure to import a module results in a descriptive message being printed to the console, e.g., providing a description of how to install.

This is useful for cases where a module is not required for the core functionality of the code, and thus is not included as a base dependency in conda. This is also useful for helping users install packages that are only available via pip (and thus would not be installed in the conda release).

The approach taken here is adapted from MDTraj’s delay_import module. MDTraj is released under GNU 2.1 license; see <http://www.gnu.org/licenses/>

Functions

check_import(module)

This tries to import a given module.

get_path_string(module)

Get the path as a string to an imported module.

import_(module)

Import a module or print a descriptive message and raise an ImportError

parse_devices(value)

Parse the devices argument which can be either a single integer or a list of integers.