diff --git a/cameo/api/__init__.py b/cameo/api/__init__.py index 33531618a..e18a73002 100644 --- a/cameo/api/__init__.py +++ b/cameo/api/__init__.py @@ -19,17 +19,21 @@ # logger.info('Initializing cameo advanced programming interface. Be patient this might take a while ...') import os -import gzip import cPickle as pickle import cameo -# with gzip.open(os.path.join(cameo._cameo_data_path, 'metanetx.pgz')) as f: -# _METANETX = pickle.load(f) +import logging +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) -with open(os.path.join(cameo._cameo_data_path, 'metanetx.pickle')) as f: - _METANETX = pickle.load(f) +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +if not on_rtd: + with open(os.path.join(cameo._cameo_data_path, 'metanetx.pickle')) as f: + _METANETX = pickle.load(f) +else: + # Mock this for RTD + _METANETX = dict([(key, None) for key in ['chem_prop', 'universal_model', 'bigg2mnx', 'mnx2bigg']]) from cameo.api.hosts import hosts from cameo.api.designer import design from cameo.api.products import products - diff --git a/docs/conf.py b/docs/conf.py index 6bae4e02f..7ab35be20 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ def __getattr__(cls, name): MOCK_MODULES = ['numpy', 'numpy.random', 'matplotlib', 'pandas', 'scipy', 'scipy.sparse', 'scipy.io', 'scipy.stats', 'scipy.version', 'bokeh', 'bokeh.plotting', 'swiglpk', - 'glpk', 'gurobipy', 'gurobipy.GRB', 'cplex', 'mlabwrap', 'pp', 'libsbml'] + 'glpk', 'gurobipy', 'gurobipy.GRB', 'cplex', 'mlabwrap', 'pp', 'libsbml', 'METANETX', '_METANETX'] sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) # If extensions (or modules to document with autodoc) are in another directory,