Repository navigation
Conversation
ca6d1f9 to
579e7ce
Compare
There was a problem hiding this comment.
Code Review
This pull request updates several instances of md5 hashing across the codebase to explicitly set usedforsecurity=False, ensuring compatibility with FIPS-compliant environments where standard MD5 usage is restricted. There are no review comments to address, and I have no additional feedback to provide.
…urity=False hashlib.md5() raises on FIPS-enabled OpenSSL because MD5 isn't in the OpenSSL FIPS provider. hashlib.blake2b() is served by the _blake2 builtin rather than OpenSSL, but distributions that wrap the builtins when _hashlib.get_fips_mode() is set reject it the same way, so both need the same treatment. ray-project#40755 fixed this for runtime_env by moving to SHA-1, which the FIPS provider does allow. These five calls are what is left, and in each the digest value matters so the algorithm can't change: - _generate_arm_guid replicates ARM's guid(), which is defined as MD5 - _rewrite_iceberg_file needs a stable write_uuid so retries overwrite the same object, and uuid.UUID wants 128 bits anyway - _compute_row_hashes uses the digest as a reproducible 64-bit seed - Dataset.train_test_split buckets rows by a digest of the split key - get_worker_id derives a Dynamo worker id from a replica's unique id All five derive an identifier from a string rather than doing anything security related, so usedforsecurity=False fits, and it leaves the digests identical. Signed-off-by: Thomas Bechtold <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
579e7ce to
b6e6eee
Compare
|
@dstrodtman could you maybe have a look at this? or point to somebody who could? |
## Description Since #66357, `import ray.data` loads `pyarrow.dataset` and its native extensions. The legacy `parquet_datasource.py` now imports `_compute_row_hashes` from the V2 readers package at module level, and the V2 reader modules import `pyarrow.dataset` at load time. Before #66357, the dependency ran the other way and `ray.data` never reached `pyarrow.dataset` on import. This PR moves the `_compute_row_hashes` import into `_read_batches_from`, its only caller. That matches the file's existing function-level `pyarrow.dataset` imports. The import points at `readers/synthesized_columns.py`, where the helper has lived since #66390, rather than at the `file_reader` re-export. Importing from `synthesized_columns` at module level isn't enough on its own, because `read_units.py` also imports `pyarrow.dataset` at the top level. It also adds `test_import_does_not_load_pyarrow_dataset` to `python/ray/data/tests/test_import.py`. The test asserts that a fresh driver's `import ray.data` loads no `pyarrow._dataset*` modules. ### Why this matters The Ray docs Read the Docs build has been segfaulting intermittently, in about 31% of builds since 2026-09-23. The crash is in native extension init while autosummary imports RLlib → Tune → AIR → `ray.data`. A `PYTHONFAULTHANDLER=1` traceback (#66452) puts the crash inside `from pyarrow._dataset_parquet import ...`, which is reached from `parquet_datasource.py` → `file_reader.py` → `import pyarrow.dataset`. The loaded-extensions list in that traceback ends with exactly the modules this import adds. This change takes the crashing import off the `import ray.data` path. It doesn't fix the underlying native crash. I couldn't reproduce it with a bare `import pyarrow.dataset` loop in `linux/amd64` Docker: 0 of 300 runs failed, with numpy 2.2.6 and pyarrow 23.0.1 from the doc lock. So it seems to depend on process state or on the build host. The docs build and `requirements_compiled.txt` both pin pyarrow 23.0.1, and neither pin changed in the failure window. ## Related issues Related to #66357 and #66452. ## Additional information ### Not a duplicate Searched open PRs for `_compute_row_hashes`, the DSv2 reorg series, and lazy-import and segfault keywords. #66450 (DSv2 Reorg [4/6]) and #66201 are the nearest open PRs, and neither touches this import or `test_import.py`. ### Tests run These were run locally on macOS arm64, Python 3.11, pyarrow 23.0.1, numpy 2.2.6. They used the Ray nightly wheel with `ray/data` and `ray/tests` linked from this branch. * `pytest python/ray/data/tests/test_import.py`: 2 passed. With the `parquet_datasource.py` change reverted, the new test fails and lists `pyarrow._dataset`, `_dataset_orc`, `_dataset_parquet`, and `_dataset_parquet_encryption`. * `pytest python/ray/data/tests/datasource/test_parquet.py -k row_hash`: 18 passed. * `pytest python/ray/data/tests/datasource/test_parquet.py` (full module): 242 passed, 13 skipped, 13 failed, 34 errors. Rerunning the 47 failing tests with master's `parquet_datasource.py` gave an identical failing set, so none come from this change. They come from the local environment: * The S3 fixtures error in `fsspec`'s HTTP backend, because their test dependencies aren't installed. * Several local-path tests assert `string` columns and get `large_string`, which is pandas/pyarrow version skew against CI's pins. CI is the authoritative run for this module. * `pre-commit run --files python/ray/data/_internal/datasource/parquet_datasource.py`: all hooks passed, including ruff, black, pydoclint, and the import-order check. ### AI assistance AI assistance (Claude Code) was used to investigate the import graph, write the change and test, and draft this description. This PR stays in draft until the submitter has reviewed every changed line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…6463) ## Description Since ray-project#66357, `import ray.data` loads `pyarrow.dataset` and its native extensions. The legacy `parquet_datasource.py` now imports `_compute_row_hashes` from the V2 readers package at module level, and the V2 reader modules import `pyarrow.dataset` at load time. Before ray-project#66357, the dependency ran the other way and `ray.data` never reached `pyarrow.dataset` on import. This PR moves the `_compute_row_hashes` import into `_read_batches_from`, its only caller. That matches the file's existing function-level `pyarrow.dataset` imports. The import points at `readers/synthesized_columns.py`, where the helper has lived since ray-project#66390, rather than at the `file_reader` re-export. Importing from `synthesized_columns` at module level isn't enough on its own, because `read_units.py` also imports `pyarrow.dataset` at the top level. It also adds `test_import_does_not_load_pyarrow_dataset` to `python/ray/data/tests/test_import.py`. The test asserts that a fresh driver's `import ray.data` loads no `pyarrow._dataset*` modules. ### Why this matters The Ray docs Read the Docs build has been segfaulting intermittently, in about 31% of builds since 2026-09-23. The crash is in native extension init while autosummary imports RLlib → Tune → AIR → `ray.data`. A `PYTHONFAULTHANDLER=1` traceback (ray-project#66452) puts the crash inside `from pyarrow._dataset_parquet import ...`, which is reached from `parquet_datasource.py` → `file_reader.py` → `import pyarrow.dataset`. The loaded-extensions list in that traceback ends with exactly the modules this import adds. This change takes the crashing import off the `import ray.data` path. It doesn't fix the underlying native crash. I couldn't reproduce it with a bare `import pyarrow.dataset` loop in `linux/amd64` Docker: 0 of 300 runs failed, with numpy 2.2.6 and pyarrow 23.0.1 from the doc lock. So it seems to depend on process state or on the build host. The docs build and `requirements_compiled.txt` both pin pyarrow 23.0.1, and neither pin changed in the failure window. ## Related issues Related to ray-project#66357 and ray-project#66452. ## Additional information ### Not a duplicate Searched open PRs for `_compute_row_hashes`, the DSv2 reorg series, and lazy-import and segfault keywords. ray-project#66450 (DSv2 Reorg [4/6]) and ray-project#66201 are the nearest open PRs, and neither touches this import or `test_import.py`. ### Tests run These were run locally on macOS arm64, Python 3.11, pyarrow 23.0.1, numpy 2.2.6. They used the Ray nightly wheel with `ray/data` and `ray/tests` linked from this branch. * `pytest python/ray/data/tests/test_import.py`: 2 passed. With the `parquet_datasource.py` change reverted, the new test fails and lists `pyarrow._dataset`, `_dataset_orc`, `_dataset_parquet`, and `_dataset_parquet_encryption`. * `pytest python/ray/data/tests/datasource/test_parquet.py -k row_hash`: 18 passed. * `pytest python/ray/data/tests/datasource/test_parquet.py` (full module): 242 passed, 13 skipped, 13 failed, 34 errors. Rerunning the 47 failing tests with master's `parquet_datasource.py` gave an identical failing set, so none come from this change. They come from the local environment: * The S3 fixtures error in `fsspec`'s HTTP backend, because their test dependencies aren't installed. * Several local-path tests assert `string` columns and get `large_string`, which is pandas/pyarrow version skew against CI's pins. CI is the authoritative run for this module. * `pre-commit run --files python/ray/data/_internal/datasource/parquet_datasource.py`: all hooks passed, including ruff, black, pydoclint, and the import-order check. ### AI assistance AI assistance (Claude Code) was used to investigate the import graph, write the change and test, and draft this description. This PR stays in draft until the submitter has reviewed every changed line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[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. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
Description
hashlib.md5()raises on FIPS-enabled OpenSSL, since MD5 isn't in the FIPS provider:hashlib.blake2b()is served by the_blake2builtin rather than by OpenSSL, so itdoes not go through that path — but distributions that wrap the builtin constructors
when
_hashlib.get_fips_mode()is set reject it the same way, withValueError: blake2b is blocked when usedforsecurity=True. Both need the same fix.#40755 fixed this for runtime_env by switching to SHA-1, which the FIPS provider does
allow. These five calls are what's left, and in each one the digest value matters so
the algorithm can't change:
_generate_arm_guidreplicates ARM'sguid(), which is defined as MD5_rewrite_iceberg_fileneeds a stablewrite_uuidso retries overwrite the sameobject, and
uuid.UUIDwants 128 bits anyway_compute_row_hashesuses the digest as a reproducible 64-bit seedDataset.train_test_splitbuckets rows by a digest of the split keyget_worker_idderives a Dynamo worker id from a replica's unique idNone of them is a security use, and
usedforsecurity=Falseleaves the digestsidentical, so nothing changes off FIPS. Needs Python 3.9+;
SUPPORTED_PYTHONSis 3.10+.Related issues
Same cause as #40534 / #40755. Not #53435 — SHA-1 is allowed in the FIPS provider and
doesn't raise, so the remaining
runtime_envSHA-1 uses are unaffected either way.Checks
black(22.10.0) andruff(0.8.4), the pinned pre-commit versions, are clean onall five files
md5/blake2bcall remains anywhere underpython/ray(AST walk, excluding tests)