[Data] Expose logical rules via package exports#60296
[Data] Expose logical rules via package exports#60296bveeramani merged 5 commits intoray-project:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the ray.data._internal.logical.rules package to provide a single entry point for importing logical rules, which improves code organization and maintainability. The changes involve dynamically exporting symbols from submodules via __init__.py, adding __all__ to the respective rule modules, and updating import statements in consumers.
The implementation is clean and achieves the stated goal. I have one suggestion to make the dynamic exporting in __init__.py more robust by handling potential name collisions between modules.
55c601d to
366d2ca
Compare
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
| This module dynamically imports each submodule in the package and re-exports | ||
| names listed in the submodule's __all__ attribute. This allows callers to | ||
| import rules directly from ray.data._internal.logical.rules. | ||
| """ | ||
|
|
||
| from importlib import import_module | ||
| from pkgutil import iter_modules | ||
|
|
||
| __all__ = [] | ||
|
|
||
| for _loader, _module_name, _is_pkg in iter_modules(__path__): | ||
| if _module_name.startswith("_"): | ||
| continue | ||
| _module = import_module(f"{__name__}.{_module_name}") | ||
| _exported_names = getattr(_module, "__all__", []) | ||
| for _name in _exported_names: | ||
| globals()[_name] = getattr(_module, _name) | ||
| __all__.extend(_exported_names) | ||
|
|
||
| __all__.sort() |
There was a problem hiding this comment.
Rather than using a script, can we explicitly list out the dependencies? e.g., from .inherit_batch_format import ...? I think it'll be easier to read and maintain
Signed-off-by: 400Ping <jiekai.chang326@gmail.com> Signed-off-by: 400Ping <fourhundredping@gmail.com>
Signed-off-by: 400Ping <fourhundredping@gmail.com>
|
Checked the microcheck error, doesn't seems to be related to this PR? |
## Description ### Goal Make ray.data._internal.logical.rules a proper package entry point with short imports and alphabetized `__all__`. ### Changes Add/complete `__all__` in rule modules and re-export via `__init__.py`. Update imports to `from ray.data._internal.logical.rules import ...`. Keep helper imports module-scoped to avoid circular dependencies. ## Related issues Related to ray-project#60204 ## Additional information --------- Signed-off-by: 400Ping <jiekai.chang326@gmail.com> Signed-off-by: 400Ping <fourhundredping@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com>
## Description ### Goal Make ray.data._internal.logical.rules a proper package entry point with short imports and alphabetized `__all__`. ### Changes Add/complete `__all__` in rule modules and re-export via `__init__.py`. Update imports to `from ray.data._internal.logical.rules import ...`. Keep helper imports module-scoped to avoid circular dependencies. ## Related issues Related to ray-project#60204 ## Additional information --------- Signed-off-by: 400Ping <jiekai.chang326@gmail.com> Signed-off-by: 400Ping <fourhundredping@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: jinbum-kim <jinbum9958@gmail.com>
## Description ### Goal Make ray.data._internal.logical.rules a proper package entry point with short imports and alphabetized `__all__`. ### Changes Add/complete `__all__` in rule modules and re-export via `__init__.py`. Update imports to `from ray.data._internal.logical.rules import ...`. Keep helper imports module-scoped to avoid circular dependencies. ## Related issues Related to ray-project#60204 ## Additional information --------- Signed-off-by: 400Ping <jiekai.chang326@gmail.com> Signed-off-by: 400Ping <fourhundredping@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: peterxcli <peterxcli@gmail.com>
## Description ### Goal Make ray.data._internal.logical.rules a proper package entry point with short imports and alphabetized `__all__`. ### Changes Add/complete `__all__` in rule modules and re-export via `__init__.py`. Update imports to `from ray.data._internal.logical.rules import ...`. Keep helper imports module-scoped to avoid circular dependencies. ## Related issues Related to ray-project#60204 ## Additional information --------- Signed-off-by: 400Ping <jiekai.chang326@gmail.com> Signed-off-by: 400Ping <fourhundredping@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: peterxcli <peterxcli@gmail.com>
Description
Goal
Make ray.data._internal.logical.rules a proper package entry point with short imports and alphabetized
__all__.Changes
Add/complete
__all__in rule modules and re-export via__init__.py.Update imports to
from ray.data._internal.logical.rules import ....Keep helper imports module-scoped to avoid circular dependencies.
Related issues
Related to #60204
Additional information