Repository navigation
[core] Add missing docstrings, Args, and Returns to RuntimeEnv, exceptions, and ObjectRefGenerator - #67634
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
nit: I'm curious whether we really need docstrings for methods that just raise |
|
Good call on making these useful rather than just present. These six aren't abstract stubs though. What I did instead, in #67636: |
Run ruff 0.8.4 `check --fix --unsafe-fixes --select D212,D200,D210` under the Google pydocstyle convention over python/ray/, excluding the library trees with their own code owners (data, serve, train, air, tune, rllib, llm), test code, and generated code. The diff is formatter output only. Ten docstrings keep their original layout, because moving their first line onto the quotes would change their rendered text. They need a hand edit in a separate PR. @rtd-build Signed-off-by: Douglas Strodtman <[email protected]>
…tions, and ObjectRefGenerator @rtd-build Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
1b51db7 to
06da8f9
Compare
2e2960b to
2044e26
Compare
…can be documented (#67636) ## Summary Adds type hints to public Ray Core signatures that have none, and documents their parameters in the same change. Ray's pydoclint config rejects an `Args:` section until every parameter has a type hint, so these symbols couldn't be documented in the docstring-only PRs. This PR also corrects five return annotations that didn't match what the functions return, and documents `ray.util.tpu.dispatch`. This PR is stacked on #67635, which is stacked on #67634. Those two PRs document the rest of these files. Review only the top two commits. It isn't labeled `docstring-only`, because the signatures change, so it runs the full Core premerge. ## What changes Type hints and docstrings: - `ObjectRefGenerator.send`, `throw`, `asend`, and `athrow`: `value: Any`. Each method only raises `NotImplementedError`, and the docstrings say so. - `RayError.from_bytes(b: bytes) -> BaseException` and `from_ray_exception(ray_exception: RayException) -> BaseException`. - The constructors of `CrossLanguageError`, `RayTaskError`, `RaySystemError`, `OutOfMemoryError`, and `NodeDiedError`. - `RuntimeContext.__init__(worker: Any)`. The worker is either the global Ray worker or Ray Client's `_ClientWorkerPropertyAPI`, which emulates it, so `Any` is the honest hint without new imports. - `RuntimeEnv.get(name: str, default: Any = None, data_class: Optional[type] = None) -> Any` and `get_extension(key: str)`. Return annotations corrected to match the code: - `RuntimeEnv.has_conda`: `str` to `bool`. - `RuntimeEnv.conda_env_name` and `conda_config`: `str` to `Optional[str]`. Both return None when `conda` isn't set or has the other form. - `RuntimeEnv.py_container_run_options`: `List` to `Optional[List]`. It returns None when `container` isn't set. - `ray.util.list_named_actors`: `List[str]` to `Union[List[str], List[Dict[str, str]]]`. With `all_namespaces=True`, it returns dicts with `name` and `namespace` keys. Docstring only: - `ray.util.tpu.dispatch`, the deprecated alias of `run_on_slice`, gets `Args:` and `Returns:` sections. Adding `Returns:` makes pydoclint check `*args` and `**kwargs`, so they're documented too. CODEOWNERS assigns `util/tpu.py` to `@andrewsykim`, `@edoakes`, and `@ryanaoleary`, so this PR needs one of them in addition to ray-core. Type hints don't change runtime behavior. None of these files are in Ray's mypy hook. ## For reviewers These are worth a close read: - `RayTaskError.cause` is hinted `BaseException`, which matches what the task-execution path in `_raylet.pyx` and `CompiledDAG` pass. `actor_id` is the actor ID in hex, as `_raylet.pyx` computes it. - `RaySystemError.client_exc` is hinted `str`. The callers in `worker.py`, `serialization.py`, and `_raylet.pyx` pass a message string, despite the parameter name. - `RayError.from_bytes` and `from_ray_exception` return `BaseException`: an unpickled exception, an `UnserializableException`, or a `CrossLanguageError`. `ray.util.client.api.ClientAPI.list_named_actors` carries the same `List[str]` annotation for Ray Client. It isn't public API, so this PR leaves it alone. ## Duplicate check No open PR changes these signatures. I searched open PRs for the class and method names. ## Testing - The full pre-commit suite, including ruff, black, pydoclint, and the docstyle hook, on every changed file, including `util/__init__.py` and `util/tpu.py`: passed. - `uvx [email protected] check --select D212,D200,D210` on the changed files: passed. - A smoke test against the latest nightly wheel with the four changed files overlaid: a task error and an actor task error round-trip through `to_bytes` and `from_bytes`, `ray.get_runtime_context()` works in the driver and in an actor, the exception constructors format their messages, `RuntimeEnv.get`, `get_extension`, and the re-annotated accessors return what their annotations now say, and the streaming generator's `send`, `throw`, `asend`, and `athrow` raise `NotImplementedError`. - `python/ray/tests/unit/test_runtime_env.py` and `test_runtime_env_validation.py` against the same overlay: 96 passed, 12 failed. The same 12 fail with master's versions of the four files in the same environment, because the nightly wheel's commit and the copied test fixtures don't match this checkout, so none come from this change. - The commit carries an `@rtd-build` line, so the Read the Docs preview renders the changed docstrings. AI assistance (Claude Code) was used to prepare this PR. 🤖 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]>
…can be documented (#67636) ## Summary Adds type hints to public Ray Core signatures that have none, and documents their parameters in the same change. Ray's pydoclint config rejects an `Args:` section until every parameter has a type hint, so these symbols couldn't be documented in the docstring-only PRs. This PR also corrects five return annotations that didn't match what the functions return, and documents `ray.util.tpu.dispatch`. This PR is stacked on #67635, which is stacked on #67634. Those two PRs document the rest of these files. Review only the top two commits. It isn't labeled `docstring-only`, because the signatures change, so it runs the full Core premerge. ## What changes Type hints and docstrings: - `ObjectRefGenerator.send`, `throw`, `asend`, and `athrow`: `value: Any`. Each method only raises `NotImplementedError`, and the docstrings say so. - `RayError.from_bytes(b: bytes) -> BaseException` and `from_ray_exception(ray_exception: RayException) -> BaseException`. - The constructors of `CrossLanguageError`, `RayTaskError`, `RaySystemError`, `OutOfMemoryError`, and `NodeDiedError`. - `RuntimeContext.__init__(worker: Any)`. The worker is either the global Ray worker or Ray Client's `_ClientWorkerPropertyAPI`, which emulates it, so `Any` is the honest hint without new imports. - `RuntimeEnv.get(name: str, default: Any = None, data_class: Optional[type] = None) -> Any` and `get_extension(key: str)`. Return annotations corrected to match the code: - `RuntimeEnv.has_conda`: `str` to `bool`. - `RuntimeEnv.conda_env_name` and `conda_config`: `str` to `Optional[str]`. Both return None when `conda` isn't set or has the other form. - `RuntimeEnv.py_container_run_options`: `List` to `Optional[List]`. It returns None when `container` isn't set. - `ray.util.list_named_actors`: `List[str]` to `Union[List[str], List[Dict[str, str]]]`. With `all_namespaces=True`, it returns dicts with `name` and `namespace` keys. Docstring only: - `ray.util.tpu.dispatch`, the deprecated alias of `run_on_slice`, gets `Args:` and `Returns:` sections. Adding `Returns:` makes pydoclint check `*args` and `**kwargs`, so they're documented too. CODEOWNERS assigns `util/tpu.py` to `@andrewsykim`, `@edoakes`, and `@ryanaoleary`, so this PR needs one of them in addition to ray-core. Type hints don't change runtime behavior. None of these files are in Ray's mypy hook. ## For reviewers These are worth a close read: - `RayTaskError.cause` is hinted `BaseException`, which matches what the task-execution path in `_raylet.pyx` and `CompiledDAG` pass. `actor_id` is the actor ID in hex, as `_raylet.pyx` computes it. - `RaySystemError.client_exc` is hinted `str`. The callers in `worker.py`, `serialization.py`, and `_raylet.pyx` pass a message string, despite the parameter name. - `RayError.from_bytes` and `from_ray_exception` return `BaseException`: an unpickled exception, an `UnserializableException`, or a `CrossLanguageError`. `ray.util.client.api.ClientAPI.list_named_actors` carries the same `List[str]` annotation for Ray Client. It isn't public API, so this PR leaves it alone. ## Duplicate check No open PR changes these signatures. I searched open PRs for the class and method names. ## Testing - The full pre-commit suite, including ruff, black, pydoclint, and the docstyle hook, on every changed file, including `util/__init__.py` and `util/tpu.py`: passed. - `uvx [email protected] check --select D212,D200,D210` on the changed files: passed. - A smoke test against the latest nightly wheel with the four changed files overlaid: a task error and an actor task error round-trip through `to_bytes` and `from_bytes`, `ray.get_runtime_context()` works in the driver and in an actor, the exception constructors format their messages, `RuntimeEnv.get`, `get_extension`, and the re-annotated accessors return what their annotations now say, and the streaming generator's `send`, `throw`, `asend`, and `athrow` raise `NotImplementedError`. - `python/ray/tests/unit/test_runtime_env.py` and `test_runtime_env_validation.py` against the same overlay: 96 passed, 12 failed. The same 12 fail with master's versions of the four files in the same environment, because the nightly wheel's commit and the copied test fixtures don't match this checkout, so none come from this change. - The commit carries an `@rtd-build` line, so the Read the Docs preview renders the changed docstrings. AI assistance (Claude Code) was used to prepare this PR. 🤖 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]>
… them, to Ray Core public APIs (#67635) ## Summary Documents the public Ray Core symbols that are still missing docstrings, `Args:` entries, or `Returns:` sections in `ray.util`, `ray.util.queue`, `ray.util.spark`, `ray.util.tpu`, `ray.experimental`, `ray.actor`, `ray.remote_function`, `ray.types`, `ray.exceptions`, `ray.runtime_env`, `ray.runtime_context`, and `ObjectRefGenerator`. Each docstring describes existing behavior, written from the code. Some of these symbols couldn't be documented without a signature change. Ray's pydoclint config rejects an `Args:` section until every parameter has a type hint, so this PR also adds type hints to the untyped public signatures it documents. It also corrects five return annotations that didn't match what the functions return. #67540 applied the ruff `D212` and `D200` auto-fixes to these files, and #67634 documented `ray.runtime_env`, `ray.exceptions`, and `ObjectRefGenerator`. Both are merged. This PR builds on them and has two commits: the docstring additions, then the type annotations. The second commit was reviewed as #67636, which merged into this branch instead of `master`. Because the signatures change, this PR isn't docstring-only and runs the full Core premerge. ## Docstrings - `ray.util.queue`: `Empty` and `Full` are documented, and `Queue.size`, `qsize`, `empty`, and `full` have `Returns:` sections. - `ray.util.list_named_actors` documents `all_namespaces` and returns, including the dict entries it returns when `all_namespaces` is True. - `ray.util.spark.setup_global_ray_cluster` documents all 17 parameters and what it returns. Most entries follow the matching `setup_ray_cluster` parameter, which the existing docstring already says they share, and point to it for defaults and caps. - `ray.util.tpu.dispatch`, the deprecated alias of `run_on_slice`, gets `Args:` and `Returns:` sections. Adding `Returns:` makes pydoclint check `*args` and `**kwargs`, so they're documented too. - `ray.experimental`: `CompiledDAGRef.get` and the `CompiledDAGFuture` constructor parameters, the `RayActorHandleResolver` constructor and its `get`, `forget`, `list_names`, and `kill` methods, and the `ReduceOp`, `AllGatherOp`, `AllReduceOp`, `ReduceScatterOp`, and `Device` types are documented. - `ActorMethod.__call__` and `remote`, `ActorClassInheritanceException`, `RemoteFunction.__call__`, and `ray.types.ObjectRef` have docstrings. ## Type hints Type hints added, with the parameters documented in the same change: - `ObjectRefGenerator.send`, `throw`, `asend`, and `athrow`: `value: Any`. Each method only raises `NotImplementedError`, and the docstrings say so. - `RayError.from_bytes(b: bytes) -> BaseException` and `from_ray_exception(ray_exception: RayException) -> BaseException`. - The constructors of `CrossLanguageError`, `RayTaskError`, `RaySystemError`, `OutOfMemoryError`, and `NodeDiedError`. - `RuntimeContext.__init__(worker: Any)`. The worker is either the global Ray worker or Ray Client's `_ClientWorkerPropertyAPI`, which emulates it, so `Any` is the honest hint without new imports. - `RuntimeEnv.get(name: str, default: Any = None, data_class: Optional[type] = None) -> Any` and `get_extension(key: str)`. Return annotations corrected to match the code: - `RuntimeEnv.has_conda`: `str` to `bool`. - `RuntimeEnv.conda_env_name` and `conda_config`: `str` to `Optional[str]`. Both return None when `conda` isn't set or has the other form. - `RuntimeEnv.py_container_run_options`: `List` to `Optional[List]`. It returns None when `container` isn't set. - `ray.util.list_named_actors`: `List[str]` to `Union[List[str], List[Dict[str, str]]]`. With `all_namespaces=True`, it returns dicts with `name` and `namespace` keys. `AsyncioRouter` in `python/ray/serve/_private/router.py` reads `RayTaskError.cause` into a local variable before the `ActorDiedError` check instead of calling `getattr` in the condition. It returns the same value in the same cases. Type hints don't change runtime behavior. None of these files are in Ray's mypy hook. ## For reviewers CODEOWNERS adds two reviewers beyond `@ray-project/ray-core`: `@ray-project/ray-serve` for `serve/_private/router.py`, and one of the individual owners of `util/tpu.py`. These are worth a close read: - `setup_global_ray_cluster` returns the `(address, remote_connection_address)` tuple only when `is_blocking` is False. When blocking, it returns None after the cluster shuts down. - `CompiledDAGRef.get` describes the `timeout` values from `CompiledDAG._execute_until`, which it calls. `ray.get()` on a CompiledDAGRef calls this method. - `Device` describes its members from the `device` argument of `TorchTensorType`. - `RayTaskError.cause` is hinted `BaseException`, which matches what the task-execution path in `_raylet.pyx` and `CompiledDAG` pass. `actor_id` is the actor ID in hex, as `_raylet.pyx` computes it. - `RaySystemError.client_exc` is hinted `str`. The callers in `worker.py`, `serialization.py`, and `_raylet.pyx` pass a message string, despite the parameter name. - `RayError.from_bytes` and `from_ray_exception` return `BaseException`: an unpickled exception, an `UnserializableException`, or a `CrossLanguageError`. `ray.util.client.api.ClientAPI.list_named_actors` has the same `List[str]` annotation for Ray Client. It isn't public API, so this PR leaves it alone. ## Duplicate check No open PR documents these symbols or changes these signatures. I searched open PRs for the module, class, and method names. #66745 converts the `Queue` class docstring example to doctest form, which doesn't overlap the lines this PR changes. ## Testing These checks ran on each commit before the rebase onto `master`. The rebase applied both commits unchanged. - The full pre-commit suite on every changed file, including ruff, black, pydoclint, and the docstyle hook: passed. - `uvx [email protected] check --select D212,D200,D210` on the changed files: passed. - The docstring commit passed `ci/ray_ci/doc/check_docstring_only.py`. The type-annotation commit changes signatures, so it's outside that guard by design. - A smoke test against the latest nightly wheel with the type-annotated files overlaid: a task error and an actor task error round-trip through `to_bytes` and `from_bytes`, `ray.get_runtime_context()` works in the driver and in an actor, the exception constructors format their messages, `RuntimeEnv.get`, `get_extension`, and the re-annotated accessors return what their annotations now say, and the streaming generator's `send`, `throw`, `asend`, and `athrow` raise `NotImplementedError`. - `python/ray/tests/unit/test_runtime_env.py` and `test_runtime_env_validation.py` against the same overlay: 96 passed, 12 failed. The same 12 fail with `master`'s versions of those files in the same environment, because the nightly wheel's commit and the copied test fixtures don't match this checkout, so none come from this change. - Both commits carry an `@rtd-build` line, so the Read the Docs preview renders the changed docstrings. AI assistance (Claude Code) was used to prepare this PR. 🤖 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]>
… them, to Ray Core public APIs (ray-project#67635) ## Summary Documents the public Ray Core symbols that are still missing docstrings, `Args:` entries, or `Returns:` sections in `ray.util`, `ray.util.queue`, `ray.util.spark`, `ray.util.tpu`, `ray.experimental`, `ray.actor`, `ray.remote_function`, `ray.types`, `ray.exceptions`, `ray.runtime_env`, `ray.runtime_context`, and `ObjectRefGenerator`. Each docstring describes existing behavior, written from the code. Some of these symbols couldn't be documented without a signature change. Ray's pydoclint config rejects an `Args:` section until every parameter has a type hint, so this PR also adds type hints to the untyped public signatures it documents. It also corrects five return annotations that didn't match what the functions return. ray-project#67540 applied the ruff `D212` and `D200` auto-fixes to these files, and ray-project#67634 documented `ray.runtime_env`, `ray.exceptions`, and `ObjectRefGenerator`. Both are merged. This PR builds on them and has two commits: the docstring additions, then the type annotations. The second commit was reviewed as ray-project#67636, which merged into this branch instead of `master`. Because the signatures change, this PR isn't docstring-only and runs the full Core premerge. ## Docstrings - `ray.util.queue`: `Empty` and `Full` are documented, and `Queue.size`, `qsize`, `empty`, and `full` have `Returns:` sections. - `ray.util.list_named_actors` documents `all_namespaces` and returns, including the dict entries it returns when `all_namespaces` is True. - `ray.util.spark.setup_global_ray_cluster` documents all 17 parameters and what it returns. Most entries follow the matching `setup_ray_cluster` parameter, which the existing docstring already says they share, and point to it for defaults and caps. - `ray.util.tpu.dispatch`, the deprecated alias of `run_on_slice`, gets `Args:` and `Returns:` sections. Adding `Returns:` makes pydoclint check `*args` and `**kwargs`, so they're documented too. - `ray.experimental`: `CompiledDAGRef.get` and the `CompiledDAGFuture` constructor parameters, the `RayActorHandleResolver` constructor and its `get`, `forget`, `list_names`, and `kill` methods, and the `ReduceOp`, `AllGatherOp`, `AllReduceOp`, `ReduceScatterOp`, and `Device` types are documented. - `ActorMethod.__call__` and `remote`, `ActorClassInheritanceException`, `RemoteFunction.__call__`, and `ray.types.ObjectRef` have docstrings. ## Type hints Type hints added, with the parameters documented in the same change: - `ObjectRefGenerator.send`, `throw`, `asend`, and `athrow`: `value: Any`. Each method only raises `NotImplementedError`, and the docstrings say so. - `RayError.from_bytes(b: bytes) -> BaseException` and `from_ray_exception(ray_exception: RayException) -> BaseException`. - The constructors of `CrossLanguageError`, `RayTaskError`, `RaySystemError`, `OutOfMemoryError`, and `NodeDiedError`. - `RuntimeContext.__init__(worker: Any)`. The worker is either the global Ray worker or Ray Client's `_ClientWorkerPropertyAPI`, which emulates it, so `Any` is the honest hint without new imports. - `RuntimeEnv.get(name: str, default: Any = None, data_class: Optional[type] = None) -> Any` and `get_extension(key: str)`. Return annotations corrected to match the code: - `RuntimeEnv.has_conda`: `str` to `bool`. - `RuntimeEnv.conda_env_name` and `conda_config`: `str` to `Optional[str]`. Both return None when `conda` isn't set or has the other form. - `RuntimeEnv.py_container_run_options`: `List` to `Optional[List]`. It returns None when `container` isn't set. - `ray.util.list_named_actors`: `List[str]` to `Union[List[str], List[Dict[str, str]]]`. With `all_namespaces=True`, it returns dicts with `name` and `namespace` keys. `AsyncioRouter` in `python/ray/serve/_private/router.py` reads `RayTaskError.cause` into a local variable before the `ActorDiedError` check instead of calling `getattr` in the condition. It returns the same value in the same cases. Type hints don't change runtime behavior. None of these files are in Ray's mypy hook. ## For reviewers CODEOWNERS adds two reviewers beyond `@ray-project/ray-core`: `@ray-project/ray-serve` for `serve/_private/router.py`, and one of the individual owners of `util/tpu.py`. These are worth a close read: - `setup_global_ray_cluster` returns the `(address, remote_connection_address)` tuple only when `is_blocking` is False. When blocking, it returns None after the cluster shuts down. - `CompiledDAGRef.get` describes the `timeout` values from `CompiledDAG._execute_until`, which it calls. `ray.get()` on a CompiledDAGRef calls this method. - `Device` describes its members from the `device` argument of `TorchTensorType`. - `RayTaskError.cause` is hinted `BaseException`, which matches what the task-execution path in `_raylet.pyx` and `CompiledDAG` pass. `actor_id` is the actor ID in hex, as `_raylet.pyx` computes it. - `RaySystemError.client_exc` is hinted `str`. The callers in `worker.py`, `serialization.py`, and `_raylet.pyx` pass a message string, despite the parameter name. - `RayError.from_bytes` and `from_ray_exception` return `BaseException`: an unpickled exception, an `UnserializableException`, or a `CrossLanguageError`. `ray.util.client.api.ClientAPI.list_named_actors` has the same `List[str]` annotation for Ray Client. It isn't public API, so this PR leaves it alone. ## Duplicate check No open PR documents these symbols or changes these signatures. I searched open PRs for the module, class, and method names. ray-project#66745 converts the `Queue` class docstring example to doctest form, which doesn't overlap the lines this PR changes. ## Testing These checks ran on each commit before the rebase onto `master`. The rebase applied both commits unchanged. - The full pre-commit suite on every changed file, including ruff, black, pydoclint, and the docstyle hook: passed. - `uvx [email protected] check --select D212,D200,D210` on the changed files: passed. - The docstring commit passed `ci/ray_ci/doc/check_docstring_only.py`. The type-annotation commit changes signatures, so it's outside that guard by design. - A smoke test against the latest nightly wheel with the type-annotated files overlaid: a task error and an actor task error round-trip through `to_bytes` and `from_bytes`, `ray.get_runtime_context()` works in the driver and in an actor, the exception constructors format their messages, `RuntimeEnv.get`, `get_extension`, and the re-annotated accessors return what their annotations now say, and the streaming generator's `send`, `throw`, `asend`, and `athrow` raise `NotImplementedError`. - `python/ray/tests/unit/test_runtime_env.py` and `test_runtime_env_validation.py` against the same overlay: 96 passed, 12 failed. The same 12 fail with `master`'s versions of those files in the same environment, because the nightly wheel's commit and the copied test fixtures don't match this checkout, so none come from this change. - Both commits carry an `@rtd-build` line, so the Read the Docs preview renders the changed docstrings. AI assistance (Claude Code) was used to prepare this PR. 🤖 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]> Signed-off-by: Pawel Beza <[email protected]> Upstream-commit: 6357e3c (sandbox resolver only; unrelated API changes excluded) Co-authored-by: Copilot <[email protected]> Copilot-Session: 0baa3cf-af4e-472e-ad89-8f02c6e8be11
Summary
Adds the missing docstrings,
Args:entries, andReturns:sections on public Ray Core symbols inray.runtime_env.runtime_env,ray.exceptions,ray._private.object_ref_generator, andray._private.ray_logging.logging_config. Each describes existing behavior, written from the code.This PR is stacked on #67540, which applies the ruff
D212andD200auto-fixes to the same files, so the new docstrings follow that format and the two PRs don't conflict. Review only the top commit. #67635 covers the rest of Ray Core.Before
Most
RuntimeEnvandRuntimeEnvConfigmethods had no docstring, and several exception classes andObjectRefGeneratormethods had no docstring, noArgs:entries for their constructor parameters, or noReturns:section.After
RuntimeEnv:set,serialize,deserialize,to_dict, and every field accessor, such asworking_dir,pip_config,conda_uri,py_container_image, andplugins, are documented, including what each returns when its field isn't set.RuntimeEnvConfig:parse_and_validate_runtime_env_config,default_config, andto_dictare documented.RayError.to_bytes, theRayActorError.preemptedandactor_init_failedproperties, and the constructor parameters ofRayActorError,AuthenticationError,TaskUnschedulableError, andActorUnschedulableErrorare documented.RayTaskError.make_dual_exception_instancehas aReturns:section.ObjectRefGeneratordocuments its constructor parameters,close, andaclose, andcompleted,next_ready, andis_finishedhaveReturns:sections.LoggingConfig.to_dictandfrom_dicthaveArgs:andReturns:sections.This PR also fixes two swapped
#:attribute comments inRayActorError.__init__: the comment forerror_msgdescribedactor_init_failed, and the other way around. Autodoc renders#:comments as attribute docs.Behavior is unchanged. The diff touches only docstrings and comments, which the guard below confirms.
Not in this PR
RuntimeEnvConfig.from_protoandbuild_proto_runtime_env_configconvert to and from the protobuf message, which looks like internal plumbing rather than public API. Should they stay on the public surface? Making them private isn't a docstring-only change, so this PR leaves them alone.LoggingConfigalready has a class docstring, assigned throughLoggingConfig.__doc__after the class body. A docstring in the class body would be overwritten, so nothing changes there.ObjectRefGenerator.send,throw,asend, andathrow,RayError.from_bytesandfrom_ray_exception,RuntimeEnv.getandget_extension, and the constructor parameters ofCrossLanguageError,RayTaskError,RaySystemError,OutOfMemoryError, andNodeDiedErrorhave parameters with no type hint. Ray's pydoclint config rejects anArgs:section until every parameter has a hint, so they need a separate PR that adds the hints and the docstrings together.For reviewers
These are worth a close read:
RuntimeEnv.has_condais annotated-> strbut returns a bool, andconda_env_nameandconda_configare annotated-> strbut can return None. The docstrings describe what the code returns. Fixing the annotations is a code change for a separate PR.RuntimeEnv.conda_uri,pip_uri, anduv_uridescribe the URI as a hash of the environment spec, from theget_urihelpers inray._private.runtime_env.conda_urireturns None whencondanames an existing environment.RuntimeEnv.deserializenotes that it skips validation, andserializethat it validates first, as the code does.Duplicate check
No open PR documents these symbols. I searched open PRs for the module and method names. #67540, which this PR stacks on, touches the same files for docstring format only.
Testing
python ci/ray_ci/doc/check_docstring_only.py --base upstream/doc-1903-core-docstring-autofix:docstring-only guard: 4 file(s), docstrings only.uvx [email protected] check --select D212,D200,D210on the changed files: passed, so the new docstrings don't add work for the ruff config PR.@rtd-buildline, so the Read the Docs preview renders the changed docstrings.AI assistance (Claude Code) was used to prepare this PR.
🤖 Generated with Claude Code