Skip to content

Commit 6391e40

Browse files
authored
Embedded Single Card: parse card route exp alias (#6515)
The card route should be set up to parse experiment ids and return alias for run display names on the internal single card.
1 parent a399065 commit 6391e40

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

tensorboard/webapp/app_routing/store/app_routing_selectors.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,17 @@ export const getExperimentIdToExperimentAliasMap = createSelector(
116116
getRouteKind,
117117
getRouteParams,
118118
(routeKind, routeParams): {[id: string]: ExperimentAlias} => {
119-
if (routeKind !== RouteKind.COMPARE_EXPERIMENT) {
119+
const compareParams = routeParams as CompareRouteParams;
120+
if (
121+
routeKind !== RouteKind.COMPARE_EXPERIMENT &&
122+
!(
123+
routeKind === RouteKind.CARD &&
124+
compareParams.experimentIds.indexOf(',') !== -1
125+
)
126+
) {
120127
return {};
121128
}
122129

123-
const compareParams = routeParams as CompareRouteParams;
124130
const map = getCompareExperimentIdAliasWithNumberSpec(compareParams);
125131
return Object.fromEntries(map.entries());
126132
}

tensorboard/webapp/app_routing/store/app_routing_selectors_test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,40 @@ describe('app_routing_selectors', () => {
163163
});
164164
});
165165

166+
it('returns a map of id to alias for CARD route', () => {
167+
const state = buildStateFromAppRoutingState(
168+
buildAppRoutingState({
169+
activeRoute: buildRoute({
170+
routeKind: RouteKind.CARD,
171+
params: {
172+
experimentIds: 'exp1:123,exp2:234,exp2:345',
173+
},
174+
}),
175+
})
176+
);
177+
178+
expect(selectors.getExperimentIdToExperimentAliasMap(state)).toEqual({
179+
123: {aliasText: 'exp1', aliasNumber: 1},
180+
234: {aliasText: 'exp2', aliasNumber: 2},
181+
345: {aliasText: 'exp2', aliasNumber: 3},
182+
});
183+
});
184+
185+
it('returns an empty map for CARD route with single experiment', () => {
186+
const state = buildStateFromAppRoutingState(
187+
buildAppRoutingState({
188+
activeRoute: buildRoute({
189+
routeKind: RouteKind.CARD,
190+
params: {
191+
experimentIds: '1234',
192+
},
193+
}),
194+
})
195+
);
196+
197+
expect(selectors.getExperimentIdToExperimentAliasMap(state)).toEqual({});
198+
});
199+
166200
it('returns an empty map for non-compare route', () => {
167201
const state = buildStateFromAppRoutingState(
168202
buildAppRoutingState({

0 commit comments

Comments
 (0)