Fix double sharding in ShuffleBuffer#9020
Conversation
Signed-off-by: kyinhub <kevinpyin@gmail.com>
📝 WalkthroughWalkthrough
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
monai/data/iterable_dataset.py (1)
125-132: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument transform failures.
Add a Google-style
Raisessection forRuntimeErrorfromapply_transform.As per path instructions, “Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@monai/data/iterable_dataset.py` around lines 125 - 132, Add a Google-style Raises section to the docstring of the method yielding shuffled items, documenting that apply_transform can raise RuntimeError. Keep the existing description and Yields documentation unchanged.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@monai/data/iterable_dataset.py`:
- Around line 125-132: Add a Google-style Raises section to the docstring of the
method yielding shuffled items, documenting that apply_transform can raise
RuntimeError. Keep the existing description and Yields documentation unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f032a9a6-a682-4939-bf36-d6b81c16e970
📒 Files selected for processing (2)
monai/data/iterable_dataset.pytests/data/test_shuffle_buffer.py
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
monai/data/iterable_dataset.py (1)
105-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd Google-style method docstrings.
monai/data/iterable_dataset.py#L105-L120: document constructor arguments and initialization behavior.tests/data/test_shuffle_buffer.py#L30-L44: document yielded values for both helper iterators.As per path instructions, “Docstrings should be present for all definition[s] … in the appropriate section of the Google-style of docstrings.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@monai/data/iterable_dataset.py` around lines 105 - 120, Document the IterableDataset constructor with a Google-style docstring covering each argument and its initialization behavior. In tests/data/test_shuffle_buffer.py lines 30-44, add Google-style docstrings to both helper iterator definitions describing the values they yield; make the requested documentation changes at both sites.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/data/test_shuffle_buffer.py`:
- Around line 93-104: Update the test description and method name in
test_unsharded_source_keeps_outer_worker_partition to describe the explicitly
configured source_shards_by_worker=False behavior rather than claiming it
verifies the default. Keep the test setup and assertions unchanged.
---
Nitpick comments:
In `@monai/data/iterable_dataset.py`:
- Around line 105-120: Document the IterableDataset constructor with a
Google-style docstring covering each argument and its initialization behavior.
In tests/data/test_shuffle_buffer.py lines 30-44, add Google-style docstrings to
both helper iterator definitions describing the values they yield; make the
requested documentation changes at both sites.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4122d582-cc91-43b8-ae0f-fb344ed8ff38
📒 Files selected for processing (2)
monai/data/iterable_dataset.pytests/data/test_shuffle_buffer.py
Signed-off-by: kyinhub <kevinpyin@gmail.com>
bfbaacd to
e525693
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@monai/data/iterable_dataset.py`:
- Around line 105-120: Add a Google-style docstring directly inside
ShuffleBuffer.__init__ documenting all constructor arguments, including
source_shards_by_worker, and the constructor’s return value. Keep the existing
initialization behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2bcf7957-7fe6-4929-a20e-95b51dd7f4af
📒 Files selected for processing (2)
monai/data/iterable_dataset.pytests/data/test_shuffle_buffer.py
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/data/test_shuffle_buffer.py
Signed-off-by: kyinhub <kevinpyin@gmail.com>
Fixes #7986.
Description
ShuffleBuffernow distinguishes sources that already partition their stream usingtorch.utils.data.get_worker_info. MONAIIterableDatasetsources are recognized automatically, while an explicitsource_shards_by_workeroverride supports generic PyTorch or unusual custom iterable sources.The default auto-detects MONAI iterable sources, so the
GridPatchDatasetpipeline reported in #7986 works without a caller change.Trueprevents a second partition for any worker-aware source;Falsepreserves the outer worker partition for an explicitly unsharded iterable source.This avoids using class identity as a proxy for sharding behavior: MONAI subclasses can be unsharded, while generic PyTorch iterable sources can shard themselves.
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.Validation
DataLoadercontract: the default MONAI-source path returns all 40 inputs exactly once;git diff --checkpass.