forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf.py
437 lines (357 loc) · 14.2 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# -*- coding: utf-8 -*-
from datetime import datetime
from pathlib import Path
from importlib import import_module
import os
import sys
from jinja2.filters import FILTERS
sys.path.insert(0, os.path.abspath("."))
from custom_directives import (
DownloadAndPreprocessEcosystemDocs,
mock_modules,
update_context,
LinkcheckSummarizer,
build_gallery,
)
# Mocking modules allows Sphinx to work without installing Ray.
mock_modules()
assert (
"ray" not in sys.modules
), "If ray is already imported, we will not render documentation correctly!"
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("../../python/"))
import ray
# -- General configuration ------------------------------------------------
# The name of a reST role (builtin or Sphinx extension) to use as the default role, that
# is, for text marked up `like this`. This can be set to 'py:obj' to make `filter` a
# cross-reference to the Python function “filter”. The default is None, which doesn’t
# reassign the default role.
default_role = "py:obj"
sys.path.append(os.path.abspath("./_ext"))
extensions = [
"callouts", # custom extension from _ext folder
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx_click.ext",
"sphinx-jsonschema",
"sphinxemoji.sphinxemoji",
"sphinx_copybutton",
"versionwarning.extension",
"sphinx_sitemap",
"myst_nb",
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx.ext.autosummary",
"sphinx_external_toc",
"sphinxcontrib.autodoc_pydantic",
"sphinxcontrib.redoc",
"sphinx_tabs.tabs",
"sphinx_remove_toctrees",
"sphinx_design",
"sphinx.ext.intersphinx",
]
# Prune deep toc-trees on demand for smaller html and faster builds.
# This only effects the navigation bar, not the content.
if os.getenv("FAST", False):
remove_from_toctrees = [
"data/api/doc/*",
"ray-air/api/doc/*",
"ray-core/api/doc/*",
"ray-observability/api/state/doc/*",
"serve/api/doc/*",
"train/api/doc/*",
"tune/api/doc/*",
"workflows/api/doc/*",
"cluster/running-applications/job-submission/doc/*",
"serve/production-guide/*",
"serve/tutorials/deployment-graph-patterns/*",
"rllib/package_ref/env/*",
"rllib/package_ref/policy/*",
"rllib/package_ref/evaluation/*",
"rllib/package_ref/utils/*",
"workflows/api/*",
"cluster/kubernetes/user-guides/*",
"cluster/kubernetes/examples/*",
"cluster/vms/user-guides/*",
"cluster/running-applications/job-submission/*",
"ray-core/actors/*",
"ray-core/objects/*",
"ray-core/scheduling/*",
"ray-core/tasks/*",
"ray-core/patterns/*",
"tune/examples/*",
]
myst_enable_extensions = [
"dollarmath",
"amsmath",
"deflist",
"html_admonition",
"html_image",
"colon_fence",
"smartquotes",
"replacements",
]
intersphinx_mapping = {
"sklearn": ("https://scikit-learn.org/stable/", None),
}
# Cache notebook outputs in _build/.jupyter_cache
# To prevent notebook execution, set this to "off". To force re-execution, set this to "force".
# To cache previous runs, set this to "cache".
jupyter_execute_notebooks = os.getenv("RUN_NOTEBOOKS", "off")
external_toc_exclude_missing = False
external_toc_path = "_toc.yml"
html_extra_path = ["robots.txt"]
html_baseurl = "https://docs.ray.io/en/latest"
# This pattern matches:
# - Python Repl prompts (">>> ") and it's continuation ("... ")
# - Bash prompts ("$ ")
# - IPython prompts ("In []: ", "In [999]: ") and it's continuations
# (" ...: ", " : ")
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
copybutton_prompt_is_regexp = True
# By default, tabs can be closed by selecting an open tab. We disable this
# functionality with the `sphinx_tabs_disable_tab_closing` option.
sphinx_tabs_disable_tab_closing = True
# There's a flaky autodoc import for "TensorFlowVariables" that fails depending on the doc structure / order
# of imports.
# autodoc_mock_imports = ["ray.experimental.tf_utils"]
# This is used to suppress warnings about explicit "toctree" directives.
suppress_warnings = ["etoc.toctree"]
versionwarning_admonition_type = "note"
versionwarning_banner_title = "Join the Ray Discuss Forums!"
FORUM_LINK = "https://discuss.ray.io"
versionwarning_messages = {
# Re-enable this after Ray Summit.
# "latest": (
# "This document is for the latest pip release. "
# 'Visit the <a href="/en/master/">master branch documentation here</a>.'
# ),
# "master": (
# "<b>Got questions?</b> Join "
# f'<a href="{FORUM_LINK}">the Ray Community forum</a> '
# "for Q&A on all things Ray, as well as to share and learn use cases "
# "and best practices with the Ray community."
# ),
}
versionwarning_body_selector = "#main-content"
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "Ray"
copyright = str(datetime.now().year) + ", The Ray Team"
author = "The Ray Team"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
from ray import __version__ as version
# The full version, including alpha/beta/rc tags.
release = version
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# Also helps resolve warnings about documents not included in any toctree.
exclude_patterns = [
"templates/*",
"cluster/running-applications/doc/ray.*",
]
# If "DOC_LIB" is found, only build that top-level navigation item.
build_one_lib = os.getenv("DOC_LIB")
all_toc_libs = [f.path for f in os.scandir(".") if f.is_dir() and "ray-" in f.path]
all_toc_libs += [
"cluster",
"tune",
"data",
"train",
"rllib",
"serve",
"workflows",
]
if build_one_lib and build_one_lib in all_toc_libs:
all_toc_libs.remove(build_one_lib)
exclude_patterns += all_toc_libs
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "lovelace"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# Do not check anchors for links because it produces many false positives
# and is slow (it needs to download the linked website).
linkcheck_anchors = False
# Only check external links, i.e. the ones starting with http:https:// or https://.
linkcheck_ignore = [
r"^((?!http).)*$", # exclude links not starting with http
"http:https://ala2017.it.nuigalway.ie/papers/ALA2017_Gupta.pdf", # broken
"https://mvnrepository.com/artifact/*", # working but somehow not with linkcheck
# This should be fixed -- is temporal the successor of cadence? Do the examples need to be updated?
"https://github.com/serverlessworkflow/specification/blob/main/comparisons/comparison-cadence.md",
# TODO(richardliaw): The following probably needs to be fixed in the tune_sklearn package
"https://scikit-optimize.github.io/stable/modules/",
"https://www.oracle.com/java/technologies/javase-jdk15-downloads.html", # forbidden for client
"https://speakerdeck.com/*", # forbidden for bots
r"https://huggingface.co/*", # seems to be flaky
r"https://www.meetup.com/*", # seems to be flaky
r"https://www.pettingzoo.ml/*", # seems to be flaky
r"http:https://localhost[:/].*", # Ignore localhost links
r"^http:/$", # Ignore incomplete links
# 403 Client Error: Forbidden for url.
# They ratelimit bots.
"https://www.datanami.com/2018/02/01/rays-new-library-targets-high-speed-reinforcement-learning/",
# 403 Client Error: Forbidden for url.
# They ratelimit bots.
"https://www.researchgate.net/publication/222573328_Stochastic_Gradient_Boosting",
"https://www.datanami.com/2019/11/05/why-every-python-developer-will-love-ray/",
"https://dev.mysql.com/doc/connector-python/en/",
# Returning 522s intermittently.
"https://lczero.org/",
# Returns 429 errors in Linkcheck due to too many requests
"https://archive.is/2022.12.16-171259/https://www.businessinsider.com/openai-chatgpt-trained-on-anyscale-ray-generative-lifelike-ai-models-2022-12",
# Returns 406 but remains accessible
"https://www.uber.com/blog/elastic-xgboost-ray/",
]
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_book_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"repository_url": "https://github.com/ray-project/ray",
"use_repository_button": True,
"use_issues_button": True,
"use_edit_page_button": True,
"path_to_docs": "doc/source",
"home_page_in_toc": True,
"show_navbar_depth": 1,
"announcement": "<div class='topnav'></div>",
}
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = f"Ray {release}"
# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "_static/favicon.ico"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# Output file base name for HTML help builder.
htmlhelp_basename = "Raydoc"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
latex_documents = [
(master_doc, "Ray.tex", "Ray Documentation", author, "manual"),
]
# -- Options for manual page output ---------------------------------------
man_pages = [(master_doc, "ray", "Ray Documentation", [author], 1)]
# -- Options for Texinfo output -------------------------------------------
texinfo_documents = [
(
master_doc,
"Ray",
"Ray Documentation",
author,
"Ray",
"Ray provides a simple, universal API for building distributed applications.",
"Miscellaneous",
),
]
# Python methods should be presented in source code order
autodoc_member_order = "bysource"
# Better typehint formatting (see custom.css)
autodoc_typehints = "signature"
def filter_out_undoc_class_members(member_name, class_name, module_name):
module = import_module(module_name)
cls = getattr(module, class_name)
if getattr(cls, member_name).__doc__:
return f"~{class_name}.{member_name}"
else:
return ""
FILTERS["filter_out_undoc_class_members"] = filter_out_undoc_class_members
# Add a render priority for doctest
nb_render_priority = {
"doctest": (),
"html": (
"application/vnd.jupyter.widget-view+json",
"application/javascript",
"text/html",
"image/svg+xml",
"image/png",
"image/jpeg",
"text/markdown",
"text/latex",
"text/plain",
),
}
def setup(app):
# NOTE: 'MOCK' is a custom option we introduced to illustrate mock outputs. Since
# `doctest` doesn't support this flag by default, `sphinx.ext.doctest` raises
# warnings when we build the documentation.
import doctest
doctest.register_optionflag("MOCK")
app.connect("html-page-context", update_context)
# Custom CSS
app.add_css_file("css/custom.css", priority=800)
app.add_css_file(
"https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css"
)
# https://github.com/ines/termynal
app.add_css_file("css/termynal.css")
# Custom JS
app.add_js_file(
"https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js",
defer="defer",
)
app.add_js_file("js/docsearch.js", defer="defer")
app.add_js_file("js/csat.js", defer="defer")
# https://github.com/ines/termynal
app.add_js_file("js/termynal.js", defer="defer")
app.add_js_file("js/custom.js", defer="defer")
app.add_js_file("js/top-navigation.js", defer="defer")
base_path = Path(__file__).parent
github_docs = DownloadAndPreprocessEcosystemDocs(base_path)
# Download docs from ecosystem library repos
app.connect("builder-inited", github_docs.write_new_docs)
# Restore original file content after build
app.connect("build-finished", github_docs.write_original_docs)
# Hook into the logger used by linkcheck to display a summary at the end.
linkcheck_summarizer = LinkcheckSummarizer()
app.connect("builder-inited", linkcheck_summarizer.add_handler_to_linkcheck)
app.connect("build-finished", linkcheck_summarizer.summarize)
# Create galleries on the fly
app.connect("builder-inited", build_gallery)
# tag filtering system
app.add_js_file("js/tags.js")
redoc = [
{
"name": "Ray Jobs API",
"page": "cluster/running-applications/job-submission/api",
"spec": "cluster/running-applications/job-submission/openapi.yml",
"embed": True,
},
]
redoc_uri = "https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"
autosummary_filename_map = {
"ray.serve.deployment": "ray.serve.deployment_decorator",
"ray.serve.Deployment": "ray.serve.Deployment",
}