Skip to content

[Docs][Core] Specify if the node id needs to be a hex or byte value - #67592

Merged
pseudo-rnd-thoughts merged 4 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:fix-core-docstrings-hex-id-2
Nov 4, 2026
Merged

pseudo-rnd-thoughts merged 4 commits into
ray-project:masterfrom
pseudo-rnd-thoughts:fix-core-docstrings-hex-id-2

Conversation

@pseudo-rnd-thoughts

Copy link
Copy Markdown
Member

Description

In recent PRs, I've found that Gemini and Claude sometimes get confused on if the node id should be a hex or byte value.
This PR updates the docstrings for all applicable functions to specify this and avoid these issues in the future

Mark Towers added 2 commits October 30, 2026 12:16
…ed as hex values or bytes

Signed-off-by: Mark Towers <[email protected]>
…ed as hex values or bytes

Signed-off-by: Mark Towers <[email protected]>
@pseudo-rnd-thoughts pseudo-rnd-thoughts added the docstring-only Skip heavy library tests for Ray API docstring edits. label Oct 30, 2026
@pseudo-rnd-thoughts
pseudo-rnd-thoughts requested review from a team as code owners October 30, 2026 12:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates docstrings across several Ray internal files to explicitly document where node, actor, and job IDs are represented as hex strings versus binary bytes. The feedback suggests a correction to the actor_table docstring in python/ray/_private/state.py to clarify that the 'NodeID' key is nested inside 'Address' and 'OwnerAddress' dictionaries rather than being a top-level key, which helps prevent potential KeyErrors.

Comment thread python/ray/_private/state.py Resolved
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Oct 30, 2026
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Oct 30, 2026
dstrodtman added a commit that referenced this pull request Oct 30, 2026
## Why are these changes needed?

The `docstring-only` label's scope guard,
`ci/ray_ci/doc/check_docstring_only.py`, rejects every file that isn't
`.py`. Docstring edits to Cython bindings therefore can't use the label,
even when they change nothing else. #67592 hit this: its edits to
`python/ray/includes/gcs_client.pxi` and `global_state_accessor.pxi`
only add and rewrite docstrings, and the guard failed them with "isn't a
Python file" ([build
75788](https://buildkite.com/ray-project/premerge/builds/75788#01a18cd4-72d1-46c4-b00f-0995c3e2b663)).

This PR extends the guard to two more kinds of file:

- **`.pyi` stubs** are Python, so they go through the existing `ast`
comparison unchanged.
- **Cython files, `.pyx`, `.pxi`, and `.pxd`,** can't go through `ast`,
which can't parse `cdef`. The guard compares their `tokenize` token
streams instead. It drops comments, blank lines, and line breaks inside
brackets. It removes a string only where Python allows a docstring: the
first statement of the file, or the first statement in the indented body
of a `def`, `class`, `cdef`/`cpdef` function, or `cdef class`.

Two Cython constructs look like comments or docstrings but are code, and
the guard keeps both:

- `# cython:` and `# distutils:` comments set compiler directives and
build options. `_raylet.pyx`, `_raylet.pxd`, and `libcoreworker.pxd`
carry them, including `embedsignature`.
- A string in a `cdef extern from` block is verbatim C or C++ that
Cython compiles. Five files under `python/ray/` have one. A `cdef
extern` header has neither a parameter list nor `class`, so the guard
never treats that string as a docstring.

The token comparison fails closed where it differs from the `ast` rule.
It treats replacing a docstring-only body with `pass` as a code change,
and it doesn't strip a docstring written on the same line as its `def`.

The label still compiles the PR's Cython. A `python/` change selects
`doc: docstring examples`, which depends on `ray-core-build`, so a
docstring edit that breaks the Cython build still fails the PR.

`ci.md`, `ci/ray_ci/doc/README.md`, and the step comment in
`.buildkite/lint.rayci.yml` now name the covered file types and the two
Cython exceptions. `ci.md` also notes that `doc: docstring examples`
runs only Python modules. No CI step runs `>>>` examples in Cython
docstrings, with or without the label, because no `doctest()` target
lists a Cython file and `--doctest-modules` collects only `.py`.

## Testing

- `pytest ci/ray_ci/doc/test_check_docstring_only.py` passes all 33
tests on Python 3.10, which is the forge image's version, and on 3.12
and 3.13. The new tests cover stub docstrings, the #67592 edit shapes,
line rewrapping, indentation changes, the build comments, the extern C
block, a non-leading string, an f-string in the docstring position, a
Cython cast, an `except?` clause, and a tokenize error.
- On #67592's head against its merge base, the new guard reports "5
file(s), docstrings only." and exits 0. The guard on master fails the
same diff the way CI did.
- All 39 `.pyx`, `.pxi`, `.pxd`, and `.pyi` files on master tokenize on
Python 3.10 through 3.13.
- Mutation test on master's Cython files: the guard caught all 1,520
injected single-token and indentation edits to code, plus every
directive-comment change.
- History replay: I ran the comparison on every modification to a Cython
file in the last 940 commits on master that touched one, 1,831 file
changes in all. It passed 42, and I read each of those diffs: all are
docstring, comment, blank-line, or in-bracket rewrapping changes. The
other 1,789 changed code and failed.
- `pre-commit run` on the changed files passes.

## Duplicate check

No open PR changes `check_docstring_only.py` or the label's file
coverage. I searched open PRs for "docstring-only" and
"check_docstring_only".

## AI assistance

I wrote this change with Claude Code (Opus 5.5). I reviewed every
changed line, and I ran the tests and checks listed 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]>
dstrodtman and others added 2 commits October 30, 2026 13:58
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Mark Towers <[email protected]>
@pseudo-rnd-thoughts
pseudo-rnd-thoughts merged commit b399613 into ray-project:master Nov 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core docs An issue or change related to documentation docstring-only Skip heavy library tests for Ray API docstring edits. go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants