Skip to content

[train] Create top-level ray.train aliases for public APIs#57758

Merged
justinvyu merged 15 commits intoray-project:masterfrom
justinvyu:v2_module_aliases
Oct 17, 2025
Merged

[train] Create top-level ray.train aliases for public APIs#57758
justinvyu merged 15 commits intoray-project:masterfrom
justinvyu:v2_module_aliases

Conversation

@justinvyu
Copy link
Copy Markdown
Contributor

@justinvyu justinvyu commented Oct 15, 2025

Description

Add top-level aliases for public APIs. Users should never import from internal modules.

This includes:

  • ray.train.TrainingFailedError
  • ray.train.WorkerGroupError
  • ray.train.ControllerError
  • ray.train.TrainContext

Also removes the top-level ray.train.TrainingIterator import since this is a V1 DeveloperAPI that shouldn't be imported anymore.

Related issues

Types of change

  • Bug fix 🐛
  • New feature ✨
  • Enhancement 🚀
  • Code refactoring 🔧
  • Documentation update 📖
  • Chore 🧹
  • Style 🎨

Checklist

Does this PR introduce breaking changes?

  • Yes ⚠️
  • No

Testing:

  • Added/updated tests for my changes
  • Tested the changes manually
  • This PR is not tested ❌ (please explain why)

Code Quality:

  • Signed off every commit (git commit -s)
  • Ran pre-commit hooks (setup guide)

Documentation:

  • Updated documentation (if applicable) (contribution guide)
  • Added new APIs to doc/source/ (if applicable)

Additional context

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Copy link
Copy Markdown
Contributor

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

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 refactors Ray Train's public API by creating top-level aliases for TrainingFailedError, WorkerGroupError, ControllerError, and TrainContext in the ray.train namespace. This is a good improvement for user experience, as it avoids imports from internal modules. The changes in the documentation and the __init__.py file are mostly correct. I've found a couple of minor issues regarding redundancy and consistency in __init__.py and have left specific comments with suggestions to address them.

cursor[bot]

This comment was marked as outdated.

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
~train.v2.api.exceptions.WorkerGroupError
~train.ControllerError
~train.WorkerGroupError
~train.TrainingFailedError
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.

curious how the generated doc looks like for this since it's just a union of the other two errors

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
@ray-gardener ray-gardener bot added the train Ray Train Related Issue label Oct 16, 2025
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
cursor[bot]

This comment was marked as outdated.

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
@justinvyu justinvyu added the go add ONLY when ready to merge, run all tests label Oct 16, 2025
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
@justinvyu justinvyu requested a review from a team as a code owner October 17, 2025 18:13
Copy link
Copy Markdown
Collaborator

@aslonnie aslonnie left a comment

Choose a reason for hiding this comment

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

approve for check_api_discrepancy change

@justinvyu justinvyu merged commit 3c24f0f into ray-project:master Oct 17, 2025
6 checks passed
@justinvyu justinvyu deleted the v2_module_aliases branch October 17, 2025 19:25
justinyeh1995 pushed a commit to justinyeh1995/ray that referenced this pull request Oct 20, 2025
…ct#57758)

Add top-level aliases for public APIs. Users should never import from
internal modules.

This includes:
* `ray.train.TrainingFailedError`
* `ray.train.WorkerGroupError`
* `ray.train.ControllerError`
* `ray.train.TrainContext`

Also removes the top-level `ray.train.TrainingIterator` import since
this is a V1 DeveloperAPI that shouldn't be imported anymore.

---------

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 22, 2025
…ct#57758)

Add top-level aliases for public APIs. Users should never import from
internal modules.

This includes:
* `ray.train.TrainingFailedError`
* `ray.train.WorkerGroupError`
* `ray.train.ControllerError`
* `ray.train.TrainContext`

Also removes the top-level `ray.train.TrainingIterator` import since
this is a V1 DeveloperAPI that shouldn't be imported anymore.

---------

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: xgui <xgui@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Oct 23, 2025
Add top-level aliases for public APIs. Users should never import from
internal modules.

This includes:
* `ray.train.TrainingFailedError`
* `ray.train.WorkerGroupError`
* `ray.train.ControllerError`
* `ray.train.TrainContext`

Also removes the top-level `ray.train.TrainingIterator` import since
this is a V1 DeveloperAPI that shouldn't be imported anymore.

---------

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
…ct#57758)

Add top-level aliases for public APIs. Users should never import from
internal modules.

This includes:
* `ray.train.TrainingFailedError`
* `ray.train.WorkerGroupError`
* `ray.train.ControllerError`
* `ray.train.TrainContext`

Also removes the top-level `ray.train.TrainingIterator` import since
this is a V1 DeveloperAPI that shouldn't be imported anymore.

---------

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Nov 19, 2025
…ct#57758)

Add top-level aliases for public APIs. Users should never import from
internal modules.

This includes:
* `ray.train.TrainingFailedError`
* `ray.train.WorkerGroupError`
* `ray.train.ControllerError`
* `ray.train.TrainContext`

Also removes the top-level `ray.train.TrainingIterator` import since
this is a V1 DeveloperAPI that shouldn't be imported anymore.

---------

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Aydin Abiar <aydin@anyscale.com>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
…ct#57758)

Add top-level aliases for public APIs. Users should never import from
internal modules.

This includes:
* `ray.train.TrainingFailedError`
* `ray.train.WorkerGroupError`
* `ray.train.ControllerError`
* `ray.train.TrainContext`

Also removes the top-level `ray.train.TrainingIterator` import since
this is a V1 DeveloperAPI that shouldn't be imported anymore.

---------

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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