[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
import urllib
|
2022-02-19 10:19:07 +01:00
|
|
|
import mock
|
|
|
|
import sys
|
2022-01-29 18:41:57 -08:00
|
|
|
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
# Note: the scipy import has to stay here, it's used implicitly down the line
|
|
|
|
import scipy.stats # noqa: F401
|
|
|
|
import scipy.linalg # noqa: F401
|
|
|
|
|
|
|
|
__all__ = [
|
2022-01-29 18:41:57 -08:00
|
|
|
"fix_xgb_lgbm_docs",
|
2022-02-19 10:19:07 +01:00
|
|
|
"mock_modules",
|
2022-01-29 18:41:57 -08:00
|
|
|
"update_context",
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
]
|
2019-09-24 15:46:56 -07:00
|
|
|
|
|
|
|
try:
|
|
|
|
FileNotFoundError
|
|
|
|
except NameError:
|
|
|
|
FileNotFoundError = IOError
|
|
|
|
|
2021-07-30 16:47:41 +02:00
|
|
|
|
|
|
|
def fix_xgb_lgbm_docs(app, what, name, obj, options, lines):
|
|
|
|
"""Fix XGBoost-Ray and LightGBM-Ray docstrings.
|
|
|
|
|
|
|
|
For ``app.connect('autodoc-process-docstring')``.
|
|
|
|
See https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html
|
|
|
|
|
|
|
|
Removes references to XGBoost ``callback_api`` and sets explicit module
|
|
|
|
references to classes and functions that are named the same way in both
|
|
|
|
XGBoost-Ray and LightGBM-Ray.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def _remove_xgboost_refs(replacements: list):
|
|
|
|
"""Remove ``callback_api`` ref to XGBoost docs.
|
|
|
|
|
|
|
|
Fixes ``undefined label: callback_api (if the link has no caption
|
|
|
|
the label must precede a section header)``
|
|
|
|
"""
|
|
|
|
if name.startswith("xgboost_ray"):
|
|
|
|
replacements.append((":ref:`callback_api`", "Callback API"))
|
|
|
|
|
|
|
|
def _replace_ray_params(replacements: list):
|
|
|
|
"""Replaces references to ``RayParams`` with module-specific ones.
|
|
|
|
|
|
|
|
Fixes ``more than one target found for cross-reference 'RayParams'``.
|
|
|
|
"""
|
|
|
|
if name.startswith("xgboost_ray"):
|
|
|
|
replacements.append(("RayParams", "xgboost_ray.RayParams"))
|
|
|
|
elif name.startswith("lightgbm_ray"):
|
|
|
|
replacements.append(("RayParams", "lightgbm_ray.RayParams"))
|
|
|
|
|
|
|
|
replacements = []
|
|
|
|
_remove_xgboost_refs(replacements)
|
|
|
|
_replace_ray_params(replacements)
|
|
|
|
if replacements:
|
|
|
|
for i, _ in enumerate(lines):
|
|
|
|
for replacement in replacements:
|
|
|
|
lines[i] = lines[i].replace(*replacement)
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Taken from https://github.com/edx/edx-documentation
|
2022-01-29 18:41:57 -08:00
|
|
|
FEEDBACK_FORM_FMT = (
|
|
|
|
"https://github.com/ray-project/ray/issues/new?"
|
|
|
|
"title={title}&labels=docs&body={body}"
|
|
|
|
)
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
def feedback_form_url(project, page):
|
|
|
|
"""Create a URL for feedback on a particular page in a project."""
|
|
|
|
return FEEDBACK_FORM_FMT.format(
|
2022-01-29 18:41:57 -08:00
|
|
|
title=urllib.parse.quote("[docs] Issue on `{page}.rst`".format(page=page)),
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
body=urllib.parse.quote(
|
|
|
|
"# Documentation Problem/Question/Comment\n"
|
|
|
|
"<!-- Describe your issue/question/comment below. -->\n"
|
|
|
|
"<!-- If there are typos or errors in the docs, feel free "
|
|
|
|
"to create a pull-request. -->\n"
|
|
|
|
"\n\n\n\n"
|
2022-01-29 18:41:57 -08:00
|
|
|
"(Created directly from the docs)\n"
|
|
|
|
),
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def update_context(app, pagename, templatename, context, doctree):
|
|
|
|
"""Update the page rendering context to include ``feedback_form_url``."""
|
2022-01-29 18:41:57 -08:00
|
|
|
context["feedback_form_url"] = feedback_form_url(app.config.project, pagename)
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
MOCK_MODULES = [
|
|
|
|
"ax",
|
|
|
|
"ax.service.ax_client",
|
|
|
|
"blist",
|
|
|
|
"ConfigSpace",
|
|
|
|
"dask.distributed",
|
|
|
|
"gym",
|
|
|
|
"gym.spaces",
|
|
|
|
"horovod",
|
|
|
|
"horovod.runner",
|
|
|
|
"horovod.runner.common",
|
|
|
|
"horovod.runner.common.util",
|
|
|
|
"horovod.ray",
|
|
|
|
"horovod.ray.runner",
|
|
|
|
"horovod.ray.utils",
|
|
|
|
"hyperopt",
|
2022-01-29 18:41:57 -08:00
|
|
|
"hyperopt.hp" "kubernetes",
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
"mlflow",
|
|
|
|
"modin",
|
|
|
|
"mxnet",
|
|
|
|
"mxnet.model",
|
|
|
|
"optuna",
|
|
|
|
"optuna.distributions",
|
|
|
|
"optuna.samplers",
|
|
|
|
"optuna.trial",
|
|
|
|
"psutil",
|
|
|
|
"ray._raylet",
|
|
|
|
"ray.core.generated",
|
|
|
|
"ray.core.generated.common_pb2",
|
|
|
|
"ray.core.generated.runtime_env_common_pb2",
|
|
|
|
"ray.core.generated.gcs_pb2",
|
|
|
|
"ray.core.generated.logging_pb2",
|
|
|
|
"ray.core.generated.ray.protocol.Task",
|
|
|
|
"ray.serve.generated",
|
|
|
|
"ray.serve.generated.serve_pb2",
|
|
|
|
"scipy.signal",
|
|
|
|
"scipy.stats",
|
|
|
|
"setproctitle",
|
|
|
|
"tensorflow_probability",
|
|
|
|
"tensorflow",
|
|
|
|
"tensorflow.contrib",
|
|
|
|
"tensorflow.contrib.all_reduce",
|
|
|
|
"tree",
|
|
|
|
"tensorflow.contrib.all_reduce.python",
|
|
|
|
"tensorflow.contrib.layers",
|
|
|
|
"tensorflow.contrib.rnn",
|
|
|
|
"tensorflow.contrib.slim",
|
|
|
|
"tensorflow.core",
|
|
|
|
"tensorflow.core.util",
|
|
|
|
"tensorflow.keras",
|
|
|
|
"tensorflow.python",
|
|
|
|
"tensorflow.python.client",
|
|
|
|
"tensorflow.python.util",
|
|
|
|
"torch",
|
2022-03-16 22:53:02 -05:00
|
|
|
"torch.cuda.amp",
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
"torch.distributed",
|
|
|
|
"torch.nn",
|
|
|
|
"torch.nn.parallel",
|
2022-03-16 22:53:02 -05:00
|
|
|
"torch.optim",
|
[train] add TorchTensorboardProfilerCallback (#22345)
The [original PR](https://github.com/ray-project/ray/pull/21864) was [reverted](https://github.com/ray-project/ray/pull/22117) because it caused `torch` (more specifically, `torch>=1.8.1`) to be required to use `ray.train`.
```
| File "ray_sgd_training.py", line 18, in <module>
| from ray import train
| File "/home/ray/anaconda3/lib/python3.7/site-packages/ray/train/__init__.py", line 2, in <module>
| from ray.train.callbacks import TrainingCallback
| File "/home/ray/anaconda3/lib/python3.7/site-packages/ray/train/callbacks/__init__.py", line 8, in <module>
| from ray.train.callbacks.profile import TorchTensorboardProfilerCallback
| File "/home/ray/anaconda3/lib/python3.7/site-packages/ray/train/callbacks/profile.py", line 6, in <module>
| from torch.profiler import profile
| ModuleNotFoundError: No module named 'torch.profiler'
```
A [minimal installation test suite](https://github.com/ray-project/ray/pull/22300) was added to detect this. Further, in this PR we make the following changes:
1. Move `TorchWorkerProfiler` to `ray.train.torch` so all torch imports are centralized.
2. Add import validation logic to `TorchWorkerProfiler.__init__` so an exception will only be raised if the user tries to initialize a `TorchWorkerProfiler` without having a valid version of `torch` installed:
```
>>> import ray
>>> import ray.train
>>> import ray.train.torch
>>> from ray.train.torch import TorchWorkerProfiler
>>> twp = TorchWorkerProfiler()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/matt/workspace/ray/python/ray/train/torch.py", line 365, in __init__
"Torch Profiler requires torch>=1.8.1. "
ImportError: Torch Profiler requires torch>=1.8.1. Run `pip install 'torch>=1.8.1'` to use TorchWorkerProfiler.
```
2022-02-14 16:16:55 -08:00
|
|
|
"torch.profiler",
|
[docs] new structure (#21776)
This PR consolidates both #21667 and #21759 (look there for features), but improves on them in the following way:
- [x] we reverted renaming of existing projects `tune`, `rllib`, `train`, `cluster`, `serve`, `raysgd` and `data` so that links won't break. I think my consolidation efforts with the `ray-` prefix were a little overeager in that regard. It's better like this. Only the creation of `ray-core` was a necessity, and some files moved into the `rllib` folder, so that should be relatively benign.
- [x] Additionally, we added Algolia `docsearch`, screenshot below. This is _much_ better than our current search. Caveat: there's a sphinx dependency that needs to be replaced (`sphinx-tabs`) by another, newer one (`sphinx-panels`), as the former prevents loading of the `algolia.js` library. Will follow-up in the next PR (hoping this one doesn't get re-re-re-re-reverted).
2022-01-22 00:42:05 +01:00
|
|
|
"torch.utils.data",
|
|
|
|
"torch.utils.data.distributed",
|
|
|
|
"wandb",
|
|
|
|
"zoopt",
|
|
|
|
]
|
|
|
|
|
|
|
|
CHILD_MOCK_MODULES = [
|
|
|
|
"pytorch_lightning",
|
|
|
|
"pytorch_lightning.accelerators",
|
|
|
|
"pytorch_lightning.plugins",
|
|
|
|
"pytorch_lightning.plugins.environments",
|
|
|
|
"pytorch_lightning.utilities",
|
|
|
|
"tensorflow.keras.callbacks",
|
|
|
|
]
|
2022-02-19 10:19:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ChildClassMock(mock.Mock):
|
|
|
|
@classmethod
|
|
|
|
def __getattr__(cls, name):
|
|
|
|
return mock.Mock
|
|
|
|
|
|
|
|
|
|
|
|
def mock_modules():
|
|
|
|
for mod_name in MOCK_MODULES:
|
|
|
|
sys.modules[mod_name] = mock.Mock()
|
|
|
|
|
|
|
|
sys.modules["tensorflow"].VERSION = "9.9.9"
|
|
|
|
|
|
|
|
for mod_name in CHILD_MOCK_MODULES:
|
|
|
|
sys.modules[mod_name] = ChildClassMock()
|