Skip to content

Commit 6f5be4b

Browse files
authored
Remove MetricSpec and HparamAndMetricSpec types. (#6776)
We no longer surface Hparam-related Metric Values from the server in Angular TensorBoard UI. We therefore remove the MetricSpec and HparamAndMetricSpec types. The latter is replaced with just HparamSpec[] where necessary.
1 parent 1ddbc7b commit 6f5be4b

18 files changed

+164
-332
lines changed

tensorboard/webapp/hparams/_redux/hparams_actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import {
2121
AddColumnEvent,
2222
ReorderColumnEvent,
2323
} from '../../widgets/data_table/types';
24-
import {HparamAndMetricSpec, SessionGroup, ColumnHeader} from '../types';
24+
import {HparamSpec, SessionGroup, ColumnHeader} from '../types';
2525
import {HparamFilter, MetricFilter} from './types';
2626

2727
export const hparamsFetchSessionGroupsSucceeded = createAction(
2828
'[Hparams] Hparams Fetch Session Groups Succeeded',
2929
props<{
30-
hparamsAndMetricsSpecs: HparamAndMetricSpec;
30+
hparamSpecs: HparamSpec[];
3131
sessionGroups: SessionGroup[];
3232
}>()
3333
);

tensorboard/webapp/hparams/_redux/hparams_data_source.ts

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ import {Observable} from 'rxjs';
1717
import {map} from 'rxjs/operators';
1818

1919
import {
20+
BackendListSessionGroupResponse,
2021
Domain,
2122
DomainType,
2223
BackendListSessionGroupRequest,
2324
BackendHparamsExperimentRequest,
2425
BackendHparamsExperimentResponse,
2526
BackendHparamSpec,
2627
DiscreteDomainHparamSpec,
27-
SessionGroup,
28-
HparamAndMetricSpec,
28+
HparamSpec,
2929
IntervalDomainHparamSpec,
30-
BackendListSessionGroupResponse,
3130
RunStatus,
31+
SessionGroup,
3232
} from '../types';
3333
import {TBHttpClient} from '../../webapp_data_source/tb_http_client';
3434

@@ -87,9 +87,7 @@ export class HparamsDataSource {
8787
return experimentIds.map((eid, index) => `${index}:${eid}`).join(',');
8888
}
8989

90-
fetchExperimentInfo(
91-
experimentIds: string[]
92-
): Observable<HparamAndMetricSpec> {
90+
fetchExperimentInfo(experimentIds: string[]): Observable<HparamSpec[]> {
9391
const formattedExperimentIds = this.formatExperimentIds(experimentIds);
9492

9593
const experimentRequest: BackendHparamsExperimentRequest = {
@@ -110,42 +108,31 @@ export class HparamsDataSource {
110108
)
111109
.pipe(
112110
map((response) => {
113-
return {
114-
hparams: response.hparamInfos.map((hparam) => {
115-
const feHparam = {
116-
...hparam,
117-
domain: getHparamDomain(hparam),
118-
};
119-
120-
delete (feHparam as any).domainInterval;
121-
delete (feHparam as any).domainDiscrete;
122-
123-
return feHparam;
124-
}),
125-
metrics: response.metricInfos.map((metric) => ({
126-
...metric,
127-
tag: metric.name.tag,
128-
})),
129-
};
111+
return response.hparamInfos.map((hparam) => {
112+
const feHparam = {
113+
...hparam,
114+
domain: getHparamDomain(hparam),
115+
};
116+
117+
delete (feHparam as any).domainInterval;
118+
delete (feHparam as any).domainDiscrete;
119+
120+
return feHparam;
121+
});
130122
})
131123
);
132124
}
133125

134126
fetchSessionGroups(
135127
experimentIds: string[],
136-
hparamsAndMetricsSpecs: HparamAndMetricSpec
128+
hparamSpecs: HparamSpec[]
137129
): Observable<SessionGroup[]> {
138130
const formattedExperimentIds = this.formatExperimentIds(experimentIds);
139131

140132
const colParams: BackendListSessionGroupRequest['colParams'] = [];
141133

142-
for (const hparam of hparamsAndMetricsSpecs.hparams) {
143-
colParams.push({hparam: hparam.name});
144-
}
145-
for (const mectric of hparamsAndMetricsSpecs.metrics) {
146-
colParams.push({
147-
metric: mectric.name,
148-
});
134+
for (const hparamSpec of hparamSpecs) {
135+
colParams.push({hparam: hparamSpec.name});
149136
}
150137

151138
const listSessionRequestParams: BackendListSessionGroupRequest = {

tensorboard/webapp/hparams/_redux/hparams_data_source_test.ts

Lines changed: 49 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -68,53 +68,29 @@ describe('HparamsDataSource Test', () => {
6868
httpMock
6969
.expectOne('/experiment/eid/data/plugin/hparams/experiment')
7070
.flush(createHparamsExperimentResponse());
71-
expect(returnValue).toHaveBeenCalledWith({
72-
hparams: [
73-
{
74-
description: 'describes hparams one',
75-
displayName: 'hparams one',
76-
name: 'hparams1',
77-
type: BackendHparamsValueType.DATA_TYPE_STRING,
78-
domain: {
79-
type: DomainType.INTERVAL,
80-
minValue: -100,
81-
maxValue: 100,
82-
},
83-
},
84-
{
85-
description: 'describes hparams two',
86-
displayName: 'hparams two',
87-
name: 'hparams2',
88-
type: BackendHparamsValueType.DATA_TYPE_BOOL,
89-
domain: {
90-
type: DomainType.DISCRETE,
91-
values: ['foo', 'bar', 'baz'],
92-
},
71+
expect(returnValue).toHaveBeenCalledWith([
72+
{
73+
description: 'describes hparams one',
74+
displayName: 'hparams one',
75+
name: 'hparams1',
76+
type: BackendHparamsValueType.DATA_TYPE_STRING,
77+
domain: {
78+
type: DomainType.INTERVAL,
79+
minValue: -100,
80+
maxValue: 100,
9381
},
94-
],
95-
metrics: [
96-
{
97-
name: {
98-
tag: 'metrics1',
99-
group: '',
100-
},
101-
tag: 'metrics1',
102-
displayName: 'Metrics One',
103-
description: 'describe metrics one',
104-
datasetType: DatasetType.DATASET_UNKNOWN,
105-
},
106-
{
107-
name: {
108-
tag: 'metrics2',
109-
group: 'group',
110-
},
111-
tag: 'metrics2',
112-
displayName: 'Metrics Two',
113-
description: 'describe metrics two',
114-
datasetType: DatasetType.DATASET_TRAINING,
82+
},
83+
{
84+
description: 'describes hparams two',
85+
displayName: 'hparams two',
86+
name: 'hparams2',
87+
type: BackendHparamsValueType.DATA_TYPE_BOOL,
88+
domain: {
89+
type: DomainType.DISCRETE,
90+
values: ['foo', 'bar', 'baz'],
11591
},
116-
],
117-
});
92+
},
93+
]);
11894
});
11995

12096
it('treats missing domains as discrete domains', () => {
@@ -123,41 +99,35 @@ describe('HparamsDataSource Test', () => {
12399
httpMock
124100
.expectOne('/experiment/eid/data/plugin/hparams/experiment')
125101
.flush(createHparamsExperimentNoDomainResponse());
126-
expect(returnValue).toHaveBeenCalledWith(
127-
jasmine.objectContaining({
128-
hparams: [
129-
{
130-
description: 'describes hparams one',
131-
displayName: 'hparams one',
132-
name: 'hparams1',
133-
type: BackendHparamsValueType.DATA_TYPE_STRING,
134-
domain: {
135-
type: DomainType.DISCRETE,
136-
values: [],
137-
},
138-
},
139-
{
140-
description: 'describes hparams two',
141-
displayName: 'hparams two',
142-
name: 'hparams2',
143-
type: BackendHparamsValueType.DATA_TYPE_BOOL,
144-
domain: {
145-
type: DomainType.DISCRETE,
146-
values: ['foo', 'bar', 'baz'],
147-
},
148-
},
149-
],
150-
})
151-
);
102+
expect(returnValue).toHaveBeenCalledWith([
103+
{
104+
description: 'describes hparams one',
105+
displayName: 'hparams one',
106+
name: 'hparams1',
107+
type: BackendHparamsValueType.DATA_TYPE_STRING,
108+
domain: {
109+
type: DomainType.DISCRETE,
110+
values: [],
111+
},
112+
},
113+
{
114+
description: 'describes hparams two',
115+
displayName: 'hparams two',
116+
name: 'hparams2',
117+
type: BackendHparamsValueType.DATA_TYPE_BOOL,
118+
domain: {
119+
type: DomainType.DISCRETE,
120+
values: ['foo', 'bar', 'baz'],
121+
},
122+
},
123+
]);
152124
});
153125
});
154126

155127
describe('fetchSessionGroups', () => {
156128
it('uses /experiment when a single experiment id is provided', () => {
157129
const returnValue = jasmine.createSpy();
158-
dataSource
159-
.fetchSessionGroups(['eid'], {hparams: [], metrics: []})
160-
.subscribe(returnValue);
130+
dataSource.fetchSessionGroups(['eid'], []).subscribe(returnValue);
161131
httpMock
162132
.expectOne('/experiment/eid/data/plugin/hparams/session_groups')
163133
.flush(createHparamsListSessionGroupResponse());
@@ -167,7 +137,7 @@ describe('HparamsDataSource Test', () => {
167137
it('uses /compare when a multiple experiment ids are provided', () => {
168138
const returnValue = jasmine.createSpy();
169139
dataSource
170-
.fetchSessionGroups(['eid1', 'eid2'], {hparams: [], metrics: []})
140+
.fetchSessionGroups(['eid1', 'eid2'], [])
171141
.subscribe(returnValue);
172142
httpMock
173143
.expectOne('/compare/0:eid1,1:eid2/data/plugin/hparams/session_groups')
@@ -180,9 +150,7 @@ describe('HparamsDataSource Test', () => {
180150
const callback = (resp: SessionGroup[]) => {
181151
sessionGroups = resp;
182152
};
183-
dataSource
184-
.fetchSessionGroups(['eid'], {hparams: [], metrics: []})
185-
.subscribe(callback);
153+
dataSource.fetchSessionGroups(['eid'], []).subscribe(callback);
186154
httpMock
187155
.expectOne('/experiment/eid/data/plugin/hparams/session_groups')
188156
.flush(createHparamsListSessionGroupResponse());
@@ -195,9 +163,7 @@ describe('HparamsDataSource Test', () => {
195163
const callback = (resp: SessionGroup[]) => {
196164
sessionGroups = resp;
197165
};
198-
dataSource
199-
.fetchSessionGroups(['eid1', 'eid2'], {hparams: [], metrics: []})
200-
.subscribe(callback);
166+
dataSource.fetchSessionGroups(['eid1', 'eid2'], []).subscribe(callback);
201167

202168
const response = createHparamsListSessionGroupResponse();
203169
// This is the format expected in comparison view.
@@ -333,26 +299,7 @@ export function createHparamsExperimentResponse(): BackendHparamsExperimentRespo
333299
domainDiscrete: ['foo', 'bar', 'baz'],
334300
},
335301
],
336-
metricInfos: [
337-
{
338-
name: {
339-
group: '',
340-
tag: 'metrics1',
341-
},
342-
displayName: 'Metrics One',
343-
description: 'describe metrics one',
344-
datasetType: DatasetType.DATASET_UNKNOWN,
345-
},
346-
{
347-
name: {
348-
group: 'group',
349-
tag: 'metrics2',
350-
},
351-
displayName: 'Metrics Two',
352-
description: 'describe metrics two',
353-
datasetType: DatasetType.DATASET_TRAINING,
354-
},
355-
],
302+
metricInfos: [],
356303
name: 'experiment name',
357304
timeCreatedSecs: 1337,
358305
user: 'user name',
@@ -377,26 +324,7 @@ export function createHparamsExperimentNoDomainResponse(): BackendHparamsExperim
377324
domainDiscrete: ['foo', 'bar', 'baz'],
378325
},
379326
],
380-
metricInfos: [
381-
{
382-
name: {
383-
group: '',
384-
tag: 'metrics1',
385-
},
386-
displayName: 'Metrics One',
387-
description: 'describe metrics one',
388-
datasetType: DatasetType.DATASET_UNKNOWN,
389-
},
390-
{
391-
name: {
392-
group: 'group',
393-
tag: 'metrics2',
394-
},
395-
displayName: 'Metrics Two',
396-
description: 'describe metrics two',
397-
datasetType: DatasetType.DATASET_TRAINING,
398-
},
399-
],
327+
metricInfos: [],
400328
name: 'experiment name',
401329
timeCreatedSecs: 1337,
402330
user: 'user name',

tensorboard/webapp/hparams/_redux/hparams_effects.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {HttpErrorResponse} from '../../webapp_data_source/tb_http_client';
3737

3838
import * as hparamsActions from './hparams_actions';
3939
import {HparamsDataSource} from './hparams_data_source';
40-
import {HparamAndMetricSpec, SessionGroup} from '../types';
40+
import {HparamSpec, SessionGroup} from '../types';
4141
import {RouteKind} from '../../app_routing/types';
4242

4343
/**
@@ -85,13 +85,13 @@ export class HparamsEffects {
8585
});
8686

8787
private loadHparamsForExperiments(experimentIds: string[]): Observable<{
88-
hparamsAndMetricsSpecs: HparamAndMetricSpec;
88+
hparamSpecs: HparamSpec[];
8989
sessionGroups: SessionGroup[];
9090
}> {
9191
return this.dataSource.fetchExperimentInfo(experimentIds).pipe(
92-
switchMap((hparamsAndMetricsSpecs) => {
92+
switchMap((hparamSpecs) => {
9393
return this.dataSource
94-
.fetchSessionGroups(experimentIds, hparamsAndMetricsSpecs)
94+
.fetchSessionGroups(experimentIds, hparamSpecs)
9595
.pipe(
9696
catchError((error) => {
9797
// HParam plugin return 400 when there are no hparams
@@ -101,7 +101,7 @@ export class HparamsEffects {
101101
}
102102
return throwError(() => error);
103103
}),
104-
map((sessionGroups) => ({hparamsAndMetricsSpecs, sessionGroups}))
104+
map((sessionGroups) => ({hparamSpecs, sessionGroups}))
105105
);
106106
})
107107
);

0 commit comments

Comments
 (0)