Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow documentation to be build without installing and configuring AiiDA #3669

Merged
merged 2 commits into from
Dec 15, 2019

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Dec 14, 2019

Fixes #3390 and fixes #2263

I took PR #3607 as a base. First I reinstated the (unintentionally removed) loading of the Sphinx theme when building the documentation locally. Then I put one commit on top, see commit message for details. Effectively this provides a single function in the docs conf.py that fully loads a dummy environment. This is a bit more verbose than the solution proposed by @ltalirz but this removes a lot of code from the main code base that is just there to be able to build the documentation without installation. I feel this does not belong there and should instead be in the documentation configuration. Plugins can simply copy this function and call it to copy the behavior.

In addition, this approach now also fixes another issue that required a profile with a django backend to be present locally in order to build the docs. This is no longer necessary and also locally one does not even have to have a profile installed.

@sphuber sphuber requested a review from ltalirz December 14, 2019 10:38
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sphuber !
To me, this looks great - except for one detail: load_documentation_profile should be part of aiida core.

I don't think it's a good idea to have plugin developers copy this code, which uses AiiDA internals that might change.


# If we are not on READTHEDOCS load the Sphinx theme manually
if not os.environ.get('READTHEDOCS', None):
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/except should not be needed here since we have the package in the docs dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ltalirz
Copy link
Member

ltalirz commented Dec 14, 2019

I would put it in aiida.manage.configuration and not expose it on the top level.

@sphuber sphuber force-pushed the fix_2263_build_docs_dummy_profile branch from dfe458b to b091030 Compare December 14, 2019 12:44
@sphuber
Copy link
Contributor Author

sphuber commented Dec 14, 2019

I would put it in aiida.manage.configuration and not expose it on the top level.

Of fair enough, I have moved the function into aiida.manage.configuration

ltalirz and others added 2 commits December 14, 2019 18:26
So far, importing aiida would directly create a config file. Such side
effects can have problematic consequences e.g. if the default path that
AiiDA chooses is not writeable. It also means that you pollute your file
system just by importing the package. This PR moves the creation of the
config file (if necessary) into the `load_profile` function, which is
anyhow called e.g. by the `verdi` command line. The same goes for the
configuration of the logger.
To compile the documentation, the code has to be imported which includes
the Django database models. Unfortunately, Django will raise here if it
has not been configured. Normally this is done through the backend which
will load the backend environment for the currently loaded AiiDA profile.
Since on readthedocs.org AiiDA is not installed and so there won't be a
configuration with a profile to load, the profile management code was
monkey patched to provide a dummy profile just for this purpose.

Instead of cluttering the main codebase for this one exception, we move
the responsibility to the documentation configuration itself. The
requirements boil down to the Django settings being called and an AiiDA
configuration and profile to be loaded. Since loading a profile with a
django backend and loading said backend, the former will be accomplished
automatically. This will now also allow building the documentation
locally even if the default profile is not using a Django backend
because the dummy documentation profile will simply be used. The function
`aiida.manage.configuration.load_documentation_profile` performs all the
required actions.
@sphuber sphuber force-pushed the fix_2263_build_docs_dummy_profile branch from b091030 to f51c231 Compare December 14, 2019 17:26
@sphuber sphuber requested a review from ltalirz December 14, 2019 17:27
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sphuber !
I just restarted the builds - there was an issue on PyPI that should be resolved now https://status.python.org/#past-incidents

@sphuber sphuber merged commit e46997e into develop Dec 15, 2019
@sphuber sphuber deleted the fix_2263_build_docs_dummy_profile branch December 15, 2019 10:50
@sphuber sphuber mentioned this pull request Dec 15, 2019
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

interface for loading dummy profile Docs failed to make when the default profile has SQLA backend
2 participants