-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fixing ModelLoaderUtils.split() to pass tests #126009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Prior to these changes, the split method would fail tests. Additionally, the method had code which could be refactored. A new variable (numRanges) was introduced to replace the direct usage of numStreams. The method was refactored to make the code easier to understand. Javadocs were updated. Tests for this method now pass.
Pinging @elastic/ml-core (Team:ML) |
@elasticmachine test this please |
Thank you for the contribution, and welcome. The code looks good, and I verified the tests pass now. Can you add a changelog to Example: https://github.com/elastic/elasticsearch/blob/main/docs/changelog/125650.yaml |
@elasticmachine test this please |
@elasticmachine test this please |
Prior to these changes, the split method would fail tests. Additionally, the method had code which could be refactored. A new variable (numRanges) was introduced to replace the direct usage of numStreams. The method was refactored to make the code easier to understand. Javadocs were updated. Tests for this method now pass.
Prior to these changes, the split method would fail tests. Additionally, the method had code which could be refactored. A new variable (numRanges) was introduced to replace the direct usage of numStreams. The method was refactored to make the code easier to understand. Javadocs were updated. Tests for this method now pass. Co-authored-by: Jason-Whitmore <[email protected]>
The primary changes are to the split() method's functionality. A new variable,
numberOfRanges
is created to ensure the return list has the correct length. The variablesbaseChunksPerRange
andremainder
are now calculated differently to fit the new code structure.The new code structure completes all but the final range in a single for loop and removes the need for an if statement that adds the second to last range in some cases.
Changes are also made to the method Javadoc to accurately state what the method does.
A good way to test this change is to run:
./gradlew ":x-pack:plugin:ml-package-loader:test" --tests "org.elasticsearch.xpack.ml.packageloader.action.ModelLoaderUtilsTests.testSplitIntoRanges" -Dtests.iters=100000
This test will fail on main, but passes on this PR.
Closes #121799