Skip to content

Commit 1adec6c

Browse files
authored
HParams: Start showing hparams in runs table based on the enableHparamsInTimeSeries flag (#6317)
Nothing will be displayed until ~#6318~ is merged ## Motivation for features / changes We are working on surfacing hparam data in the time series dashboard. As part of this effort we would like to show the value of hparams in the runs table. The runs table already has partial support for this but it is currently disabled. I am enabling the columns based on the feature flag I added in #6308. Note that you will not see anything in OSS until we fix the call to session_groups ## Technical description of changes I added a new selector to get the feature flag, then modified the metrics_container to read the value of the flag ## Screenshots of UI changes Disabled ![image](https://user-images.githubusercontent.com/78179109/231893521-e75c2176-af9e-4585-991c-126e277d2acb.png) Enabled ![image](https://user-images.githubusercontent.com/78179109/231893683-71ea69cd-7cbf-46ed-a0ae-4829bd5b21bd.png) ## Detailed steps to verify changes work correctly (as executed by you) ## Alternate designs / implementations considered
1 parent bca0692 commit 1adec6c

File tree

5 files changed

+83
-4
lines changed

5 files changed

+83
-4
lines changed

tensorboard/webapp/feature_flag/store/feature_flag_selectors.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,10 @@ export const getIsScalarColumnCustomizationEnabled = createSelector(
174174
return flags.enableScalarColumnCustomization;
175175
}
176176
);
177+
178+
export const getEnableHparamsInTimeSeries = createSelector(
179+
getFeatureFlags,
180+
(flags: FeatureFlags): boolean => {
181+
return flags.enableHparamsInTimeSeries;
182+
}
183+
);

tensorboard/webapp/feature_flag/store/feature_flag_selectors_test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,28 @@ describe('feature_flag_selectors', () => {
444444
);
445445
});
446446
});
447+
448+
describe('#getEnableHparamsInTimeSeries', () => {
449+
it('returns true when enableHparamsInTimeSeries is true', () => {
450+
let state = buildState(
451+
buildFeatureFlagState({
452+
defaultFlags: buildFeatureFlag({
453+
enableHparamsInTimeSeries: true,
454+
}),
455+
})
456+
);
457+
expect(selectors.getEnableHparamsInTimeSeries(state)).toBeTrue();
458+
});
459+
460+
it('returns false when enableHparamsInTimeSeries is false', () => {
461+
let state = buildState(
462+
buildFeatureFlagState({
463+
defaultFlags: buildFeatureFlag({
464+
enableHparamsInTimeSeries: false,
465+
}),
466+
})
467+
);
468+
expect(selectors.getEnableHparamsInTimeSeries(state)).toBeFalse();
469+
});
470+
});
447471
});

tensorboard/webapp/metrics/views/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ tf_ng_module(
3434
"//tensorboard/webapp/angular:expect_angular_material_icon",
3535
"//tensorboard/webapp/core",
3636
"//tensorboard/webapp/customization",
37+
"//tensorboard/webapp/feature_flag/store",
38+
"//tensorboard/webapp/feature_flag/store:types",
3739
"//tensorboard/webapp/metrics/actions",
3840
"//tensorboard/webapp/metrics/views/main_view",
3941
"//tensorboard/webapp/metrics/views/right_pane",
4042
"//tensorboard/webapp/runs/views/runs_selector",
4143
"@npm//@angular/common",
4244
"@npm//@angular/core",
45+
"@npm//@ngrx/store",
4346
],
4447
)
4548

