Skip to content

[Data][Train] Remove top-level ray.data imports to decouple Ray Train from Ray Data#60292

Merged
bveeramani merged 7 commits intoray-project:masterfrom
KaisennHu:decouple-ray-data
Jan 20, 2026
Merged

[Data][Train] Remove top-level ray.data imports to decouple Ray Train from Ray Data#60292
bveeramani merged 7 commits intoray-project:masterfrom
KaisennHu:decouple-ray-data

Conversation

@KaisennHu
Copy link
Contributor

@KaisennHu KaisennHu commented Jan 19, 2026

Description

Remove all top-level imports of ray.data from the ray.train module. Imports needed only for type annotations should be guarded behind if TYPE_CHECKING:. Imports needed at runtime should be moved inline (lazy imports within functions/methods).
@tianyi-ge

Related issues

Fixes #60152.

@KaisennHu KaisennHu requested a review from a team as a code owner January 19, 2026 11:48
Copy link
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 effectively decouples Ray Train from Ray Data by removing top-level ray.data imports. The changes are implemented consistently across all modified files, using TYPE_CHECKING guards for type annotations and lazy, inline imports for runtime dependencies. This is a solid refactoring that improves modularity and dependency management within the Ray ecosystem. The implementation is clean and correct, and I have no further suggestions.

@ray-gardener ray-gardener bot added train Ray Train Related Issue community-contribution Contributed by the community labels Jan 19, 2026
Copy link
Member

@bveeramani bveeramani left a comment

Choose a reason for hiding this comment

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

LGTM overall. Only questions are about _get_execution_options_class() and _get_execution_resources_class()

Comment on lines +12 to +25
def _get_execution_options_class():
"""Lazy import of ExecutionOptions."""
from ray.data import ExecutionOptions

return ExecutionOptions


def _get_execution_resources_class():
"""Lazy import of ExecutionResources."""
from ray.data._internal.execution.interfaces.execution_options import (
ExecutionResources,
)

return ExecutionResources
Copy link
Member

Choose a reason for hiding this comment

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

What happens if we import these under if TYPE_CHECKING? If that doesn't work, what happens if we import these in the function definitions (e.g., in the DataConfig constructor?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it.

@bveeramani bveeramani enabled auto-merge (squash) January 20, 2026 21:03
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Jan 20, 2026
@bveeramani bveeramani merged commit b16808c into ray-project:master Jan 20, 2026
7 of 8 checks passed
@KaisennHu KaisennHu deleted the decouple-ray-data branch January 24, 2026 02:04
jinbum-kim pushed a commit to jinbum-kim/ray that referenced this pull request Jan 29, 2026
… from Ray Data (ray-project#60292)

## Description
Remove all top-level imports of `ray.data` from the `ray.train` module.
Imports needed only for type annotations should be guarded behind if
`TYPE_CHECKING:`. Imports needed at runtime should be moved inline (lazy
imports within functions/methods).

## Related issues
Fixes ray-project#60152.

---------

Signed-off-by: Haichuan Hu <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Signed-off-by: jinbum-kim <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Feb 1, 2026
… from Ray Data (ray-project#60292)

## Description
Remove all top-level imports of `ray.data` from the `ray.train` module.
Imports needed only for type annotations should be guarded behind if
`TYPE_CHECKING:`. Imports needed at runtime should be moved inline (lazy
imports within functions/methods).

## Related issues
Fixes ray-project#60152.

---------

Signed-off-by: Haichuan Hu <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Signed-off-by: 400Ping <[email protected]>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Feb 3, 2026
… from Ray Data (ray-project#60292)

## Description
Remove all top-level imports of `ray.data` from the `ray.train` module.
Imports needed only for type annotations should be guarded behind if
`TYPE_CHECKING:`. Imports needed at runtime should be moved inline (lazy
imports within functions/methods).

## Related issues
Fixes ray-project#60152.

---------

Signed-off-by: Haichuan Hu <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
… from Ray Data (ray-project#60292)

## Description
Remove all top-level imports of `ray.data` from the `ray.train` module.
Imports needed only for type annotations should be guarded behind if
`TYPE_CHECKING:`. Imports needed at runtime should be moved inline (lazy
imports within functions/methods).

## Related issues
Fixes ray-project#60152.

---------

Signed-off-by: Haichuan Hu <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Signed-off-by: peterxcli <[email protected]>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
… from Ray Data (ray-project#60292)

## Description
Remove all top-level imports of `ray.data` from the `ray.train` module.
Imports needed only for type annotations should be guarded behind if
`TYPE_CHECKING:`. Imports needed at runtime should be moved inline (lazy
imports within functions/methods).

## Related issues
Fixes ray-project#60152.

---------

Signed-off-by: Haichuan Hu <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Signed-off-by: peterxcli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community 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.

[Data][Train] Remove top-level ray.data imports to decouple Ray Train from Ray Data

3 participants