multiply-org / prior-engine

GNU General Public License v3.0
0 stars 6 forks source link

Fix auto documentation #40

Closed tramsauer closed 5 years ago

tramsauer commented 5 years ago

Sphinx auto-doc of modules is not working on ReadTheDocs:

WARNING: autodoc: failed to import module 'vegetation_prior_creator' from module 'multiply_prior_engine'; the following exception was raised:
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/multiply-core/conda/doc/lib/python3.6/site-packages/sphinx/ext/autodoc/importer.py", line 154, in import_module
    __import__(modname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/multiply-core/checkouts/doc/docs/prior-engine/multiply_prior_engine/__init__.py", line 27, in <module>
    PriorLogger(level='debug', handlers=['console'])
  File "/home/docs/checkouts/readthedocs.org/user_builds/multiply-core/checkouts/doc/docs/prior-engine/multiply_prior_engine/prior_logger.py", line 50, in __init__
    config_dict['handlers']['file']['filename'] = filename
TypeError: 'Mock' object is not subscriptable

This fails for all prior-engine modules, not only for vegetation_prior_creator.

I understand that not all python modules are installed on readthedocs but many are 'mocked'/mimicked, hence config_dict as being a mocked object from config_dict = yaml.load(..) is not subscriptable. Does this problem only occur because the PriorLogger is placed in the __init.py__ file and hence is loaded(/executed?) even for gathering the auto-doc? @TonioF do you have experience with this?

TonioF commented 5 years ago

This one seems to be complicated. I can build the docs on my local computer and they look fine. The autodoc build of only the Prior Engine fails also, but that is because numpy is not found (so probably it just needs to be added as mock).

One solution here would be to remove the prior logger initiatialization from the init.py . I can't help but feel that there must be another, more flexible solution, but this would include some try and error.

TonioF commented 5 years ago

See also #41

tramsauer commented 5 years ago

solved with the new readthedocs.yml file and installing with conda.