@@ -73,11 +76,15 @@ tf_ts_library(
7376
":types",
7477
":utils",
7578
":views",
79+
"//tensorboard/webapp:app_state",
7680
"//tensorboard/webapp/angular:expect_angular_core_testing",
7781
"//tensorboard/webapp/angular:expect_angular_platform_browser_animations",
7882
"//tensorboard/webapp/angular:expect_ngrx_store_testing",
83+
"//tensorboard/webapp/feature_flag/store",
7984
"//tensorboard/webapp/metrics/actions",
8085
"//tensorboard/webapp/metrics/data_source",
86+
"//tensorboard/webapp/runs/views/runs_selector",
87+
"//tensorboard/webapp/testing:utils",
8188
"@npm//@angular/core",
8289
"@npm//@angular/platform-browser",
8390
"@npm//@types/jasmine",

tensorboard/webapp/metrics/views/metrics_container.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,26 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515
import {ChangeDetectionStrategy, Component} from '@angular/core';
16+
import {Store} from '@ngrx/store';
17+
import {getEnableHparamsInTimeSeries} from '../../feature_flag/store/feature_flag_selectors';
18+
import {State} from '../../feature_flag/store/feature_flag_types';
1619

1720
@Component({
1821
selector: 'metrics-dashboard',
1922
template: `
2023
<tb-dashboard-layout>
21-
<runs-selector sidebar></runs-selector>
24+
<runs-selector
25+
[showHparamsAndMetrics]="showHparamsAndMetrics$ | async"
26+
sidebar
27+
></runs-selector>
2228
<metrics-main-view main></metrics-main-view>
2329
</tb-dashboard-layout>
2430
`,
2531
styleUrls: ['metrics_container.css'],
2632
changeDetection: ChangeDetectionStrategy.OnPush,
2733
})
28-
export class MetricsDashboardContainer {}
34+
export class MetricsDashboardContainer {
35+
showHparamsAndMetrics$ = this.store.select(getEnableHparamsInTimeSeries);
36+
37+
constructor(readonly store: Store<State>) {}
38+
}

tensorboard/webapp/metrics/views/metrics_container_test.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,53 @@ limitations under the License.
1515
import {NO_ERRORS_SCHEMA} from '@angular/core';
1616
import {TestBed} from '@angular/core/testing';
1717
import {By} from '@angular/platform-browser';
18+
import {Store} from '@ngrx/store';
19+
import {MockStore} from '@ngrx/store/testing';
20+
import {State} from '../../app_state';
21+
import {getEnableHparamsInTimeSeries} from '../../feature_flag/store/feature_flag_selectors';
22+
import {RunsSelectorContainer} from '../../runs/views/runs_selector/runs_selector_container';
23+
import {provideMockTbStore} from '../../testing/utils';
1824
import {MetricsDashboardContainer} from './metrics_container';
1925

2026
describe('metrics view', () => {
27+
let store: MockStore<State>;
28+
2129
beforeEach(async () => {
2230
await TestBed.configureTestingModule({
23-
declarations: [MetricsDashboardContainer],
24-
providers: [],
31+
declarations: [MetricsDashboardContainer, RunsSelectorContainer],
32+
providers: [provideMockTbStore()],
2533
// Ignore errors from components that are out-of-scope for this test:
2634
// 'runs-selector'.
2735
schemas: [NO_ERRORS_SCHEMA],
2836
}).compileComponents();
37+
38+
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
2939
});
3040

3141
it('renders', () => {
42+
store.overrideSelector(getEnableHparamsInTimeSeries, false);
3243
const fixture = TestBed.createComponent(MetricsDashboardContainer);
3344
fixture.detectChanges();
3445
expect(fixture.debugElement.query(By.css('runs-selector'))).not.toBeNull();
3546
});
47+
48+
it('enables hparamsAndMetrics when enableHparamsInTimeSeries is true', () => {
49+
store.overrideSelector(getEnableHparamsInTimeSeries, true);
50+
const fixture = TestBed.createComponent(MetricsDashboardContainer);
51+
fixture.detectChanges();
52+
expect(
53+
fixture.debugElement.query(By.css('runs-selector')).componentInstance
54+
.showHparamsAndMetrics
55+
).toBeTrue();
56+
});
57+
58+
it('disables hparamsAndMetrics when enableHparamsInTimeSeries is false', () => {
59+
store.overrideSelector(getEnableHparamsInTimeSeries, false);
60+
const fixture = TestBed.createComponent(MetricsDashboardContainer);
61+
fixture.detectChanges();
62+
expect(
63+
fixture.debugElement.query(By.css('runs-selector')).componentInstance
64+
.showHparamsAndMetrics
65+
).toBeFalse();
66+
});
3667
});

0 commit comments

Comments
 (0)