Skip to content

Commit f7680b4

Browse files
authored
HParams: Stop fetching hparams data using run effects (#6561)
## Motivation for features / changes Now that we are fetching the hparams data using the newly created hparams_effects (#6540) we no longer need to fetch them using the old method. Note that the experiment list SHOULD still use the old method.
1 parent 3a70adc commit f7680b4

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

tensorboard/webapp/app_routing/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ export enum RouteKind {
3838
NOT_SET,
3939
}
4040

41+
export type DashboardRoute =
42+
| RouteKind.EXPERIMENT
43+
| RouteKind.COMPARE_EXPERIMENT
44+
| RouteKind.CARD;
45+
46+
export function isDashboardRoute(
47+
routeKind: RouteKind
48+
): routeKind is DashboardRoute {
49+
return (
50+
routeKind === RouteKind.EXPERIMENT ||
51+
routeKind === RouteKind.COMPARE_EXPERIMENT ||
52+
routeKind === RouteKind.CARD
53+
);
54+
}
55+
4156
export const DEFAULT_EXPERIMENT_ID = 'defaultExperimentId';
4257

4358
/**

tensorboard/webapp/runs/effects/runs_effects.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,27 @@ limitations under the License.
1515
import {Injectable} from '@angular/core';
1616
import {Actions, createEffect, ofType} from '@ngrx/effects';
1717
import {Store} from '@ngrx/store';
18-
import {forkJoin, merge, Observable, of, throwError} from 'rxjs';
18+
import {forkJoin, merge, Observable, of, throwError, zip} from 'rxjs';
1919
import {
2020
catchError,
2121
distinctUntilChanged,
2222
filter,
2323
map,
2424
mergeMap,
25+
switchMap,
2526
take,
2627
tap,
2728
withLatestFrom,
2829
} from 'rxjs/operators';
2930
import {areSameRouteKindAndExperiments} from '../../app_routing';
3031
import {navigated} from '../../app_routing/actions';
31-
import {RouteKind} from '../../app_routing/types';
32+
import {RouteKind, isDashboardRoute} from '../../app_routing/types';
3233
import {State} from '../../app_state';
3334
import * as coreActions from '../../core/actions';
3435
import {
3536
getActiveRoute,
37+
getRouteKind,
38+
getEnableHparamsInTimeSeries,
3639
getExperimentIdsFromRoute,
3740
getRuns,
3841
getRunsLoadState,
@@ -264,15 +267,33 @@ export class RunsEffects {
264267
);
265268
}
266269

270+
private maybeFetchHparamsMetadata(
271+
experimentId: string
272+
): Observable<HparamsAndMetadata> {
273+
return this.store.select(getEnableHparamsInTimeSeries).pipe(
274+
withLatestFrom(this.store.select(getRouteKind)),
275+
switchMap(([hparamsInTimeSeries, routeKind]) => {
276+
if (hparamsInTimeSeries && isDashboardRoute(routeKind)) {
277+
return of({
278+
hparamSpecs: [],
279+
metricSpecs: [],
280+
runToHparamsAndMetrics: {},
281+
});
282+
}
283+
return this.runsDataSource.fetchHparamsMetadata(experimentId);
284+
})
285+
);
286+
}
287+
267288
private fetchRunsForExperiment(experimentId: string): Observable<{
268289
fromRemote: true;
269290
experimentId: string;
270291
runs: Run[];
271292
metadata: HparamsAndMetadata;
272293
}> {
273-
return forkJoin([
294+
return zip([
274295
this.runsDataSource.fetchRuns(experimentId),
275-
this.runsDataSource.fetchHparamsMetadata(experimentId),
296+
this.maybeFetchHparamsMetadata(experimentId),
276297
]).pipe(
277298
map(([runs, metadata]) => {
278299
return {fromRemote: true, experimentId, runs, metadata};

tensorboard/webapp/runs/effects/runs_effects_test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import {State} from '../../app_state';
2828
import * as coreActions from '../../core/actions';
2929
import {
3030
getActiveRoute,
31+
getEnableHparamsInTimeSeries,
3132
getExperimentIdsFromRoute,
33+
getRouteKind,
3234
getRuns,
3335
getRunsLoadState,
3436
} from '../../selectors';
@@ -62,6 +64,7 @@ describe('runs_effects', () => {
6264
let dispatchSpy: jasmine.Spy;
6365
let actualActions: Action[];
6466
let selectSpy: jasmine.Spy;
67+
let fetchHparamsSpy: jasmine.Spy;
6568

6669
function flushFetchRuns(requestIndex: number, runs: Run[]) {
6770
expect(fetchRunsSubjects.length).toBeGreaterThan(requestIndex);
@@ -113,7 +116,8 @@ describe('runs_effects', () => {
113116
});
114117

115118
fetchHparamsMetadataSubjects = [];
116-
spyOn(runsDataSource, 'fetchHparamsMetadata').and.callFake(() => {
119+
fetchHparamsSpy = spyOn(runsDataSource, 'fetchHparamsMetadata');
120+
fetchHparamsSpy.and.callFake(() => {
117121
const subject = new ReplaySubject<HparamsAndMetadata>(1);
118122
fetchHparamsMetadataSubjects.push(subject);
119123
return subject;
@@ -231,6 +235,15 @@ describe('runs_effects', () => {
231235
});
232236
});
233237

238+
it('does not fetch hparam data when enableHparamsInTimeSeries is true when on a dashboard route', () => {
239+
store.overrideSelector(getEnableHparamsInTimeSeries, true);
240+
store.overrideSelector(getRouteKind, RouteKind.EXPERIMENT);
241+
store.refreshState();
242+
243+
action.next(actions.runTableShown({experimentIds: ['a']}));
244+
expect(fetchHparamsSpy).not.toHaveBeenCalled();
245+
});
246+
234247
it('fires FAILED action when failed to fetch runs', () => {
235248
action.next(actions.runTableShown({experimentIds: ['a']}));
236249
const expectedExperimentId = 'a';

0 commit comments

Comments
 (0)