[docs] Revert #16919 and fix documentation build (#17270)

This commit is contained in:
Richard Liaw 2021-07-22 13:03:38 -07:00 committed by GitHub
parent e5925daed3
commit 2ce73ce843
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 63 deletions

View file

@ -99,58 +99,8 @@ sys.modules["tensorflow"].VERSION = "9.9.9"
sys.modules["tensorflow.keras.callbacks"] = ChildClassMock()
sys.modules["pytorch_lightning"] = ChildClassMock()
def import_or_mock(module):
try:
# Same as `import module`
__import__(module, globals(), locals(), [], 0)
except ImportError:
sys.modules[module] = ChildClassMock()
xgb_lgbm_modules = [
"xgboost", "xgboost.core", "xgboost.callback", "xgboost.sklearn",
"xgboost_ray", "lightgbm.main", "lightgbm.callback", "lightgbm.compat",
"lightgbm_ray"
]
for module in xgb_lgbm_modules:
import_or_mock(module)
# replace docstring refs in XGBoost documentation XGBoost-Ray inherits from
# if this is not done, an error during make will be thrown, as there is no
# such ref in ray docs
replaces_callback_api = [
sys.modules["xgboost_ray"].RayXGBClassifier.fit,
sys.modules["xgboost_ray"].RayXGBRegressor.fit
]
for m in replaces_callback_api:
m.__doc__ = m.__doc__.replace(":ref:`callback_api`", "Callback API")
# fix "more than one target found for cross-reference 'RayParams'"
# as both lightgbm-ray and xgboost-ray have classes with the same
# names, we need to refer to the explicitly in ray docs, otherwise
# make will throw an error
replaces_ray_params = [
sys.modules["xgboost_ray"].train, sys.modules["xgboost_ray"].predict,
sys.modules["xgboost_ray"].RayXGBClassifier.fit,
sys.modules["xgboost_ray"].RayXGBClassifier.predict,
sys.modules["xgboost_ray"].RayXGBClassifier.predict_proba,
sys.modules["xgboost_ray"].RayXGBRegressor.fit,
sys.modules["xgboost_ray"].RayXGBRegressor.predict
]
for m in replaces_ray_params:
m.__doc__ = m.__doc__.replace("RayParams", "xgboost_ray.RayParams")
replaces_ray_params = [
sys.modules["lightgbm_ray"].train, sys.modules["lightgbm_ray"].predict,
sys.modules["lightgbm_ray"].RayLGBMClassifier.fit,
sys.modules["lightgbm_ray"].RayLGBMClassifier.predict,
sys.modules["lightgbm_ray"].RayLGBMClassifier.predict_proba,
sys.modules["lightgbm_ray"].RayLGBMRegressor.fit,
sys.modules["lightgbm_ray"].RayLGBMRegressor.predict
]
for m in replaces_ray_params:
m.__doc__ = m.__doc__.replace("RayParams", "lightgbm_ray.RayParams")
assert "ray" not in sys.modules, (
"If ray is already imported, we will not render documentation correctly!")
class SimpleClass(object):

View file

@ -531,8 +531,8 @@ the `examples folder <https://github.com/ray-project/lightgbm_ray/tree/master/ex
API reference
-------------
.. autoclass:: lightgbm_ray.RayParams
:members:
.. .. autoclass:: lightgbm_ray.RayParams
.. :members:
.. autoclass:: xgboost_ray.RayDMatrix
:members:

View file

@ -611,14 +611,14 @@ API reference
scikit-learn API
^^^^^^^^^^^^^^^^
.. autoclass:: xgboost_ray.RayXGBClassifier
:members:
.. .. autoclass:: xgboost_ray.RayXGBClassifier
.. :members:
.. autoclass:: xgboost_ray.RayXGBRegressor
:members:
.. .. autoclass:: xgboost_ray.RayXGBRegressor
.. :members:
.. autoclass:: xgboost_ray.RayXGBRFClassifier
:members:
.. .. autoclass:: xgboost_ray.RayXGBRFClassifier
.. :members:
.. autoclass:: xgboost_ray.RayXGBRFRegressor
:members:
.. .. autoclass:: xgboost_ray.RayXGBRFRegressor
.. :members: