Skip to content

[train] Enable v2 for train py_doctest - #57256

Merged
justinvyu merged 13 commits into
ray-project:masterfrom
justinvyu:train_doctest
Oct 8, 2025
Merged

justinvyu merged 13 commits into
ray-project:masterfrom
justinvyu:train_doctest

Conversation

@justinvyu

Copy link
Copy Markdown
Contributor

Summary

Enables Train V2 for py_doctest.

Train v2 doctest wasn't running before this, so this PR also enables those to run in CI. This was because Bazel glob stops at nested BUILD.bazel files.

Justin Yu added 3 commits October 6, 2025 19:09
Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: Justin Yu <[email protected]>
@justinvyu
justinvyu requested a review from a team as a code owner October 7, 2025 02:12

@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

Overall, the changes in this pull request are well-aligned with the goal of enabling and fixing doctests for Ray Train V2. The modifications to the build files and the updates to the doctest examples are logical and consistent. I've found one critical issue that needs to be addressed.

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation train Ray Train Related Issue labels Oct 7, 2025

@liulehui liulehui 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.

 🚀

Signed-off-by: Justin Yu <[email protected]>
@justinvyu
justinvyu enabled auto-merge (squash) October 7, 2025 23:05
@github-actions github-actions Bot added the go add ONLY when ready to merge, run all tests label Oct 7, 2025
Justin Yu added 3 commits October 7, 2025 16:30
@github-actions
github-actions Bot disabled auto-merge October 8, 2025 00:16
cursor[bot]

This comment was marked as outdated.

Justin Yu added 3 commits October 7, 2025 19:05
Signed-off-by: Justin Yu <[email protected]>
@justinvyu
justinvyu merged commit 17d6299 into ray-project:master Oct 8, 2025
@justinvyu
justinvyu deleted the train_doctest branch October 8, 2025 06:06
ArturNiederfahrenhorst pushed a commit to ArturNiederfahrenhorst/ray that referenced this pull request Oct 13, 2025
Enables Train V2 for py_doctest.

Train v2 doctest wasn't running before this, so this PR also enables
those to run in CI. This was because Bazel glob stops at nested
BUILD.bazel files.

---------

Signed-off-by: Justin Yu <[email protected]>
justinvyu pushed a commit that referenced this pull request Oct 16, 2025
Ports over the remaining unit tests that were marked as TODOs from this
series of PRs: #57534, #57256, #56868, #56820, #56816.

Notably:
* `test_new_dataset_config -> test_data_integration`
* `test_backend -> test_torch_trainer, test_worker_group`
* `test_gpu -> test_torch_gpu`

This PR also finishes migrating the Tune LightGBM/Keras examples which
were unblocked by #57042 and
#57121.

---------

Signed-off-by: Justin Yu <[email protected]>
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 22, 2025
Enables Train V2 for py_doctest.

Train v2 doctest wasn't running before this, so this PR also enables
those to run in CI. This was because Bazel glob stops at nested
BUILD.bazel files.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: xgui <[email protected]>
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 22, 2025
Ports over the remaining unit tests that were marked as TODOs from this
series of PRs: ray-project#57534, ray-project#57256, ray-project#56868, ray-project#56820, ray-project#56816.

Notably:
* `test_new_dataset_config -> test_data_integration`
* `test_backend -> test_torch_trainer, test_worker_group`
* `test_gpu -> test_torch_gpu`

This PR also finishes migrating the Tune LightGBM/Keras examples which
were unblocked by ray-project#57042 and
ray-project#57121.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: xgui <[email protected]>
snorkelopsstgtesting1-spec pushed a commit to snorkel-marlin-repos/ray-project_ray_pr_57256_27e4ffe4-80af-4a1d-baf7-52fd600b4bd2 that referenced this pull request Oct 22, 2025
Original PR #57256 by justinvyu
Original: ray-project/ray#57256
snorkelopstesting1-a11y added a commit to snorkel-marlin-repos/ray-project_ray_pr_57256_27e4ffe4-80af-4a1d-baf7-52fd600b4bd2 that referenced this pull request Oct 22, 2025
elliot-barn pushed a commit that referenced this pull request Oct 23, 2025
Enables Train V2 for py_doctest.

