Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hparams: refactor arguments provided to getDashboardRuns #6555

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tensorboard/webapp/experiments/store/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tf_ts_library(
],
deps = [
":types",
"//tensorboard/webapp/app_routing/store",
"//tensorboard/webapp/experiments:types",
"//tensorboard/webapp/types",
"@npm//@ngrx/store",
Expand Down
20 changes: 20 additions & 0 deletions tensorboard/webapp/experiments/store/experiments_selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
ExperimentsState,
EXPERIMENTS_FEATURE_KEY,
} from './experiments_types';
import {getExperimentIdsFromRoute} from '../../app_routing/store/app_routing_selectors';

const getExperimentsState = createFeatureSelector<ExperimentsState>(
EXPERIMENTS_FEATURE_KEY
Expand Down Expand Up @@ -61,3 +62,22 @@ export const getExperimentNames = (experimentIds: string[]) =>
return map;
}, {} as Record<string, string>)
);

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the original getExperimentNames be deleted?

If not:

  • Can you explain in the comment where/when it is used?
  • Can it share some logic with the new getDashboardExperimentNames?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it can, good point

* Returns the names of all experiments present on the current dashboard.
*/
export const getDashboardExperimentNames = createSelector(
getDataState,
getExperimentIdsFromRoute,
(
state: ExperimentsDataState,
experimentIds: string[] | null
): Record<string, string> =>
(experimentIds ?? [])
.map((experimentId) => state.experimentMap[experimentId])
.filter(Boolean)
.reduce((map, experiment) => {
map[experiment.id] = experiment.name;
return map;
}, {} as Record<string, string>)
);
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ import {
HeaderToggleInfo,
XAxisType,
} from '../../types';
import {getFilteredRenderableRunsIdsFromRoute} from '../main_view/common_selectors';
import {getFilteredRenderableRunsIds} from '../main_view/common_selectors';
import {CardRenderer} from '../metrics_view_types';
import {getTagDisplayName} from '../utils';
import {DataDownloadDialogContainer} from './data_download_dialog_container';
Expand Down Expand Up @@ -499,7 +499,7 @@ export class ScalarCardContainer implements CardRenderer, OnInit, OnDestroy {
combineLatestWith(
this.store.select(getCurrentRouteRunSelection),
this.store.select(getEnableHparamsInTimeSeries),
this.store.select(getFilteredRenderableRunsIdsFromRoute),
this.store.select(getFilteredRenderableRunsIds),
this.store.select(getRunColorMap),
this.store.select(getMetricsScalarSmoothing)
),
Expand Down
40 changes: 20 additions & 20 deletions tensorboard/webapp/metrics/views/card_renderer/scalar_card_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ describe('scalar card', () => {
new Map([['run1', true]])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1'])
);
store.overrideSelector(selectors.getMetricsXAxisType, XAxisType.STEP);
Expand Down Expand Up @@ -764,7 +764,7 @@ describe('scalar card', () => {
new Map([['run1', true]])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1'])
);
});
Expand Down Expand Up @@ -2574,7 +2574,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);
store.overrideSelector(getCardStateMap, {
Expand Down Expand Up @@ -2996,7 +2996,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);

Expand Down Expand Up @@ -3066,7 +3066,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);

Expand Down Expand Up @@ -3145,7 +3145,7 @@ describe('scalar card', () => {
new Map([['run1', true]])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1'])
);

Expand Down Expand Up @@ -3211,7 +3211,7 @@ describe('scalar card', () => {
new Map([['run1', true]])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1'])
);

Expand Down Expand Up @@ -3278,7 +3278,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);

Expand Down Expand Up @@ -3330,7 +3330,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);

Expand Down Expand Up @@ -3382,7 +3382,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);

Expand Down Expand Up @@ -3432,7 +3432,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);
store.overrideSelector(getMetricsLinkedTimeSelection, {
Expand Down Expand Up @@ -3481,7 +3481,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);
store.overrideSelector(selectors.getExperimentIdToExperimentAliasMap, {
Expand Down Expand Up @@ -3539,7 +3539,7 @@ describe('scalar card', () => {
new Map([['run1', true]])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1'])
);
store.overrideSelector(getMetricsLinkedTimeSelection, {
Expand Down Expand Up @@ -3586,7 +3586,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2', 'run3'])
);

Expand Down Expand Up @@ -3635,7 +3635,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2', 'run3'])
);

Expand Down Expand Up @@ -3692,7 +3692,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2', 'run3', 'run4', 'run5', 'run6', 'run7'])
);

Expand Down Expand Up @@ -3754,7 +3754,7 @@ describe('scalar card', () => {
);

store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2', 'run3', 'run4', 'run5', 'run6', 'run7'])
);

Expand Down Expand Up @@ -3840,7 +3840,7 @@ describe('scalar card', () => {
);

store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1'])
);

Expand Down Expand Up @@ -3952,7 +3952,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2', 'run3', 'run4'])
);

Expand Down Expand Up @@ -3981,7 +3981,7 @@ describe('scalar card', () => {
])
);
store.overrideSelector(
commonSelectors.getFilteredRenderableRunsIdsFromRoute,
commonSelectors.getFilteredRenderableRunsIds,
new Set(['run1', 'run2'])
);
const fixture = createComponent('card1');
Expand Down
Loading