Import error when trying to build the docs

Hi, I’m having trouble setting up my dev environment for ray. That is, building ray for Python dev worked as described here: Building Ray from Source — Ray v2.0.0.dev0

But building the docs does not work and always fails with an import error when running make html:

Warning, treated as error:
autodoc: failed to import function 'rllib.utils.annotations.PublicAPI' from module 'ray'; the following exception was raised:
No module named 'ray.rllib'

I have ray installed inside a virtualenv on WSL2 (Ubuntu 20, Python 3.8) and inside the Python shell from ray.rllib.utils.annotations import PublicAPI works without problems.

Any idea what’s the issue here and how to resolve it? Just in case I make changes to the docs, I’d like to inspect them locally first.
My guess is that it’s some issue with the make command not using my version ray installed inside my virtualenv, even though, I’m executing make after activating the virtualenv.

I usually use a separate environment for building docs.

I create a new virtual env, and then run those pip install commands for doc requirements. I do not install ray actually for that environment. Maybe you could try that?

That makes sense and I tried it just now: Created a fresh virtualenv just for building the docs.
I followed the setup guide here: Building Ray from Source — Ray v2.0.0.dev0
So, I ran

cd doc
pip install -r requirements-doc.txt
pip install -U -r requirements-rtd.txt # important for reproducing the deployment environment
make html

The installation went fine but make html breaks with the same error as before:

Warning, treated as error:
autodoc: failed to import function 'rllib.utils.annotations.PublicAPI' from module 'ray'; the following exception was raised:
No module named 'ray.rllib'
make: *** [Makefile:57: html] Error 2

Do I need to deviate from the described process somehow? Seems like make html does require ray and doesn’t find it for some reason.

Any ideas?

Hey @stefanbschneider , the above works all fine on my Mac with py3.8:

conda create -n ray_docs python=3.8
conda activate ray_docs
cd doc
pip install -r requirements-doc.txt
pip install -U -r requirements-rtd.txt
make html

I do get an error, though, when I try: python; from ray import rllib, which makes sense.
Just out of curiosity, could you try doing this pip install ray[rllib] before building the docs?

Hm. I installed ray[rllib] and tried again (python; from ray import rllib works from within my virtualenv), but I still get the same error (here in full):

(venv-docs) stefan@.../ray/doc$ make html
sphinx-build -W -b html -d _build/doctrees   source _build/html
Running Sphinx v3.0.4
generating gallery...
Using Sphinx-Gallery to convert rst text blocks to markdown for .ipynb files.
generating gallery for auto_examples... [100%] plot_pong_example.py
generating gallery for tune/tutorials... [100%] tune-serve-integration-mnist.py
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 192 source files that are out of date
updating environment: [new config] 192 added, 0 changed, 0 removed
reading sources... [100%] xgboost-ray

Warning, treated as error:
autodoc: failed to import function 'rllib.utils.annotations.PublicAPI' from module 'ray'; the following exception was raised:
No module named 'ray.rllib'
make: *** [Makefile:57: html] Error 2

To me it seems like Sphinx is somehow not using my ray[rllib] installation from within the activated virtualenv (made with virtualenv --python=python3 venv-docs).

For now, it’s not too important and not blocking at all since I don’t have any doc changes planned yet. I can check this again in more detail, once I really need it.