Repository navigation
[data][WIP][Do not review] propose folder hierarchy - #62573
iamjustinhsu wants to merge 3 commits into
Conversation
Signed-off-by: iamjustinhsu <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request performs a comprehensive refactoring of the ray.data._internal package to improve modularity and code organization. It redistributes internal logic into several new sub-packages, including blocks for data format implementations, physical for operator logic, io for datasource and datasink management, and observability for stats and logging. The changes involve moving a large number of files and updating internal imports across the repository. I have no feedback to provide as there were no review comments to assess.
Signed-off-by: iamjustinhsu <[email protected]>
|
I think the Otherwise LGTM |
|
A couple of things:
|
Signed-off-by: iamjustinhsu <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
…mmon/ and formats/parquet/ (#66497) ## Description `python/ray/data/_internal/datasource_v2/` grouped files by role (`listing/`, `scanners/`, `readers/`, `partitioners/`, `chunkers/`), and each role folder mixed the abstract class, the format-independent implementation and the Parquet one. `listing/file_indexer.py` held `FileIndexer` next to `NonSamplingFileIndexer`, with `FooterFileIndexer` two files over. Someone adding a format could not tell from the tree what they must implement, what they may reuse, and what is Parquet's business. This PR regroups the package by kind: `interfaces/` is what a format implements, `common/` is what it may reuse, `formats/<name>/` is one folder per format. `interfaces/` imports nothing else in the package, `common/` imports only `interfaces/`, `formats/` may import both. No class, signature or behaviour changes; every import path changes. ### The layout ``` python/ray/data/_internal/datasource_v2/ __init__.py InputSplit TypeVar (unchanged) README.md new: layout rule, how a read flows, what a format implements interfaces/ abstract classes and the types their signatures use datasource_v2.py DataSourceV2, DatasourceCategory, FileDataSourceV2, DataSourceWithMetadata scanner.py Scanner reader.py Reader file_indexer.py FileIndexer, FileInfo file_pruner.py FilePruner file_partitioner.py FilePartitioner, PartitionHints in_memory_size_estimator.py InMemorySizeEstimator supports_metadata.py SupportsMetadata, MetadataType pushdown.py SupportsFilterPushdown, SupportsColumnPushdown, SupportsLimitPushdown, SupportsPartitionPruning, ListFilesPushdown read_units.py ReadUnit, ReadUnitFragment synthesized_columns.py SynthesizedColumn, ReadUnitPosition file_manifest.py FileManifest, ChunkMetadata, create_chunk_metadata common/ format-independent implementations non_sampling_file_indexer.py NonSamplingFileIndexer listing_utils.py, indexing_utils.py file_pruners.py FileExtensionPruner, PartitionPruner, PartitionPredicatePruner round_robin_partitioner.py RoundRobinPartitioner online_bin_packer.py OnlineBinPacker, BinItem, Bin size_estimators.py SamplingInMemorySizeEstimator file_scanner.py FileScanner arrow_file_scanner.py ArrowFileScanner file_reader.py FileReader synthesized_columns.py PathColumn, RowHashColumn pushdown_utils.py derive_list_files_pushdown, combine_predicates formats/ parquet/ parquet_datasource_v2.py ParquetDatasourceV2 parquet_scanner.py ParquetScanner parquet_file_reader.py ParquetFileReader footer_file_indexer.py FooterFileIndexer footer_reader.py FooterReader actor parquet_footer_types.py RowGroupInfo, FileChunks, ParquetRowGroupChunkMetadata parquet_size_estimator.py ParquetInMemorySizeEstimator parquet_file_chunking_utils.py, parquet_row_group_coalescing.py, parquet_utils.py ``` ### What changes 1. **32 renames** into the three folders; `git diff -M` pairs them, most at 90%+ similarity with the rest being import lines. 2. **7 files split** where an interface sat next to its implementations: `listing/file_indexer.py`, `listing/file_pruners.py`, `readers/in_memory_size_estimator.py`, `readers/synthesized_columns.py`, `logical_optimizers.py` (mixins to `interfaces/pushdown.py`, helpers to `common/pushdown_utils.py`), `chunkers/file_chunker.py` (dissolved into `interfaces/file_manifest.py` and `formats/parquet/parquet_footer_types.py`) and `chunkers/parquet_footer_types.py` (`BinItem`/`Bin` to `common/online_bin_packer.py`). 3. **27 files outside the package** change import lines only: `read_api.py`, the legacy `ParquetDatasource`, logical rules, planners, tests. Tests keep their locations. 4. **Nine type errors fixed** in `common/indexing_utils.py`, `common/non_sampling_file_indexer.py` and `interfaces/file_manifest.py`. These three files were in `ci/lint/pyrefly-excluded-files.txt` under their old paths, so the move puts them under pyrefly for the first time. The fixes: re-raise after `_handle_read_os_error` returns instead of reading an unbound `file_info`; the threaded lister always wraps results in `OrderedFileResult` and unwraps on yield, so `input_path_index` is an `int` and there is no `FileInfo | OrderedFileResult` union; `FileManifest.__init__` asserts a `TableBlockAccessor` before calling `column_names()`. `ci/` is not touched. 5. **`README.md`** (new) for the package. One import still crosses the layering line: `common/online_bin_packer.py` reads and writes `ParquetRowGroupChunkMetadata` from `formats/parquet/`. The packer is meant for any format with sized sub-file units, so it stays in `common/`. A follow-up PR, once #66121 has settled the packer's fields, adds a generic chunk-run type in `interfaces/` that the packer works on and makes the Parquet type a subclass of it. Doing that here would turn a reviewable set of renames into content changes. ## Additional information Follows #66450 (`[4/6]`) and #66478 (`[5/6]`), both merged; the branch sits directly on `master`. Not a duplicate: #62573 (WIP, `_internal/` wide) does not touch `datasource_v2/`. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 146 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean on every changed Python file; `tests/test_import.py` (from #66463) passes; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors, identical to `master`, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
…mmon/ and formats/parquet/ (ray-project#66497) ## Description `python/ray/data/_internal/datasource_v2/` grouped files by role (`listing/`, `scanners/`, `readers/`, `partitioners/`, `chunkers/`), and each role folder mixed the abstract class, the format-independent implementation and the Parquet one. `listing/file_indexer.py` held `FileIndexer` next to `NonSamplingFileIndexer`, with `FooterFileIndexer` two files over. Someone adding a format could not tell from the tree what they must implement, what they may reuse, and what is Parquet's business. This PR regroups the package by kind: `interfaces/` is what a format implements, `common/` is what it may reuse, `formats/<name>/` is one folder per format. `interfaces/` imports nothing else in the package, `common/` imports only `interfaces/`, `formats/` may import both. No class, signature or behaviour changes; every import path changes. ### The layout ``` python/ray/data/_internal/datasource_v2/ __init__.py InputSplit TypeVar (unchanged) README.md new: layout rule, how a read flows, what a format implements interfaces/ abstract classes and the types their signatures use datasource_v2.py DataSourceV2, DatasourceCategory, FileDataSourceV2, DataSourceWithMetadata scanner.py Scanner reader.py Reader file_indexer.py FileIndexer, FileInfo file_pruner.py FilePruner file_partitioner.py FilePartitioner, PartitionHints in_memory_size_estimator.py InMemorySizeEstimator supports_metadata.py SupportsMetadata, MetadataType pushdown.py SupportsFilterPushdown, SupportsColumnPushdown, SupportsLimitPushdown, SupportsPartitionPruning, ListFilesPushdown read_units.py ReadUnit, ReadUnitFragment synthesized_columns.py SynthesizedColumn, ReadUnitPosition file_manifest.py FileManifest, ChunkMetadata, create_chunk_metadata common/ format-independent implementations non_sampling_file_indexer.py NonSamplingFileIndexer listing_utils.py, indexing_utils.py file_pruners.py FileExtensionPruner, PartitionPruner, PartitionPredicatePruner round_robin_partitioner.py RoundRobinPartitioner online_bin_packer.py OnlineBinPacker, BinItem, Bin size_estimators.py SamplingInMemorySizeEstimator file_scanner.py FileScanner arrow_file_scanner.py ArrowFileScanner file_reader.py FileReader synthesized_columns.py PathColumn, RowHashColumn pushdown_utils.py derive_list_files_pushdown, combine_predicates formats/ parquet/ parquet_datasource_v2.py ParquetDatasourceV2 parquet_scanner.py ParquetScanner parquet_file_reader.py ParquetFileReader footer_file_indexer.py FooterFileIndexer footer_reader.py FooterReader actor parquet_footer_types.py RowGroupInfo, FileChunks, ParquetRowGroupChunkMetadata parquet_size_estimator.py ParquetInMemorySizeEstimator parquet_file_chunking_utils.py, parquet_row_group_coalescing.py, parquet_utils.py ``` ### What changes 1. **32 renames** into the three folders; `git diff -M` pairs them, most at 90%+ similarity with the rest being import lines. 2. **7 files split** where an interface sat next to its implementations: `listing/file_indexer.py`, `listing/file_pruners.py`, `readers/in_memory_size_estimator.py`, `readers/synthesized_columns.py`, `logical_optimizers.py` (mixins to `interfaces/pushdown.py`, helpers to `common/pushdown_utils.py`), `chunkers/file_chunker.py` (dissolved into `interfaces/file_manifest.py` and `formats/parquet/parquet_footer_types.py`) and `chunkers/parquet_footer_types.py` (`BinItem`/`Bin` to `common/online_bin_packer.py`). 3. **27 files outside the package** change import lines only: `read_api.py`, the legacy `ParquetDatasource`, logical rules, planners, tests. Tests keep their locations. 4. **Nine type errors fixed** in `common/indexing_utils.py`, `common/non_sampling_file_indexer.py` and `interfaces/file_manifest.py`. These three files were in `ci/lint/pyrefly-excluded-files.txt` under their old paths, so the move puts them under pyrefly for the first time. The fixes: re-raise after `_handle_read_os_error` returns instead of reading an unbound `file_info`; the threaded lister always wraps results in `OrderedFileResult` and unwraps on yield, so `input_path_index` is an `int` and there is no `FileInfo | OrderedFileResult` union; `FileManifest.__init__` asserts a `TableBlockAccessor` before calling `column_names()`. `ci/` is not touched. 5. **`README.md`** (new) for the package. One import still crosses the layering line: `common/online_bin_packer.py` reads and writes `ParquetRowGroupChunkMetadata` from `formats/parquet/`. The packer is meant for any format with sized sub-file units, so it stays in `common/`. A follow-up PR, once ray-project#66121 has settled the packer's fields, adds a generic chunk-run type in `interfaces/` that the packer works on and makes the Parquet type a subclass of it. Doing that here would turn a reviewable set of renames into content changes. ## Additional information Follows ray-project#66450 (`[4/6]`) and ray-project#66478 (`[5/6]`), both merged; the branch sits directly on `master`. Not a duplicate: ray-project#62573 (WIP, `_internal/` wide) does not touch `datasource_v2/`. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 146 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean on every changed Python file; `tests/test_import.py` (from ray-project#66463) passes; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors, identical to `master`, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
ray/data/_internal/Directory StructureOverview
The
_internal/directory is organized into 15 semantic domains, each owning adistinct area of responsibility in Ray Data's implementation.
Design Principles
from ray.data._internal.physical.map_operator import MapOperator.public_api/— old locations remain as deprecation shims.[shim]files forward imports with aDeprecationWarningso external code thatreferences old paths continues to work during migration.