Repository navigation
[train] Add missing docstrings, Args, and Returns across core Train and AIR - #67621
Merged
Merged
Conversation
…nd AIR Backfill docstrings, Args entries, and Returns sections on public Ray Train and AIR symbols in ray.train.v2, ray.train.context, ray.train._internal, ray.train._checkpoint, ray.train.health, and ray.air.config. Each describes existing behavior. The Returns sections on the ray.train._internal.session accessors also document ray.train.context.TrainContext and ray.tune.context.TuneContext, which copy those docstrings through _copy_doc. Docstring-only: no code changes. @rtd-build Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
This was referenced Oct 30, 2026
Merged
pseudo-rnd-thoughts
approved these changes
Oct 30, 2026
pseudo-rnd-thoughts
pushed a commit
that referenced
this pull request
Nov 2, 2026
…tegrations (#67620) ## Summary Adds the missing docstrings, `Args:` entries, and `Returns:` sections on public Ray Train symbols in the framework integrations: Lightning, Torch, TensorFlow, Horovod, Hugging Face Transformers, LightGBM, and XGBoost. Each describes existing behavior, written from the code. #67621 covers core Train and AIR. ## Before Across these integrations, 23 public symbols had no docstring, 14 parameters had no `Args:` entry, and 13 callables that annotate a return type had no `Returns:` section. `TensorflowConfig` had no class docstring. ## After - The Lightning strategies' `root_device` and `distributed_sampler_kwargs`, every `RayLightningEnvironment` method, and `RayTrainReportCallback.on_train_epoch_end` have docstrings. - Both `prepare_trainer` functions document `trainer` and what they return. - The `get_model` methods on the LightGBM and XGBoost checkpoints and trainers document their arguments and return value. - `BackendConfig.backend_cls`, `train_func_context`, `framework`, and `to_dict` are documented on the base class rather than on each override, so `TorchConfig`, `TorchXLAConfig`, `TensorflowConfig`, `HorovodConfig`, and `JaxConfig` inherit them. Behavior is unchanged. The diff touches only docstrings, which the guard below confirms. ## Not in this PR 8 parameters on three methods with untyped signatures: the Lightning `RayTrainReportCallback.__init__` (`checkpoint_upload_mode`, `validation`, `checkpoint_frequency`) and `on_train_epoch_end` (`trainer`, `pl_module`), and the Transformers `RayTrainReportCallback.on_save` (`args`, `state`, `control`). pydoclint runs with `--arg-type-hints-in-signature`, so an `Args:` section on these raises DOC106 and DOC107. Documenting them needs a signature change, which doesn't belong in a docstring-only PR. #67622, stacked on this PR, adds the type hints and documents them. ## For reviewers These are worth a close read: - `RayFSDPStrategy.lightning_module_state_dict`: the `Returns:` section describes the Lightning 2.0.x full-state-dict path and the fallback to the parent strategy. - `HorovodConfig.start_timeout`: the docstring says Horovod reads it when the config serves as its settings object, since `_HorovodBackend` passes the config to Horovod's `Coordinator`. - `RayLightningEnvironment.teardown` does nothing; the docstring says so rather than inventing a reason. ## Duplicate check No open PR documents these symbols. Searches for `docstring train`, `RayTrainReportCallback`, `TorchConfig`, `prepare_trainer`, and the changed paths returned nothing overlapping. ## Testing - `python ci/ray_ci/doc/check_docstring_only.py --base "$(git merge-base upstream/master HEAD)"`: `docstring-only guard: 9 file(s), docstrings only.` - The full pre-commit suite on the changed files, including ruff, black, pydoclint, and the docstyle hook: passed. - `ci/ray_ci/doc/api_param_coverage.py` over the changed integrations: 14 undocumented parameters on `master`, 8 on this branch, all on the untyped signatures listed above. - 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]>
dstrodtman
added a commit
that referenced
this pull request
Nov 2, 2026
… can be documented (#67622) ## Summary Adds type hints to four public Ray Train callback methods so their parameters can be documented, and documents them: the Lightning `RayTrainReportCallback` constructor and `on_train_epoch_end`, the Transformers `RayTrainReportCallback.on_save`, and `WandbLoggerCallback.on_experiment_end`. Stacked on #67620, which writes the docstrings these `Args:` sections extend. It retargets to `master` once #67620 merges. ## Why this isn't in the docstring-only PRs Ray's pydoclint hook runs with `--arg-type-hints-in-signature`, so it rejects an `Args:` section on a signature without type hints (DOC106, DOC107). These methods had none, or had an unannotated `**info`, so documenting their 9 parameters needs a signature change. A signature change isn't docstring-only, so it's in its own PR without the `docstring-only` label, and premerge runs Train's tests on it. ## Changes - Lightning `RayTrainReportCallback.__init__`: `checkpoint_upload_mode: Optional["CheckpointUploadMode"]` and `validation: Union[bool, "ValidationTaskConfig"]`, matching what the callback passes to `ray.train.report`. The class docstring's prose list of arguments becomes an `Args:` section, plus a `Raises:` section for the existing `TypeError` and `ValueError` checks. - Lightning `RayTrainReportCallback.on_train_epoch_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule) -> None`, with `Args:`. - Transformers `RayTrainReportCallback.on_save(self, args: "TrainingArguments", state: "TrainerState", control: "TrainerControl", **kwargs: Any) -> None`, with `Args:`. - `WandbLoggerCallback.on_experiment_end(self, trials: List["Trial"], **info: Any)`, with `Args:`. The type hints don't change behavior. `ValidationTaskConfig` and the three Transformers types are imported under `TYPE_CHECKING` only, so the runtime imports of both modules are unchanged. `CheckpointUploadMode` is a string annotation on the module's existing conditional import. ## Duplicate check No open PR changes these signatures. Searches for `RayTrainReportCallback`, `WandbLoggerCallback`, and the changed paths returned nothing overlapping. #67621, the sibling docstring PR for core Train and AIR, doesn't touch these files. ## Testing - The full pre-commit suite on the changed files, including ruff, black, pydoclint, and the docstyle hook: passed. - `ci/ray_ci/doc/api_param_coverage.py` over the Lightning and Transformers integrations and `wandb.py`: 16 undocumented parameters on the base branch, 7 on this one. The remaining 7 are on `WandbLoggerCallback`'s `log_trial_*` methods, which this PR leaves alone. - Train's unit tests run in premerge on this PR. Lightning, Transformers, and W&B aren't installed in my local environment, so I couldn't import-test the changed modules locally. 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the missing docstrings,
Args:entries, andReturns:sections on public Ray Train and AIR symbols inray.train.v2,ray.train.context,ray.train._internal,ray.train._checkpoint,ray.train.health, andray.air.config. Each describes existing behavior, written from the code. #67620 covers the framework integrations.Before
Across these modules, 13 public symbols had no docstring, 4 parameters had no
Args:entry, and 31 callables that annotate a return type had noReturns:section.After
ray.train._internal.sessionaccessors (get_metadata,get_experiment_name,get_trial_name,get_trial_id,get_run_id,get_trial_resources,get_trial_dir,get_world_size,get_world_rank,get_local_rank) haveReturns:sections, including the default each returns outside a Train or Tune function.ray.train.v2TrainContextmethods, bothget_contextfunctions,JaxConfig,ValidationFn.__call__,CheckpointUploadMode.default_delete_local_checkpoint_after_upload, andRunConfig.storage_contextare documented.Checkpoint.get_metadata,set_metadata, andupdate_metadata,DataConfig.default_ingest_options, bothScalingConfigplacement-group methods, andProbe.probe_nameare documented.ray.train.context.TrainContextandray.tune.context.TuneContextcopy their accessor docstrings fromray.train._internal.sessionthrough@_copy_doc, so the sessionReturns:sections document those methods too. A docstring written on the context methods would be overwritten.Behavior is unchanged. The diff touches only docstrings, which the guard below confirms.
Not in this PR
JaxConfig.backend_cls,framework, andto_dictinherit their docstrings fromBackendConfig, which [train] Add missing docstrings, Args, and Returns to the framework integrations #67620 documents.WandbLoggerCallback.on_experiment_end: its**infoparameter has no type hint, so anArgs:section raises pydoclint DOC107 under--arg-type-hints-in-signature. [train] Type-annotate four Train callback methods so their parameters can be documented #67622 adds the type hint and documents it.For reviewers
These are worth a close read:
@PublicAPIbut have no public import path. They're documented here because the publicTrainContextandTuneContextrender their docstrings. Whether they stay public is a separate question.ScalingConfig.as_placement_group_factorydescribes the bundle layout: an empty head bundle, a bundle combining the trainer with the first worker, and one bundle per other worker.JaxConfigdocuments that Ray Train skips JAX distributed setup when neitheruse_tpunoruse_gpuis set.Duplicate check
No open PR documents these symbols. #67521 changes Ray Train health probes but touches only
ray.train.v2._internal, nothealth/probe.py.Testing
python ci/ray_ci/doc/check_docstring_only.py --base "$(git merge-base upstream/master HEAD)":docstring-only guard: 12 file(s), docstrings only.ci/ray_ci/doc/api_param_coverage.pyover the changed modules andray.air.integrations: 11 undocumented parameters onmaster, 8 on this branch. The rest are onWandbLoggerCallback, outside this PR's scope or blocked as above.@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