Sort trials table metric columns numerically instead of as strings - #2717
Open
pujitha24 wants to merge 1 commit into
Open
Sort trials table metric columns numerically instead of as strings#2717pujitha24 wants to merge 1 commit into
pujitha24 wants to merge 1 commit into
Conversation
Motivation: The Trials table in the Katib UI sorts metric and hyperparameter columns lexicographically instead of numerically. Values with more than 6 significant digits are formatted into scientific notation (e.g. "1.3923e-2") by numberToExponential() before being handed to the table, and the shared kubeflow table component sorts by that formatted display string when no sortingPreprocessorFn is set. As a result "1.3923e-2" > "0.49713" as strings even though 0.013923 < 0.49713 numerically, so clicking a metric column header does not sort trials by value. Approach: TableColumn (from the kubeflow common library) supports an optional sortingPreprocessorFn, used by MatTableDataSource.sortingDataAccessor instead of the raw display value when present. This adds a sortingPreprocessorFn to the generic (metric/hyperparameter) columns in TrialsTableComponent.setConfig() that converts the formatted string back to a Number for sorting, falling back to the original string for non-numeric values (e.g. categorical hyperparameters) and for empty values (missing metrics), so those continue to sort/group as before. This only changes sort order; displayed values are unaffected. Validation: Reproduced the CI job defined in .github/workflows/test-node.yaml locally: cloned kubeflow/kubeflow at the pinned commit in pkg/ui/v1beta1/frontend/COMMIT, built and npm linked the kubeflow common library, then in pkg/ui/v1beta1/frontend: - `npm run test:prod` (ng test --browsers=ChromeHeadless --watch=false): TOTAL 46 SUCCESS, exit code 0. Includes two new unit tests that call sortingPreprocessorFn directly and assert numeric strings (including scientific notation) sort numerically, and that an empty string (missing metric) stays '' rather than becoming 0. Both are genuine failing-before/passing-after tests: before this change sortingPreprocessorFn is undefined on these columns, so calling it throws. - `npm run lint-check` (ng lint): all files pass linting. - `npm run format:check` (prettier, matching the repo's make prettier-check): all matched files use Prettier code style. Not run: the Cypress UI test job (frontend-ui-tests), which requires serving the app live in Chrome and Firefox. This change has no DOM/interaction surface (it only changes a sort comparator function), so it is disclosed here rather than blocking on it. Report: kubeflow#2715 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5 (via Claude Code)
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
google-oss-prow
Bot
requested review from
andreyvelich,
anencore94 and
kimwnasptd
September 3, 2026 09:41
|
🎉 Welcome to the Kubeflow Katib repo! 🎉 Thanks for opening your first PR! We're excited to have you onboard 🚀 Next steps:
Feel free to ask questions in the comments. Thanks again for contributing! 🙏 |
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 this PR does / why we need it:
The Trials table in the Katib UI sorts metric and hyperparameter columns lexicographically instead of numerically. Values with more than 6 significant digits are formatted into scientific notation (e.g.
1.3923e-2) bynumberToExponential()before being handed to the table, and the sharedkubeflowtable component sorts by that formatted display string when nosortingPreprocessorFnis set. As a result"1.3923e-2" > "0.49713"as strings even though0.013923 < 0.49713numerically, so clicking a metric column header does not sort trials by value.Approach:
TableColumn(from thekubeflowcommon library) supports an optionalsortingPreprocessorFnused byMatTableDataSource.sortingDataAccessorinstead of the raw display value when present. This PR adds asortingPreprocessorFnto the generic (metric/hyperparameter) columns inTrialsTableComponent.setConfig()that converts the formatted string back to aNumberfor sorting, falling back to the original string for non-numeric values (e.g. categorical hyperparameters) and for empty values (missing metrics), so those continue to sort/group as before.This is a display/sorting-only change: it does not affect the values shown in the table, only the order rows appear in when a numeric column is sorted.
Validation:
Reproduced the CI job defined in
.github/workflows/test-node.yamllocally: clonedkubeflow/kubeflowat the pinned commit inpkg/ui/v1beta1/frontend/COMMIT, built andnpm linked thekubeflowcommon library, then inpkg/ui/v1beta1/frontend:npm run test:prod(ng test --browsers=ChromeHeadless --watch=false) →TOTAL: 46 SUCCESS, exit code 0. This includes two new unit tests that callsortingPreprocessorFndirectly and assert numeric strings (including scientific notation) sort numerically, and that an empty string (missing metric) is left as''rather than becoming0. Both are genuine failing-before/passing-after tests: before this changesortingPreprocessorFnisundefinedon these columns, so calling it throws.npm run lint-check(ng lint) → all files pass linting.npm run format:check(prettier, matching the repo'smake prettier-check) → all matched files use Prettier code style.Not run: the Cypress UI test job (
frontend-ui-tests), which requires serving the app live in Chrome and Firefox. This change has no DOM/interaction surface (it only changes a sort comparator function), so it is disclosed here rather than block on it.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Checklist:
Fixes #2715