Skip to content

Commit 3049d0c

Browse files
authored
Fixes hparam columns from breaking multi-experiment scalar cards (#6754)
## Motivation for features / changes Currently [scalar_card_data_table.ts:273](https://github.com/tensorflow/tensorboard/blob/5033fef6cf89f5f539b6ec56e193689d98daa6cf/tensorboard/webapp/metrics/views/card_renderer/scalar_card_data_table.ts#L273) will throw an error if the scalar card table does not contain the corresponding hparam column data - this will happen often for multi-experiment dashboards. ## Technical description of changes - Extends the optional chaining to the get() call (this was the original intent) - Adds test to prevent regression
1 parent 6f4b7a1 commit 3049d0c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

tensorboard/webapp/metrics/views/card_renderer/scalar_card_data_table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class ScalarCardDataTable {
270270
(metadata as SmoothedSeriesMetadata).originalSeriesId ||
271271
metadata.id;
272272
selectedStepData[header.name] =
273-
this.runToHparamMap?.[runId].get(header.name) ?? '';
273+
this.runToHparamMap?.[runId]?.get(header.name) ?? '';
274274
continue;
275275
default:
276276
continue;

tensorboard/webapp/metrics/views/card_renderer/scalar_card_test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4091,6 +4091,35 @@ describe('scalar card', () => {
40914091
]);
40924092
}));
40934093

4094+
// This can easily happen in multi-experiment Time Series dashboards.
4095+
it('shows empty cells for runs that do not have given hparams', fakeAsync(() => {
4096+
store.overrideSelector(
4097+
commonSelectors.getFilteredRenderableRunsIds,
4098+
new Set(['run1', 'run2'])
4099+
);
4100+
store.overrideSelector(runsSelectors.getRunToHparamMap, {});
4101+
const fixture = createComponent('card1');
4102+
const scalarCardDataTable = fixture.debugElement.query(
4103+
By.directive(ScalarCardDataTable)
4104+
);
4105+
4106+
const data =
4107+
scalarCardDataTable.componentInstance.getTimeSelectionTableData();
4108+
4109+
expect(data).toEqual([
4110+
jasmine.objectContaining({
4111+
id: 'run1',
4112+
conv_layers: '',
4113+
conv_kernel_size: '',
4114+
}),
4115+
jasmine.objectContaining({
4116+
id: 'run2',
4117+
conv_layers: '',
4118+
conv_kernel_size: '',
4119+
}),
4120+
]);
4121+
}));
4122+
40944123
it('shows hparam values with smoothing enabled', fakeAsync(() => {
40954124
store.overrideSelector(
40964125
commonSelectors.getFilteredRenderableRunsIds,

0 commit comments

Comments
 (0)