-
Notifications
You must be signed in to change notification settings - Fork 119
feature: add "group by" dropdown to sidebar #551
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9b42152
run grouping in UI
Saba9 b8378cc
refactor + tests
Saba9 ddeadc8
surface username in group dropdown
Saba9 32fd88d
add changeset
gradio-pr-bot 1e5104d
add changeset
gradio-pr-bot b7963a7
key with run id instead of name
Saba9 d092dab
group by None if selected grouping var disappears
Saba9 9f745aa
preserve run groups when transient failure occurs
Saba9 5fa2967
misc
Saba9 4ba5910
fallback for when run_id does not exist
Saba9 5daf816
Merge remote-tracking branch 'origin/main' into feature/run-grouping
Saba9 608e9c9
add changeset
gradio-pr-bot a67e194
always show dropdown
Saba9 ad832b0
fix changeset
Saba9 a2e6eaf
edge cases
Saba9 2f25564
ignore non-scalar keys
Saba9 1eded0f
misc
Saba9 3c5cafe
Merge branch 'main' into feature/run-grouping
Saba9 0496da6
Merge branch 'main' into feature/run-grouping
abidlabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "trackio": minor | ||
| --- | ||
|
|
||
| feat:feature: add "group by" dropdown to sidebar | ||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| export const PROMOTED_RESERVED_KEYS = Object.freeze({ | ||
| _Group: "Group", | ||
| _Username: "Username", | ||
| }); | ||
|
|
||
| function shouldHideKey(key) { | ||
| return key.startsWith("_") && !(key in PROMOTED_RESERVED_KEYS); | ||
| } | ||
|
|
||
| function displayLabelForKey(key) { | ||
| return PROMOTED_RESERVED_KEYS[key] ?? key; | ||
| } | ||
|
|
||
| export function resolveGroupByKey(displayLabel, runConfigs) { | ||
| if (!displayLabel) return null; | ||
| for (const [key, label] of Object.entries(PROMOTED_RESERVED_KEYS)) { | ||
| if (label === displayLabel && promotedKeyHasVariance(runConfigs, key)) return key; | ||
| } | ||
| return displayLabel; | ||
| } | ||
|
|
||
| function promotedKeyHasVariance(runConfigs, key) { | ||
| const seen = new Set(); | ||
| for (const cfg of Object.values(runConfigs ?? {})) { | ||
| if (!cfg || typeof cfg !== "object") continue; | ||
| const raw = cfg[key]; | ||
| const label = raw === null || raw === undefined ? "(unset)" : String(raw); | ||
| seen.add(label); | ||
| if (seen.size >= 2) return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| export function computeGroupByOptions(runConfigs) { | ||
| const promoted = Object.keys(PROMOTED_RESERVED_KEYS) | ||
| .filter((k) => promotedKeyHasVariance(runConfigs, k)) | ||
| .map(displayLabelForKey); | ||
| const surfacedPromotedLabels = new Set(promoted); | ||
|
|
||
| const regularKeys = new Set(); | ||
| for (const cfg of Object.values(runConfigs ?? {})) { | ||
| if (!cfg || typeof cfg !== "object") continue; | ||
| for (const key of Object.keys(cfg)) { | ||
| if (cfg[key] === null || cfg[key] === undefined) continue; | ||
| if (shouldHideKey(key)) continue; | ||
| if (key in PROMOTED_RESERVED_KEYS) continue; | ||
| if (surfacedPromotedLabels.has(key)) continue; | ||
| regularKeys.add(key); | ||
| } | ||
| } | ||
| const regular = [...regularKeys].sort(); | ||
| return ["None", ...promoted, ...regular]; | ||
|
Saba9 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| export function computeGroupedRuns(filteredRuns, runConfigs, groupBy) { | ||
| const realKey = resolveGroupByKey(groupBy, runConfigs); | ||
| if (!realKey) return null; | ||
| const groups = new Map(); | ||
| for (const run of filteredRuns) { | ||
| const cfg = (runConfigs ?? {})[run.id] ?? (runConfigs ?? {})[run.name] ?? {}; | ||
| const raw = cfg[realKey]; | ||
| const label = raw === null || raw === undefined ? "(unset)" : String(raw); | ||
| if (!groups.has(label)) groups.set(label, []); | ||
|
Saba9 marked this conversation as resolved.
Outdated
|
||
| groups.get(label).push(run); | ||
| } | ||
| return groups; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.