Validate dataset mixture fractions before loading - #7237
Open
lindicaphxag-tech wants to merge 2 commits into
Open
lindicaphxag-tech wants to merge 2 commits into
lindicaphxag-tech wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Dataset mixtures with invalid
fractionvalues currently fail after loading datasets, and an all-zero mixture raises an unhelpfulZeroDivisionError. This validates fractions before any dataset loading, rejects negative or non-finite values, and reports a clear error for a non-positive total.This is an internal input-validation fix; no additional dependencies are required.
Before submitting
AI writing disclosure
Testing
python -m pytest tests/test_cli_utils.py::TestGetDataset::test_dataset_fraction_zero_sum_raises_before_loading tests/test_cli_utils.py::TestGetDataset::test_dataset_fraction_invalid_value_raises_before_loading tests/test_cli_utils.py::TestGetDataset::test_dataset_fraction -q(5 passed)python -m pytest tests/test_cli_utils.py::TestGetDataset -q(15 passed; 2 pre-existing Windows NamedTemporaryFile permission failures)Who can review?
Anyone in the community is free to review the PR once the tests have passed.
Note
Low Risk
Input validation only in dataset mixture loading; behavior for valid configs is unchanged aside from failing earlier on invalid fractions.
Overview
get_datasetnow validates mixturefractionvalues before anyload_datasetcalls, so bad configs fail fast with clear errors instead of after expensive I/O (or with an unhelpfulZeroDivisionErrorwhen all fractions are zero).When any dataset specifies a fraction, the check enforces: all-or-none fraction usage (unchanged), finite non-negative values, a strictly positive sum, and the existing no fractions with streaming rule. Mixture sizing logic after load is unchanged.
Tests assert
load_datasetis never called for all-zero sums and for negative, NaN, or infinite fractions.Reviewed by Cursor Bugbot for commit 4384e32. Bugbot is set up for automated code reviews on this repo. Configure here.