Repository navigation
[doc] Convert ray-core/patterns pages to MyST Markdown - #66353
dstrodtman wants to merge 2 commits into
Conversation
Faithfully convert the 22 ray-core/patterns design-pattern and anti-pattern pages from reStructuredText to MyST Markdown. Format-only conversion: rendered HTML is preserved and every cross-reference label is kept unchanged. Also update the patterns/index toctree entry in user-guide.rst to be extensionless so it resolves to the new .md source. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
Whitespace-only reflow to Ray's one-line-per-paragraph soft-wrap convention. Verified by ray-soft-wrap verify.py: non-whitespace bytes unchanged, rendered HTML identical, transform idempotent. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request migrates various Ray Core design pattern and anti-pattern documentation files from ReStructuredText to MyST Markdown. The review feedback focuses on polishing the newly written Markdown files by correcting minor grammatical errors, improving phrasing and readability, fixing subject-verb agreement, and ensuring consistent use of MyST roles (such as {func}) throughout the documents.
|
|
||
| **TLDR:** Avoid calling {func}`ray.put() <ray.put>` on task return values and returning the resulting ObjectRefs. Instead, return these values directly if possible. | ||
|
|
||
| Returning ray.put() ObjectRefs are considered anti-patterns for the following reasons: |
|
|
||
| # Pattern: Using asyncio to run actor methods concurrently | ||
|
|
||
| By default, a Ray {ref}`actor <ray-remote-classes>` runs in a single thread and actor method calls are executed sequentially. This means that a long running method call blocks all the following ones. In this pattern, we use `await` to yield control from the long running method call so other method calls can run concurrently. Normally the control is yielded when the method is doing IO operations but you can also use `await asyncio.sleep(0)` to yield control explicitly. |
There was a problem hiding this comment.
Improve grammar, hyphenation, and phrasing for better readability and professional tone.
Suggested change:
By default, a Ray {ref}`actor <ray-remote-classes>` runs in a single thread and actor method calls are executed sequentially. This means that a long-running method call blocks all subsequent ones. In this pattern, we use `await` to yield control from the long-running method call so other method calls can run concurrently. Normally, control is yielded when the method is performing I/O operations, but you can also use `await asyncio.sleep(0)` to yield control explicitly.|
|
||
| # Anti-pattern: Forking new processes in application code | ||
|
|
||
| **Summary:** Don't fork new processes in Ray application code—for example, in driver, tasks or actors. Instead, use the "spawn" method to start new processes or use Ray tasks and actors to parallelize your workload |
There was a problem hiding this comment.
Add a missing period at the end of the summary sentence and improve phrasing.
| **Summary:** Don't fork new processes in Ray application code—for example, in driver, tasks or actors. Instead, use the "spawn" method to start new processes or use Ray tasks and actors to parallelize your workload | |
| **Summary:** Don't fork new processes in Ray application code—for example, in the driver, tasks, or actors. Instead, use the "spawn" method to start new processes or use Ray tasks and actors to parallelize your workload. |
|
|
||
| Ray manages the lifecycle of processes for you. Ray Objects, Tasks, and Actors manage sockets to communicate with the Raylet and the GCS. If you fork new processes in your application code, the processes could share the same sockets without any synchronization. This can lead to corrupted messages and unexpected behavior. | ||
|
|
||
| The solution is to: 1\. use the "spawn" method to start new processes so that the parent process's memory space is not copied to the child processes or 2\. use Ray tasks and actors to parallelize your workload and let Ray manage the lifecycle of the processes for you. |
There was a problem hiding this comment.
Since the list markers are inline within the paragraph, escaping them with backslashes (1\., 2\.) is unnecessary and can be removed for cleaner Markdown source.
| The solution is to: 1\. use the "spawn" method to start new processes so that the parent process's memory space is not copied to the child processes or 2\. use Ray tasks and actors to parallelize your workload and let Ray manage the lifecycle of the processes for you. | |
| The solution is to: 1. use the "spawn" method to start new processes so that the parent process's memory space is not copied to the child processes or 2. use Ray tasks and actors to parallelize your workload and let Ray manage the lifecycle of the processes for you. |
|
|
||
| Ray's `ray.ObjectRef` is distributed reference counted. Ray pins the underlying object until the reference isn't used by the system anymore. When all references to the pinned object are gone, Ray garbage collects the pinned object and cleans it up from the system. However, if user code serializes `ray.ObjectRef`, Ray can't keep track of the reference. | ||
|
|
||
| To avoid incorrect behavior, if `ray.cloudpickle` serializes `ray.ObjectRef`, Ray pins the object for the lifetime of a worker. "Pin" means that object can't be evicted from the object store until the corresponding owner worker dies. It's prone to Ray object leaks, which can lead to disk spilling. |
There was a problem hiding this comment.
Improve phrasing and grammar for clarity.
Suggested change:
To avoid incorrect behavior, if `ray.cloudpickle` serializes `ray.ObjectRef`, Ray pins the object for the lifetime of a worker. "Pinning" means that the object cannot be evicted from the object store until the corresponding owner worker dies. This is prone to Ray object leaks, which can lead to disk spilling.|
|
||
| **TLDR:** Avoid passing the same large argument by value to multiple tasks, use {func}`ray.put() <ray.put>` and pass by reference instead. | ||
|
|
||
| When passing a large argument (>100KB) by value to a task, Ray will implicitly store the argument in the object store and the worker process will fetch the argument to the local object store from the caller's object store before running the task. If we pass the same large argument to multiple tasks, Ray will end up storing multiple copies of the argument in the object store since Ray doesn't do deduplication. |
There was a problem hiding this comment.
Improve grammar and phrasing for better flow.
Suggested change:
When passing a large argument (>100KB) by value to a task, Ray will implicitly store the argument in the object store, and the worker process will fetch the argument into the local object store from the caller's object store before running the task. If we pass the same large argument to multiple tasks, Ray will end up storing multiple copies of the argument in the object store since Ray does not perform deduplication.|
|
||
| A call to `ray.get()` fetches the results of remotely executed functions. However, it is a blocking call, which means that it always waits until the requested result is available. If you call `ray.get()` in a loop, the loop will not continue to run until the call to `ray.get()` is resolved. | ||
|
|
||
| If you also spawn the remote function calls in the same loop, you end up with no parallelism at all, as you wait for the previous function call to finish (because of `ray.get()`) and only spawn the next call in the next iteration of the loop. The solution here is to separate the call to `ray.get()` from the call to the remote functions. That way all remote functions are spawned before we wait for the results and can run in parallel in the background. Additionally, you can pass a list of object references to `ray.get()` instead of calling it one by one to wait for all of the tasks to finish. |
There was a problem hiding this comment.
Improve phrasing and pluralization for accuracy and clarity.
Suggested change:
If you also spawn the remote function calls in the same loop, you end up with no parallelism at all, as you wait for the previous function call to finish (because of `ray.get()`) and only spawn the next call in the next iteration of the loop. The solution here is to separate the calls to `ray.get()` from the calls to the remote functions. That way, all remote functions are spawned before we wait for the results and can run in parallel in the background. Additionally, you can pass a list of object references to `ray.get()` instead of calling it for each one individually to wait for all of the tasks to finish.|
|
||
| **TLDR:** Avoid calling {func}`ray.get() <ray.get>` on too many objects since this will lead to heap out-of-memory or object store out-of-space. Instead fetch and process one batch at a time. | ||
|
|
||
| If you have a large number of tasks that you want to run in parallel, trying to do `ray.get()` on all of them at once could lead to failure with heap out-of-memory or object store out-of-space since Ray needs to fetch all the objects to the caller at the same time. Instead you should get and process the results one batch at a time. Once a batch is processed, Ray will evict objects in that batch to make space for future batches. |
There was a problem hiding this comment.
Improve phrasing and punctuation for better readability.
Suggested change:
If you have a large number of tasks that you want to run in parallel, trying to do `ray.get()` on all of them at once could lead to failures due to heap out-of-memory or object store out-of-space errors, since Ray needs to fetch all the objects to the caller at the same time. Instead, you should fetch and process the results one batch at a time. Once a batch is processed, Ray will evict objects in that batch to make space for future batches.|
|
||
| **TLDR:** Avoid redefining the same remote function or class. | ||
|
|
||
| Decorating the same function or class multiple times using the {func}`ray.remote <ray.remote>` decorator leads to slow performance in Ray. For each Ray remote function or class, Ray will pickle it and upload to GCS. Later on, the worker that runs the task or actor will download and unpickle it. Each decoration of the same function or class generates a new remote function or class from Ray's perspective. As a result, the pickle, upload, download and unpickle work will happen every time we redefine and run the remote function or class. |
There was a problem hiding this comment.
Improve phrasing, grammar, and GCS reference.
Suggested change:
Decorating the same function or class multiple times using the {func}`ray.remote <ray.remote>` decorator leads to slow performance in Ray. For each Ray remote function or class, Ray will pickle it and upload it to the GCS. Later on, the worker that runs the task or actor will download and unpickle it. Each decoration of the same function or class generates a new remote function or class from Ray's perspective. As a result, pickling, uploading, downloading, and unpickling will happen every time we redefine and run the remote function or class.## Why are these changes needed?
MyST Markdown is the standard for Ray doc pages. This PR converts the
`ray-core/` user guide from reStructuredText to MyST: 80 pages across
the top-level directory and the `actors/`, `objects/`, `scheduling/`,
`patterns/`, `fault_tolerance/`, `internals/`, `compiled-graph/`,
`direct-transport/`, `examples/`, and `tasks/` subtrees.
The conversion is **format-only and faithful**. No prose changed. Every
cross-reference label is kept byte-for-byte, so external `{ref}` and
`:ref:` callers keep resolving, and no URLs change, because Sphinx maps
`foo.rst` and `foo.md` to the same `foo.html`. The rendered HTML matches
`/en/master` except for the small, explained differences listed under
[Render differences from
`/en/master`](#render-differences-from-enmaster).
This PR combines nine PRs that were developed separately to make each
construct class easier to verify: #66353, #66355, #66377, #66380,
#66410, #66414, #66415, #66417, and #66425. This PR supersedes them.
Apart from the last two commits, its diff is identical to their union.
### How to review
There's one commit per original PR, so you can review commit by commit.
Each commit is that PR's full diff squashed, and within each one the
conversion and the soft-wrap reflow are already combined. The last two
commits are a one-line toctree fix in `user-guide.rst` and that page's
own conversion to `user-guide.md`, which the separate PRs left for last
to avoid churning the shared toctree page.
| Commit | Pages | New constructs |
|---|---|---|
| `patterns/` (#66353) | 22 design-pattern and anti-pattern pages |
Prose, `literalinclude`, figures |
| Top-level prose (#66355) | `accelerator-types`, `advanced-topics`,
`fault-tolerance`, `head-node-memory-management`, `internals`,
`ray-generator` | Toctree normalization, `orphan` frontmatter |
| Tab pages (#66377) | `tasks`, `namespaces`, `ray-dag` | sphinx-design
tabs |
| Doctest pages (#66380) | `actors`, `configure`, `miscellaneous`,
`objects`, `starting-ray`, `tips-for-first-time`, `user-spawn-processes`
| Executed `testcode`, autodoc in `{eval-rst}` |
| Table pages (#66410) | `cross-language`,
`resource-isolation-with-cgroupv2` | `{list-table}`, tables inside
definition lists |
| Prose subtrees (#66414) | `fault_tolerance/` (5), `internals/` (8),
`compiled-graph/` (5 of 6), `direct-transport/` (2),
`examples/monte_carlo_pi`, `examples/overview`,
`tasks/dynamic_generators` | Definition lists, Mermaid in comments |
| `actors/` and `objects/` (#66415) | 7 + 2 pages | Doctest-heavy tabs |
| `scheduling/` (#66417) | 6 pages | Shared help partial |
| Jupyter (#66425) | `using-ray-with-jupyter` | Paragraphs that start
with a number |
Three pages under `ray-core/`, outside `api/`, stay RST:
- `compiled-graph/compiled-graph-api.rst` is four `autosummary` blocks
and nothing else, so it stays RST like the other API reference trees.
- `tasks/nested-tasks.rst` and `handling-dependencies.rst` are named in
`doc/BUILD.bazel`'s `doctest[core]` exclusions, so they convert in a
later PR that also updates that file.
### Other files this PR touches
- `ray-core/user-guide`: the section's toctree page converts to MyST
too. Its `patterns/index.rst` and `scheduling/index.rst` entries are now
extensionless, like their siblings. Sphinx resolves either form, so that
part is for consistency, not a fix. The only reference to the page, the
toctree entry in `walkthrough.md`, is already extensionless.
- `_includes/_help-links.md` is new. `scheduling/memory-management` and
`scheduling/ray-oom-prevention` end with the shared `_help.rst` partial,
which MyST can't include natively. `_help-links.md` is the same
four-item list in Markdown. It can't be named `_help.md`, because Sphinx
treats `_help.md` and `_help.rst` as the same document. `_help.rst`
stays for the three RST pages that still include it:
`ray-references/faq`, `cluster/vms/user-guides/community/yarn`, and
`tune/key-concepts`.
- `ray-core/examples/gentle_walkthrough.ipynb`,
`ray-core/examples/map_reduce.ipynb`, and
`ray-contribute/publishing-examples-legacy.md` pointed at
`examples/overview.rst` and now point at the `.md`.
No other file changes. Every other reference to these pages is
extensionless or goes through a label.
## Render differences from `/en/master`
`render_diff.py` against `/en/master` over all 80 converted pages: 65
render identically, and the other 15 differ only in the ways listed
below.
### Intended changes, where MyST renders what the source meant
- **`configure`, TLS step 1.** On `/en/master`, the `# Alternatively,
this command automatically encode ...` paragraph has no blank line
before its `.. code-block:: bash`, so docutils swallows the directive
into the paragraph. The `kubectl` command renders as a block quote with
its `--` flags turned into en-dashes. It now renders as the bash code
block the author intended. The leading `#` is escaped (`\#`) so the
paragraph stays a paragraph rather than becoming an H1.
- **`miscellaneous`, Benchmark.** "Increase the ARP cache size:" renders
on `/en/master` as a definition list, because its sub-items are indented
four spaces rather than two. It now renders as the nested bullet list
the source describes.
- **`objects/serialization`, custom-serialization list.** On
`/en/master`, the first item's `testoutput` is indented 2 spaces under
an item whose content starts at column 3. docutils ends the list,
renders the output in a stray block quote, and restarts the list at 2.
The MyST keeps the output inside item 1, so the three items render as
one list.
### Link changes
Relative `.html` links become Sphinx roles, because MyST reads a
scheme-less link target as a cross-reference and fails
`fail_on_warning`. They render as internal references rather than
external links. Four of them only worked on `/en/master` through a site
redirect, so each now points at the page the redirect already lands on.
- `tasks`: `` `Object refs <objects.html>`__ `` becomes `` {doc}`Object
refs <objects>` ``.
- `namespaces`: `` `Driver Options <configure.html#driver-options>`__ ``
becomes `` {ref}`Driver Options <java-driver-options>` ``. The href
anchor changes from `#driver-options` to `#java-driver-options`, and
both ids sit on the same section.
- `configure`: `` `documentation <package-ref.html#ray.init>`__ ``
becomes `` {doc}`documentation <api/index>` ``, where
`ray-core/package-ref.html` already redirects.
- `configure`: `` `Python time format <strftime.org>`__ `` becomes
`[Python time format](https://strftime.org/)`. The scheme-less target
resolved as a relative path that redirected to `https://strftime.org/`.
- `configure`: the `` `Java Applications`_ `` named reference becomes
`[Java Applications](#java-applications)`, the same href it renders to
today.
- `miscellaneous`: `` `Prometheus endpoint <ray-metrics.html>`_ ``
becomes `` {ref}`Prometheus endpoint <collect-metrics>` ``.
`ray-core/ray-metrics.html` redirects to `cluster/metrics.html`, whose
top label is `collect-metrics`.
- `starting-ray`: the `Configuration`, `Deployment section`,
`Kubernetes`, `YARN`, and `SLURM` links become `{doc}` roles to the same
pages.
### Anchor changes
- **`starting-ray`, "What's next?"** MyST slugs the heading `whats-next`
where docutils produced `what-s-next`. A compat target isn't possible,
because `what-s-next` is already a global label in
`cluster/getting-started.md`. No authored link in the repo points at
this anchor. The generated toctree entries in `advanced-topics` and
`user-guide` follow the new slug automatically, so those two pages'
render diffs show the same `#whats-next` change and nothing else.
- **`objects/serialization`, "Plasma Object Store".** On `/en/master`,
the link `` `Plasma object store <…>`_ `` creates a named target that
collides with the heading's implicit name, so docutils gives the section
the id `plasma-store`, plus a stray `id1`. MyST creates no named target
for a link, so the section takes its heading slug,
`plasma-object-store`. The `plasma-store` label still renders as an
anchor on the section, so `#plasma-store` links keep working.
### Constructs with no MyST equivalent
- **Line blocks** become Markdown hard line breaks, which render as
`<p>` plus `<br>` instead of `div.line-block`, with the same lines
visible. This affects the two links at the end of `ray-dag` and five
cells in the `tips-for-first-time` API table.
### Invisible markup differences
These don't change what a reader sees:
- **Definition-list class.** MyST's `<dl>` carries `class="simple myst"`
where docutils emits no class or `simple`. The class has no styling. It
appears in `cross-language` (3), `internals/metric-exporter`,
`direct-transport`, and `scheduling/memory-management`.
- **RST comments become HTML comments** in `examples/overview` and
`scheduling/memory-management`, so the author's note stays in the
source. RST emits no node for a comment, so the diff shows the `<!-- …
-->`, but it doesn't render. The five comments in
`internals/object-spilling` hold Mermaid source whose `-->` arrows would
end an HTML comment early. They're MyST `%` comments instead, which emit
nothing, like the RST.
`render_diff.py` filters the two inert differences every MyST page shows
against an RST page: `class="tex2jax_ignore mathjax_ignore"` on the root
`<section>`, and the missing `code` class on inline literals. Neither
class carries any styling.
## Verification
- **Static checks** on all 81 new `.md` files: frontmatter parses,
backtick and colon fences balance, there's no residual RST outside
fences, every label is preserved, directive counts match the `.rst`, and
there are no relative `.html`, `.rst`, or scheme-less links.
- **Soft-wrap.** Each page's reflow to one line per paragraph is
whitespace-only. `ray-soft-wrap`'s `verify.py` reports `content=ok
render=ok idempotent=ok` for every file.
- **Doctest coverage is unchanged.** `doctest[core]` runs
`pytest-sphinx`, which yields one pytest item per file, so `pytest
--collect-only` counts files, not blocks. To count blocks, I ran
`pytest-sphinx`'s own parser over each `.rst` on master and each new
`.md`. It builds 120 examples before and 120 after. That's every example
`doctest[core]` collects from `ray-core/` on master: this PR moves all
16 of that target's executed files to MyST. Every parsed section is
identical, including directive, body, `:options:`, and `:skipif:`, apart
from trailing whitespace dropped from a comment line in
`compiled-graph/quickstart`'s skipped block and from two lines of a
`serialization` code block.
| Page | Examples before | Examples after |
|---|---|---|
| `scheduling/accelerators` | 35 | 35 |
| `tips-for-first-time` | 14 | 14 |
| `actors/async_api` | 10 | 10 |
| `starting-ray` | 8 | 8 |
| `objects/serialization` | 8 | 8 |
| `actors` | 7 | 7 |
| `miscellaneous` | 7 | 7 |
| `scheduling/memory-management` | 7 | 7 |
| `configure` | 6 | 6 |
| `objects` | 4 | 4 |
| `actors/concurrency_group_api` | 3 | 3 |
| `actors/named-actors` | 3 | 3 |
| `actors/task-orders` | 3 | 3 |
| `actors/terminating-actors` | 3 | 3 |
| `internals/task-lifecycle` | 1 | 1 |
| `user-spawn-processes` | 1 | 1 |
| **Total** | **120** | **120** |
None of the converted pages is in a doctest `exclude` list, and
`doctest[core]` globs both `.md` and `.rst`, so `doc/BUILD.bazel`
doesn't change.
- **Doctests executed locally.** This PR only touches doc sources, so
`.buildkite/test.rules.txt` routes it to no test steps, and
`doctest[core]` doesn't run premerge. I ran the converted doctest pages
through pytest locally, with the `doctest` macro's arguments, Ray's
pinned `pytest==7.4.4`, and the Ray nightly wheel (`674900c91faa`), on
Python 3.10 with `RAY_USAGE_STATS_PROMPT_ENABLED=0`. All pass except
`scheduling/accelerators`, which fails on a missing
`CUDA_VISIBLE_DEVICES` on a machine with no GPU. The master `.rst` fails
the same way, so that page's evidence is the parity check.
- **Build.** The Read the Docs preview is green under `fail_on_warning`.
- **Render diff.** `render_diff.py` against `/en/master` over all 80
pages: 65 identical, and every difference on the other 15 is listed
under [Render differences from
`/en/master`](#render-differences-from-enmaster).
**Duplicate check.** No other open PR converts these pages. Six open PRs
edit pages this PR converts, and each will need to move its change onto
the `.md` file when this lands: #64137 and #65979
(`direct-transport/direct-transport`), #66402 (`objects/serialization`),
#66368 (`scheduling/accelerators`), #65974 (`scheduling/placement-group`
and `scheduling/resources`), and #65792 (`tasks`).
This PR was prepared with AI assistance (Claude Code). I reviewed the
changes and ran the checks above.
## Related issue number
Part of the RST-to-MyST migration.
## Checks
- [x] I've signed off every commit (`git commit -s`).
- [x] I've made sure the tests are passing: the static checks, soft-wrap
verification, doctest parity check, and local doctest run pass, the RtD
build is green, and every render diff is explained above.
- Testing Strategy
- [ ] Unit tests
- [ ] Release tests
- [x] Docs-only change, verified with the static checks, doctest parity
check, RtD build, and render diff described above
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…6430) ## Why are these changes needed? MyST Markdown is the standard for Ray doc pages. This PR converts the `ray-core/` user guide from reStructuredText to MyST: 80 pages across the top-level directory and the `actors/`, `objects/`, `scheduling/`, `patterns/`, `fault_tolerance/`, `internals/`, `compiled-graph/`, `direct-transport/`, `examples/`, and `tasks/` subtrees. The conversion is **format-only and faithful**. No prose changed. Every cross-reference label is kept byte-for-byte, so external `{ref}` and `:ref:` callers keep resolving, and no URLs change, because Sphinx maps `foo.rst` and `foo.md` to the same `foo.html`. The rendered HTML matches `/en/master` except for the small, explained differences listed under [Render differences from `/en/master`](#render-differences-from-enmaster). This PR combines nine PRs that were developed separately to make each construct class easier to verify: ray-project#66353, ray-project#66355, ray-project#66377, ray-project#66380, ray-project#66410, ray-project#66414, ray-project#66415, ray-project#66417, and ray-project#66425. This PR supersedes them. Apart from the last two commits, its diff is identical to their union. ### How to review There's one commit per original PR, so you can review commit by commit. Each commit is that PR's full diff squashed, and within each one the conversion and the soft-wrap reflow are already combined. The last two commits are a one-line toctree fix in `user-guide.rst` and that page's own conversion to `user-guide.md`, which the separate PRs left for last to avoid churning the shared toctree page. | Commit | Pages | New constructs | |---|---|---| | `patterns/` (ray-project#66353) | 22 design-pattern and anti-pattern pages | Prose, `literalinclude`, figures | | Top-level prose (ray-project#66355) | `accelerator-types`, `advanced-topics`, `fault-tolerance`, `head-node-memory-management`, `internals`, `ray-generator` | Toctree normalization, `orphan` frontmatter | | Tab pages (ray-project#66377) | `tasks`, `namespaces`, `ray-dag` | sphinx-design tabs | | Doctest pages (ray-project#66380) | `actors`, `configure`, `miscellaneous`, `objects`, `starting-ray`, `tips-for-first-time`, `user-spawn-processes` | Executed `testcode`, autodoc in `{eval-rst}` | | Table pages (ray-project#66410) | `cross-language`, `resource-isolation-with-cgroupv2` | `{list-table}`, tables inside definition lists | | Prose subtrees (ray-project#66414) | `fault_tolerance/` (5), `internals/` (8), `compiled-graph/` (5 of 6), `direct-transport/` (2), `examples/monte_carlo_pi`, `examples/overview`, `tasks/dynamic_generators` | Definition lists, Mermaid in comments | | `actors/` and `objects/` (ray-project#66415) | 7 + 2 pages | Doctest-heavy tabs | | `scheduling/` (ray-project#66417) | 6 pages | Shared help partial | | Jupyter (ray-project#66425) | `using-ray-with-jupyter` | Paragraphs that start with a number | Three pages under `ray-core/`, outside `api/`, stay RST: - `compiled-graph/compiled-graph-api.rst` is four `autosummary` blocks and nothing else, so it stays RST like the other API reference trees. - `tasks/nested-tasks.rst` and `handling-dependencies.rst` are named in `doc/BUILD.bazel`'s `doctest[core]` exclusions, so they convert in a later PR that also updates that file. ### Other files this PR touches - `ray-core/user-guide`: the section's toctree page converts to MyST too. Its `patterns/index.rst` and `scheduling/index.rst` entries are now extensionless, like their siblings. Sphinx resolves either form, so that part is for consistency, not a fix. The only reference to the page, the toctree entry in `walkthrough.md`, is already extensionless. - `_includes/_help-links.md` is new. `scheduling/memory-management` and `scheduling/ray-oom-prevention` end with the shared `_help.rst` partial, which MyST can't include natively. `_help-links.md` is the same four-item list in Markdown. It can't be named `_help.md`, because Sphinx treats `_help.md` and `_help.rst` as the same document. `_help.rst` stays for the three RST pages that still include it: `ray-references/faq`, `cluster/vms/user-guides/community/yarn`, and `tune/key-concepts`. - `ray-core/examples/gentle_walkthrough.ipynb`, `ray-core/examples/map_reduce.ipynb`, and `ray-contribute/publishing-examples-legacy.md` pointed at `examples/overview.rst` and now point at the `.md`. No other file changes. Every other reference to these pages is extensionless or goes through a label. ## Render differences from `/en/master` `render_diff.py` against `/en/master` over all 80 converted pages: 65 render identically, and the other 15 differ only in the ways listed below. ### Intended changes, where MyST renders what the source meant - **`configure`, TLS step 1.** On `/en/master`, the `# Alternatively, this command automatically encode ...` paragraph has no blank line before its `.. code-block:: bash`, so docutils swallows the directive into the paragraph. The `kubectl` command renders as a block quote with its `--` flags turned into en-dashes. It now renders as the bash code block the author intended. The leading `#` is escaped (`\#`) so the paragraph stays a paragraph rather than becoming an H1. - **`miscellaneous`, Benchmark.** "Increase the ARP cache size:" renders on `/en/master` as a definition list, because its sub-items are indented four spaces rather than two. It now renders as the nested bullet list the source describes. - **`objects/serialization`, custom-serialization list.** On `/en/master`, the first item's `testoutput` is indented 2 spaces under an item whose content starts at column 3. docutils ends the list, renders the output in a stray block quote, and restarts the list at 2. The MyST keeps the output inside item 1, so the three items render as one list. ### Link changes Relative `.html` links become Sphinx roles, because MyST reads a scheme-less link target as a cross-reference and fails `fail_on_warning`. They render as internal references rather than external links. Four of them only worked on `/en/master` through a site redirect, so each now points at the page the redirect already lands on. - `tasks`: `` `Object refs <objects.html>`__ `` becomes `` {doc}`Object refs <objects>` ``. - `namespaces`: `` `Driver Options <configure.html#driver-options>`__ `` becomes `` {ref}`Driver Options <java-driver-options>` ``. The href anchor changes from `#driver-options` to `#java-driver-options`, and both ids sit on the same section. - `configure`: `` `documentation <package-ref.html#ray.init>`__ `` becomes `` {doc}`documentation <api/index>` ``, where `ray-core/package-ref.html` already redirects. - `configure`: `` `Python time format <strftime.org>`__ `` becomes `[Python time format](https://strftime.org/)`. The scheme-less target resolved as a relative path that redirected to `https://strftime.org/`. - `configure`: the `` `Java Applications`_ `` named reference becomes `[Java Applications](#java-applications)`, the same href it renders to today. - `miscellaneous`: `` `Prometheus endpoint <ray-metrics.html>`_ `` becomes `` {ref}`Prometheus endpoint <collect-metrics>` ``. `ray-core/ray-metrics.html` redirects to `cluster/metrics.html`, whose top label is `collect-metrics`. - `starting-ray`: the `Configuration`, `Deployment section`, `Kubernetes`, `YARN`, and `SLURM` links become `{doc}` roles to the same pages. ### Anchor changes - **`starting-ray`, "What's next?"** MyST slugs the heading `whats-next` where docutils produced `what-s-next`. A compat target isn't possible, because `what-s-next` is already a global label in `cluster/getting-started.md`. No authored link in the repo points at this anchor. The generated toctree entries in `advanced-topics` and `user-guide` follow the new slug automatically, so those two pages' render diffs show the same `#whats-next` change and nothing else. - **`objects/serialization`, "Plasma Object Store".** On `/en/master`, the link `` `Plasma object store <…>`_ `` creates a named target that collides with the heading's implicit name, so docutils gives the section the id `plasma-store`, plus a stray `id1`. MyST creates no named target for a link, so the section takes its heading slug, `plasma-object-store`. The `plasma-store` label still renders as an anchor on the section, so `#plasma-store` links keep working. ### Constructs with no MyST equivalent - **Line blocks** become Markdown hard line breaks, which render as `<p>` plus `<br>` instead of `div.line-block`, with the same lines visible. This affects the two links at the end of `ray-dag` and five cells in the `tips-for-first-time` API table. ### Invisible markup differences These don't change what a reader sees: - **Definition-list class.** MyST's `<dl>` carries `class="simple myst"` where docutils emits no class or `simple`. The class has no styling. It appears in `cross-language` (3), `internals/metric-exporter`, `direct-transport`, and `scheduling/memory-management`. - **RST comments become HTML comments** in `examples/overview` and `scheduling/memory-management`, so the author's note stays in the source. RST emits no node for a comment, so the diff shows the `<!-- … -->`, but it doesn't render. The five comments in `internals/object-spilling` hold Mermaid source whose `-->` arrows would end an HTML comment early. They're MyST `%` comments instead, which emit nothing, like the RST. `render_diff.py` filters the two inert differences every MyST page shows against an RST page: `class="tex2jax_ignore mathjax_ignore"` on the root `<section>`, and the missing `code` class on inline literals. Neither class carries any styling. ## Verification - **Static checks** on all 81 new `.md` files: frontmatter parses, backtick and colon fences balance, there's no residual RST outside fences, every label is preserved, directive counts match the `.rst`, and there are no relative `.html`, `.rst`, or scheme-less links. - **Soft-wrap.** Each page's reflow to one line per paragraph is whitespace-only. `ray-soft-wrap`'s `verify.py` reports `content=ok render=ok idempotent=ok` for every file. - **Doctest coverage is unchanged.** `doctest[core]` runs `pytest-sphinx`, which yields one pytest item per file, so `pytest --collect-only` counts files, not blocks. To count blocks, I ran `pytest-sphinx`'s own parser over each `.rst` on master and each new `.md`. It builds 120 examples before and 120 after. That's every example `doctest[core]` collects from `ray-core/` on master: this PR moves all 16 of that target's executed files to MyST. Every parsed section is identical, including directive, body, `:options:`, and `:skipif:`, apart from trailing whitespace dropped from a comment line in `compiled-graph/quickstart`'s skipped block and from two lines of a `serialization` code block. | Page | Examples before | Examples after | |---|---|---| | `scheduling/accelerators` | 35 | 35 | | `tips-for-first-time` | 14 | 14 | | `actors/async_api` | 10 | 10 | | `starting-ray` | 8 | 8 | | `objects/serialization` | 8 | 8 | | `actors` | 7 | 7 | | `miscellaneous` | 7 | 7 | | `scheduling/memory-management` | 7 | 7 | | `configure` | 6 | 6 | | `objects` | 4 | 4 | | `actors/concurrency_group_api` | 3 | 3 | | `actors/named-actors` | 3 | 3 | | `actors/task-orders` | 3 | 3 | | `actors/terminating-actors` | 3 | 3 | | `internals/task-lifecycle` | 1 | 1 | | `user-spawn-processes` | 1 | 1 | | **Total** | **120** | **120** | None of the converted pages is in a doctest `exclude` list, and `doctest[core]` globs both `.md` and `.rst`, so `doc/BUILD.bazel` doesn't change. - **Doctests executed locally.** This PR only touches doc sources, so `.buildkite/test.rules.txt` routes it to no test steps, and `doctest[core]` doesn't run premerge. I ran the converted doctest pages through pytest locally, with the `doctest` macro's arguments, Ray's pinned `pytest==7.4.4`, and the Ray nightly wheel (`674900c91faa`), on Python 3.10 with `RAY_USAGE_STATS_PROMPT_ENABLED=0`. All pass except `scheduling/accelerators`, which fails on a missing `CUDA_VISIBLE_DEVICES` on a machine with no GPU. The master `.rst` fails the same way, so that page's evidence is the parity check. - **Build.** The Read the Docs preview is green under `fail_on_warning`. - **Render diff.** `render_diff.py` against `/en/master` over all 80 pages: 65 identical, and every difference on the other 15 is listed under [Render differences from `/en/master`](#render-differences-from-enmaster). **Duplicate check.** No other open PR converts these pages. Six open PRs edit pages this PR converts, and each will need to move its change onto the `.md` file when this lands: ray-project#64137 and ray-project#65979 (`direct-transport/direct-transport`), ray-project#66402 (`objects/serialization`), ray-project#66368 (`scheduling/accelerators`), ray-project#65974 (`scheduling/placement-group` and `scheduling/resources`), and ray-project#65792 (`tasks`). This PR was prepared with AI assistance (Claude Code). I reviewed the changes and ran the checks above. ## Related issue number Part of the RST-to-MyST migration. ## Checks - [x] I've signed off every commit (`git commit -s`). - [x] I've made sure the tests are passing: the static checks, soft-wrap verification, doctest parity check, and local doctest run pass, the RtD build is green, and every render diff is explained above. - Testing Strategy - [ ] Unit tests - [ ] Release tests - [x] Docs-only change, verified with the static checks, doctest parity check, RtD build, and render diff described above 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Why are these changes needed?
MyST Markdown is the standard for Ray doc pages, and this converts the
ray-core/patterns/directory — 22 design-pattern and anti-pattern pages — from reStructuredText to MyST. It's the first PR in theray-core/prose migration and a self-contained, mechanical unit: every file is a short prose page with aliteralincludeand sometimes a figure, no tabs, tables, doctests, or includes.The conversion is format-only and faithful: rendered HTML is preserved, and every cross-reference label is kept byte-for-byte so external
{ref}/:ref:callers keep resolving.What's in here
.rstfor review.ray-soft-wrap'sverify.py: non-whitespace bytes unchanged, rendered HTML identical, transform idempotent.user-guide.rst's toctree listedpatterns/index.rstwith the extension, which would dangle once the file is.md, so it's now the extensionlesspatterns/indexlike its siblings.Verification
literalincludeandfiguretarget resolves.fork-new-processes, the "The solution is to: 1. … 2. …" text renders as a single inline paragraph on the RST page (no blank line before the numbers, so docutils never starts a list — confirmed against/en/master). The MyST list markers are escaped (1\.,2\.) to preserve that inline rendering rather than silently promoting it to an ordered list.fail_on_warning, and an emptyrender_diffagainst/en/masterfor every page. Holding in draft until both are clean.No URLs change: Sphinx maps
foo.rstandfoo.mdto the samefoo.html.Related issue number
Part of the
ray-core/RST-to-MyST migration.Checks
git commit -s).