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

Updates edit column menu to support hparam columns #6738

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
89fc04a
Adds shared hparam related common selectors
hoonji Jan 24, 2024
bed9604
Fixes test description
hoonji Jan 24, 2024
9eef734
Fixes formatting
hoonji Jan 24, 2024
f72b2a2
Changes reorder column events to use source and destination
hoonji Jan 25, 2024
f3130d0
Fixes lint
hoonji Jan 25, 2024
a9c53c3
Runs buildifier
hoonji Jan 25, 2024
f17fe22
Turns groupColumns into a projector function helper
hoonji Jan 26, 2024
555a84e
Merge branch 'hparam_common_selectors' into hparam_update_reorder
hoonji Jan 26, 2024
6e45e6e
Makes runs table use hparam store for hparam columns
hoonji Jan 26, 2024
ec93a93
Changes ColumnGroup to enum
hoonji Jan 27, 2024
cff6ce3
Merge branch 'hparam_common_selectors' into hparam_update_reorder
hoonji Jan 27, 2024
c17894d
Applies comments
hoonji Jan 27, 2024
694251c
Merge branch 'hparam_update_reorder' into hparam_runs_hparams
hoonji Jan 27, 2024
ff8c096
Applies comments
hoonji Jan 27, 2024
999bffc
Adds hparams to scalar tables
hoonji Jan 28, 2024
aff157d
Adds hparams to column editor
hoonji Jan 29, 2024
d3f2cb9
Fixes card view stacking context
hoonji Jan 29, 2024
62f4099
Applies fixes
hoonji Jan 29, 2024
e96b32a
Fixes lint error
hoonji Jan 29, 2024
7f39b54
Fixes lint error
hoonji Jan 29, 2024
ef301e5
Merge branch 'hparam_update_reorder' into hparam_runs_hparams
hoonji Jan 29, 2024
06b550e
Merge branch 'hparam_runs_hparams' into hparam_scalar_table_hparams
hoonji Jan 29, 2024
2445ba3
Merge branch 'hparam_scalar_table_hparams' into hparam_column_editor_…
hoonji Jan 29, 2024
8b2df63
Fixes
hoonji Jan 29, 2024
dd390f0
Revert card view layout paint
hoonji Jan 29, 2024
0e210b2
More fixes
hoonji Jan 29, 2024
8f95404
Move contain layout paint to original position
hoonji Jan 29, 2024
2a5156d
Merge branch 'hparam_scalar_table_hparams' into hparam_column_editor_…
hoonji Jan 29, 2024
5fe3551
Fix strange merge
hoonji Jan 29, 2024
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/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ tf_ng_web_test_suite(
"//tensorboard/webapp/widgets/content_wrapping_input:content_wrapping_input_tests",
"//tensorboard/webapp/widgets/custom_modal:custom_modal_test",
"//tensorboard/webapp/widgets/data_table:data_table_test",
"//tensorboard/webapp/widgets/data_table:utils_test",
"//tensorboard/webapp/widgets/dropdown:dropdown_tests",
"//tensorboard/webapp/widgets/experiment_alias:experiment_alias_test",
"//tensorboard/webapp/widgets/filter_input:filter_input_test",
Expand Down
4 changes: 4 additions & 0 deletions tensorboard/webapp/hparams/_redux/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ tf_ts_library(
":types",
":utils",
"//tensorboard/webapp/hparams:_types",
"//tensorboard/webapp/persistent_settings",
"//tensorboard/webapp/runs/actions",
"//tensorboard/webapp/widgets/data_table:types",
"//tensorboard/webapp/widgets/data_table:utils",
"@npm//@ngrx/store",
],
)
Expand Down Expand Up @@ -167,13 +169,15 @@ tf_ts_library(
"//tensorboard/webapp/app_routing/actions",
"//tensorboard/webapp/core/actions",
"//tensorboard/webapp/hparams:types",
"//tensorboard/webapp/persistent_settings",
"//tensorboard/webapp/runs/actions",
"//tensorboard/webapp/runs/data_source:testing",
"//tensorboard/webapp/runs/store:testing",
"//tensorboard/webapp/testing:utils",
"//tensorboard/webapp/util:types",
"//tensorboard/webapp/webapp_data_source:http_client_testing",
"//tensorboard/webapp/widgets/data_table:types",
"//tensorboard/webapp/widgets/data_table:utils",
"@npm//@ngrx/effects",
"@npm//@ngrx/store",
"@npm//@types/jasmine",
Expand Down
40 changes: 18 additions & 22 deletions tensorboard/webapp/hparams/_redux/hparams_reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
import {Action, ActionReducer, createReducer, on} from '@ngrx/store';
import {ColumnHeader, Side} from '../../widgets/data_table/types';
import {DataTableUtils} from '../../widgets/data_table/utils';
import {persistentSettingsLoaded} from '../../persistent_settings';
import {Side} from '../../widgets/data_table/types';
import * as actions from './hparams_actions';
import {HparamsState} from './types';

Expand All @@ -32,6 +34,16 @@ const initialState: HparamsState = {

const reducer: ActionReducer<HparamsState, Action> = createReducer(
initialState,
on(persistentSettingsLoaded, (state, {partialSettings}) => {
const {dashboardDisplayedHparamColumns: storedColumns} = partialSettings;
if (storedColumns) {
return {
...state,
dashboardDisplayedHparamColumns: storedColumns,
};
}
return state;
}),
on(actions.hparamsFetchSessionGroupsSucceeded, (state, action) => {
const nextDashboardSpecs = action.hparamsAndMetricsSpecs;
const nextDashboardSessionGroups = action.sessionGroups;
Expand Down Expand Up @@ -141,28 +153,12 @@ const reducer: ActionReducer<HparamsState, Action> = createReducer(
actions.dashboardHparamColumnOrderChanged,
(state, {source, destination, side}) => {
const {dashboardDisplayedHparamColumns: columns} = state;
const sourceIndex = columns.findIndex(
(column: ColumnHeader) => column.name === source.name
const newColumns = DataTableUtils.moveColumn(
columns,
source,
destination,
side
);
let destinationIndex = columns.findIndex(
(column: ColumnHeader) => column.name === destination.name
);
if (sourceIndex === -1 || sourceIndex === destinationIndex) {
return state;
}
if (destinationIndex === -1) {
// Use side as a backup to determine source position if destination isn't found.
if (side !== undefined) {
destinationIndex = side === Side.LEFT ? 0 : columns.length - 1;
} else {
return state;
}
}

const newColumns = [...columns];
newColumns.splice(sourceIndex, 1);
newColumns.splice(destinationIndex, 0, source);

return {
...state,
dashboardDisplayedHparamColumns: newColumns,
Expand Down
180 changes: 86 additions & 94 deletions tensorboard/webapp/hparams/_redux/hparams_reducers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,82 @@ import * as actions from './hparams_actions';
import {reducers} from './hparams_reducers';
import {buildHparamSpec, buildHparamsState, buildMetricSpec} from './testing';
import {ColumnHeaderType, Side} from '../../widgets/data_table/types';
import {DataTableUtils} from '../../widgets/data_table/utils';
import {persistentSettingsLoaded} from '../../persistent_settings';

describe('hparams/_redux/hparams_reducers_test', () => {
describe('#persistentSettingsLoaded', () => {
it('loads dashboardDisplayedHparamColumns from the persistent settings storage', () => {
const state = buildHparamsState({
dashboardDisplayedHparamColumns: [],
});
const state2 = reducers(
state,
persistentSettingsLoaded({
partialSettings: {
dashboardDisplayedHparamColumns: [
{
type: ColumnHeaderType.HPARAM,
name: 'conv_layers',
displayName: 'Conv Layers',
enabled: true,
},
{
type: ColumnHeaderType.HPARAM,
name: 'conv_kernel_size',
displayName: 'Conv Kernel Size',
enabled: true,
},
],
},
})
);

expect(state2.dashboardDisplayedHparamColumns).toEqual([
{
type: ColumnHeaderType.HPARAM,
name: 'conv_layers',
displayName: 'Conv Layers',
enabled: true,
},
{
type: ColumnHeaderType.HPARAM,
name: 'conv_kernel_size',
displayName: 'Conv Kernel Size',
enabled: true,
},
]);
});

it('does nothing if persistent settings does not contain dashboardDisplayedHparamColumns', () => {
const state = buildHparamsState({
dashboardDisplayedHparamColumns: [
{
type: ColumnHeaderType.HPARAM,
name: 'conv_layers',
displayName: 'Conv Layers',
enabled: true,
},
],
});
const state2 = reducers(
state,
persistentSettingsLoaded({
partialSettings: {},
})
);

expect(state2.dashboardDisplayedHparamColumns).toEqual([
{
type: ColumnHeaderType.HPARAM,
name: 'conv_layers',
displayName: 'Conv Layers',
enabled: true,
},
]);
});
});

describe('hparamsFetchSessionGroupsSucceeded', () => {
it('saves action.hparamsAndMetricsSpecs as dashboardSpecs', () => {
const state = buildHparamsState({
Expand Down Expand Up @@ -594,104 +668,15 @@ describe('hparams/_redux/hparams_reducers_test', () => {
},
];

it('does nothing if source is not found', () => {
it('moves source to destination using moveColumn', () => {
const state = buildHparamsState({
dashboardDisplayedHparamColumns: fakeColumns,
});
const state2 = reducers(
state,
actions.dashboardHparamColumnOrderChanged({
source: {
type: ColumnHeaderType.HPARAM,
name: 'nonexistent_param',
displayName: 'Nonexistent param',
enabled: false,
},
destination: {
type: ColumnHeaderType.HPARAM,
name: 'conv_kernel_size',
displayName: 'Conv Kernel Size',
enabled: true,
},
side: Side.LEFT,
})
);

expect(state2.dashboardDisplayedHparamColumns).toEqual(fakeColumns);
});

it('does nothing if source equals dest', () => {
const state = buildHparamsState({
dashboardDisplayedHparamColumns: fakeColumns,
});
const state2 = reducers(
state,
actions.dashboardHparamColumnOrderChanged({
source: {
type: ColumnHeaderType.HPARAM,
name: 'conv_kernel_size',
displayName: 'Conv Kernel Size',
enabled: false,
},
destination: {
type: ColumnHeaderType.HPARAM,
name: 'conv_kernel_size',
displayName: 'Conv Kernel Size',
enabled: true,
},
side: Side.LEFT,
})
);

expect(state2.dashboardDisplayedHparamColumns).toEqual(fakeColumns);
});

[
{
testDesc: 'to front if side is left',
side: Side.LEFT,
expectedResult: [
fakeColumns[1],
fakeColumns[0],
...fakeColumns.slice(2),
],
},
{
testDesc: 'to back if side is right',
side: Side.RIGHT,
expectedResult: [
fakeColumns[0],
...fakeColumns.slice(2),
fakeColumns[1],
],
},
].forEach(({testDesc, side, expectedResult}) => {
it(`if destination not found, moves source ${testDesc}`, () => {
const state = buildHparamsState({
dashboardDisplayedHparamColumns: fakeColumns,
});
const state2 = reducers(
state,
actions.dashboardHparamColumnOrderChanged({
source: fakeColumns[1],
destination: {
type: ColumnHeaderType.HPARAM,
name: 'nonexistent param',
displayName: 'Nonexistent param',
enabled: true,
},
side,
})
);

expect(state2.dashboardDisplayedHparamColumns).toEqual(expectedResult);
});
});
const moveColumnSpy = spyOn(
DataTableUtils,
'moveColumn'
).and.callThrough();

it('swaps source and destination positions if destination is found', () => {
const state = buildHparamsState({
dashboardDisplayedHparamColumns: fakeColumns,
});
const state2 = reducers(
state,
actions.dashboardHparamColumnOrderChanged({
Expand All @@ -701,6 +686,13 @@ describe('hparams/_redux/hparams_reducers_test', () => {
})
);

// Edge cases are tested by moveColumn tests.
expect(moveColumnSpy).toHaveBeenCalledWith(
fakeColumns,
fakeColumns[1],
fakeColumns[0],
Side.LEFT
);
expect(state2.dashboardDisplayedHparamColumns).toEqual([
fakeColumns[1],
fakeColumns[0],
Expand Down
8 changes: 7 additions & 1 deletion tensorboard/webapp/hparams/_redux/hparams_selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ export const getDashboardDefaultHparamFilters = createSelector(
);

export const getDashboardDisplayedHparamColumns = createSelector(
getDashboardHparamsAndMetricsSpecs,
getHparamsState,
(state) => state.dashboardDisplayedHparamColumns
({hparams}, state) => {
const hparamSet = new Set(hparams.map((hparam) => hparam.name));
return state.dashboardDisplayedHparamColumns.filter((column) =>
hparamSet.has(column.name)
);
}
);

export const getDashboardHparamFilterMap = createSelector(
Expand Down
Loading
Loading