-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
[Doc] Use autodoc_mock_imports to mock deps for sphinx builds #38817
[Doc] Use autodoc_mock_imports to mock deps for sphinx builds #38817
Conversation
32b584a
to
0e90f69
Compare
0e90f69
to
75c215d
Compare
75c215d
to
42f6c3b
Compare
There are some differences between this PR and the current And here's this branch: I'm going to spend a bit longer scanning the differences to see if there's anything bad here. @angelinalg if you have time, I'd appreciate feedback as well. |
401e96b
to
65bd69f
Compare
Signed-off-by: pdmurray <peynmurray@gmail.com>
82c5704
to
33cd701
Compare
@peytondmurray this looks great, thanks so much! we should merge this asap, once we removed the rtd build issues. |
5b6c060
to
22e4ce6
Compare
Signed-off-by: pdmurray <peynmurray@gmail.com>
22e4ce6
to
c4a5eaf
Compare
Signed-off-by: pdmurray <peynmurray@gmail.com>
Okay, the RTD build is now working - I had to make sure not to import ray in |
Signed-off-by: pdmurray <peynmurray@gmail.com>
After a discussion with @maxpumperla I'm marking this as ready for review. We still are doing ad-hoc mocking of compiled ray modules, which still display as Future effort: sphinx-doc/sphinx#4413 should allow us to put |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, approving pending a green CI run and the comment below.
Signed-off-by: pdmurray <peynmurray@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -65,7 +65,7 @@ make linkcheck | |||
To run tests for examples shipping with docstrings in Python files, run the following command: | |||
|
|||
```shell | |||
RAY_MOCK_MODULES=0 make doctest | |||
make doctest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this section or replace it with the information in How to write code snippets. We don't use make doctest
anymore.
…oject#38817) This PR is the first in a series needed to update Sphinx to the latest version. In this PR, we - Remove a lot of external dependencies that aren't necessary for building the docs. The one exception to this is tune-sklearn, a project owned by ray-project which actually does have documentation hosted on the Ray docs site. - External dependencies are now mocked out using Sphinx's autodoc_mock_imports mechanism, which is used by both autodoc and autosummary. The old module mocking mechanism has been removed in favor of this. The one exception to this is packaging.version.Version: Ray currently uses Version to modify some behaviors depending on the version of certain dependencies that the user has installed. --------- Signed-off-by: pdmurray <peynmurray@gmail.com> Co-authored-by: Max Pumperla <max.pumperla@googlemail.com> Signed-off-by: Gene Su <e870252314@gmail.com>
#39485) This PR is the first in a series needed to update Sphinx to the latest version. In this PR, we - Remove a lot of external dependencies that aren't necessary for building the docs. The one exception to this is tune-sklearn, a project owned by ray-project which actually does have documentation hosted on the Ray docs site. - External dependencies are now mocked out using Sphinx's autodoc_mock_imports mechanism, which is used by both autodoc and autosummary. The old module mocking mechanism has been removed in favor of this. The one exception to this is packaging.version.Version: Ray currently uses Version to modify some behaviors depending on the version of certain dependencies that the user has installed. --------- Signed-off-by: pdmurray <peynmurray@gmail.com> Signed-off-by: Gene Su <e870252314@gmail.com> Co-authored-by: Peyton Murray <peynmurray@gmail.com> Co-authored-by: Max Pumperla <max.pumperla@googlemail.com>
…oject#38817) This PR is the first in a series needed to update Sphinx to the latest version. In this PR, we - Remove a lot of external dependencies that aren't necessary for building the docs. The one exception to this is tune-sklearn, a project owned by ray-project which actually does have documentation hosted on the Ray docs site. - External dependencies are now mocked out using Sphinx's autodoc_mock_imports mechanism, which is used by both autodoc and autosummary. The old module mocking mechanism has been removed in favor of this. The one exception to this is packaging.version.Version: Ray currently uses Version to modify some behaviors depending on the version of certain dependencies that the user has installed. --------- Signed-off-by: pdmurray <peynmurray@gmail.com> Co-authored-by: Max Pumperla <max.pumperla@googlemail.com> Signed-off-by: Jim Thompson <jimthompson5802@gmail.com>
…oject#38817) This PR is the first in a series needed to update Sphinx to the latest version. In this PR, we - Remove a lot of external dependencies that aren't necessary for building the docs. The one exception to this is tune-sklearn, a project owned by ray-project which actually does have documentation hosted on the Ray docs site. - External dependencies are now mocked out using Sphinx's autodoc_mock_imports mechanism, which is used by both autodoc and autosummary. The old module mocking mechanism has been removed in favor of this. The one exception to this is packaging.version.Version: Ray currently uses Version to modify some behaviors depending on the version of certain dependencies that the user has installed. --------- Signed-off-by: pdmurray <peynmurray@gmail.com> Co-authored-by: Max Pumperla <max.pumperla@googlemail.com> Signed-off-by: Victor <vctr.y.m@example.com>
Why are these changes needed?
This PR is the first in a series needed to update Sphinx to the latest version. In this PR, we
tune-sklearn
, a project owned by ray-project which actually does have documentation hosted on the Ray docs site.autodoc_mock_imports
mechanism, which is used by bothautodoc
andautosummary
. The old module mocking mechanism has been removed in favor of this. The one exception to this ispackaging.version.Version
: Ray currently usesVersion
to modify some behaviors depending on the version of certain dependencies that the user has installed. For example, inpython/ray/train/torch/train_loop_utils.py
:During the Sphinx build, if
torch
is mocked out,torch.__version__
is not a string, it's aMock
object, which is not a valid argument forpackaging.version.Version
- the build will fail. Althoughpackaging
is an external dependency and therefore should be mocked out usingautodoc_mock_modules
, Sphinx itself depends on it, and during the documentation build step the module is already loaded by the timeconf.py
gets executed, and therefore can't be mocked out in the usual way. I've added a dummy class which correctly handlesMock
objects that get passed to it during documentation builds. I've also added a check for any module specified inautodoc_mock_modules
to ensure that mock targets aren't yet loaded whenconf.py
is executed, which hopefully saves the next person to touch this a lot of pain.Related issue number
Partially addresses #37944.
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.