Train v2 doctest wasn't running before this, so this PR also enables
those to run in CI. This was because Bazel glob stops at nested
BUILD.bazel files.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
elliot-barn pushed a commit that referenced this pull request Oct 23, 2025
Ports over the remaining unit tests that were marked as TODOs from this
series of PRs: #57534, #57256, #56868, #56820, #56816.

Notably:
* `test_new_dataset_config -> test_data_integration`
* `test_backend -> test_torch_trainer, test_worker_group`
* `test_gpu -> test_torch_gpu`

This PR also finishes migrating the Tune LightGBM/Keras examples which
were unblocked by #57042 and
#57121.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
Enables Train V2 for py_doctest.

Train v2 doctest wasn't running before this, so this PR also enables
those to run in CI. This was because Bazel glob stops at nested
BUILD.bazel files.

---------

Signed-off-by: Justin Yu <[email protected]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
Ports over the remaining unit tests that were marked as TODOs from this
series of PRs: ray-project#57534, ray-project#57256, ray-project#56868, ray-project#56820, ray-project#56816.

Notably:
* `test_new_dataset_config -> test_data_integration`
* `test_backend -> test_torch_trainer, test_worker_group`
* `test_gpu -> test_torch_gpu`

This PR also finishes migrating the Tune LightGBM/Keras examples which
were unblocked by ray-project#57042 and
ray-project#57121.

---------

Signed-off-by: Justin Yu <[email protected]>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
Enables Train V2 for py_doctest.

Train v2 doctest wasn't running before this, so this PR also enables
those to run in CI. This was because Bazel glob stops at nested
BUILD.bazel files.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
Ports over the remaining unit tests that were marked as TODOs from this
series of PRs: ray-project#57534, ray-project#57256, ray-project#56868, ray-project#56820, ray-project#56816.

Notably:
* `test_new_dataset_config -> test_data_integration`
* `test_backend -> test_torch_trainer, test_worker_group`
* `test_gpu -> test_torch_gpu`

This PR also finishes migrating the Tune LightGBM/Keras examples which
were unblocked by ray-project#57042 and
ray-project#57121.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
pseudo-rnd-thoughts pushed a commit that referenced this pull request Nov 16, 2026
…n legacy LightGBM/XGBoost trainers (#68145)

## Why are these changes needed?

In `_get_legacy_train_fn_per_worker` for both `LightGBMTrainer`
(`python/ray/train/lightgbm/lightgbm_trainer.py`) and `XGBoostTrainer`
(`python/ray/train/xgboost/xgboost_trainer.py`):

1. `num_boost_round = num_boost_round or DEFAULT_NUM_BOOST_ROUND` used
truthiness instead of an explicit `is None` check. When a caller
explicitly passed `num_boost_round=0` (for example in dry-run
initialization or checkpoint evaluation without additional boosting
rounds), `0 or 10` silently evaluated to `10`.
2. `callbacks = trainer_kwargs.get("callbacks", [])` retrieved the
caller's list reference directly and appended `default_callback_cls()`
in-place (`callbacks.append(...)`). Reusing the same configuration
dictionary across multiple `Trainer` instantiations mutated the caller's
`callbacks` list on each run, and passing `callbacks=None` or a tuple
raised an `AttributeError`.

This PR:
- Checks `if num_boost_round is None: num_boost_round =
DEFAULT_NUM_BOOST_ROUND` so explicit `0` is preserved.
- Copies `callbacks = list(trainer_kwargs.get("callbacks") or [])`
before appending the default `RayTrainReportCallback`.

## Related issue number

N/A

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
- [x] Unit tests (`python/ray/train/tests/test_lightgbm_trainer.py` and
`python/ray/train/tests/test_xgboost_trainer.py`)
   - [ ] Release tests
   - [ ] This PR is not tested :(

## Acknowledgements

Thanks to @dstrodtman (#67821, #67786, #67620), @pseudo-rnd-thoughts
(#63988, #63427, #63365), and @justinvyu (#57256, #50042) for their work
maintaining `LightGBMTrainer` and `XGBoostTrainer`.

---------

Signed-off-by: Parth Vadera <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs An issue or change related to documentation go add ONLY when ready to merge, run all tests train Ray Train Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants