[Data][Train] Remove top-level ray.data imports to decouple Ray Train from Ray Data#60292
Conversation
… from Ray Data Signed-off-by: Haichuan Hu <[email protected]>
There was a problem hiding this comment.
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.
bveeramani
left a comment
There was a problem hiding this comment.
LGTM overall. Only questions are about _get_execution_options_class() and _get_execution_resources_class()
| 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 |
There was a problem hiding this comment.
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?)
… from Ray Data Signed-off-by: Haichuan Hu <[email protected]>
… from Ray Data Signed-off-by: Haichuan Hu <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
… 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]>
… 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]>
… 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]>
… 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]>
… 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]>
Description
Remove all top-level imports of
ray.datafrom theray.trainmodule. Imports needed only for type annotations should be guarded behind ifTYPE_CHECKING:. Imports needed at runtime should be moved inline (lazy imports within functions/methods).@tianyi-ge
Related issues
Fixes #60152.