Skip to content

Adds redux code for displaying shared hparam columns in the Time Series page #6727

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

Merged
merged 5 commits into from
Jan 24, 2024

Conversation

hoonji
Copy link
Member

@hoonji hoonji commented Jan 22, 2024

Motivation for features / changes

Required redux edits for displaying hparams in time series.

Technical description of changes

Adds a new property to HparamsState, dashboardDisplayedHparamColumns to represent the columns shown across the time series page (similar in concept to the existing dashboardFilters)

Adds four actions for hparam column manipulation:

  • dashboardHparamColumnAdded
  • dashboardHparamColumnRemoved
  • dashboardHparamColumnToggled
  • dashboardHparamColumnOrderChanged

and reducer logic to handle these events.

Note that the add actions cannot simply pass the header index in this case as the table components will not have knowledge of the relative index of hparam columns. The actions instead specify the column to insert next to and the side, and the indices are computed from within the reducer (this can be seen as simply moving the index computation from the component to the reducer, which better conforms to https://redux.js.org/style-guide/#put-as-much-logic-as-possible-in-reducers )

Also exports required types from widgets/data_table - these will be also used by the runs and metrics tables the following PRs

Detailed steps to verify changes work correctly (as executed by you)

  • Unit tests pass

Alternate designs / implementations considered (or N/A)

An alternative is to duplicate the hparams state across the runs and scalar card tables as RunsDataState.runsTableHeaders and MetricsState.singleSelectionHeaders/MetricsState.rangeSelectionHeaders, but this would either incur massive complications in syncing the various column operations (add/remove/hide/sort) or alternatively, would force the user to duplicate operations multiple times to get the hparams columns in sync. The chosen design also aligns with keeping state minimal.

@hoonji hoonji changed the title Hparam redux final Adds redux code for displaying shared hparam columns in the Time Series page Jan 22, 2024
@hoonji hoonji requested a review from rileyajones January 22, 2024 05:02
Comment on lines 154 to 160
if (destinationIndex === -1) {
destinationIndex = side === Side.LEFT ? 0 : columns.length - 1;
}

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

Choose a reason for hiding this comment

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

If the destination IS found, the side is not taken into account.

Heads up, if side IS accounted for you will likely run into an issue with way you derive the indexes, then mutate the array.

Copy link
Member Author

@hoonji hoonji Jan 23, 2024

Choose a reason for hiding this comment

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

If the destination IS found, the side is not taken into account.

Yeah this is WAI: in typical cases, we just swap source with dest - no Side required. Side is essentially used as a backup for when dest is not found. This allows us to move columns to the end of a valid "column group" as in this gif: reorder

I'll add additional conditional logic to make sure this only triggers when dest is not found AND side exists, and a comment to clarify this behavior.

PLMK if this seems unnecessarily convoluted - I'm also open to simply removing the side param and simply doing nothing if dest isn't found. (IMO reordering elements to the end of the column group should be rather intuitive though)

@hoonji hoonji requested a review from rileyajones January 23, 2024 11:44
## Motivation for features / changes
Scalar card table columns are [currently persisted to
localstorage](https://github.com/tensorflow/tensorboard/blob/28be621b99e1bb2595b39d915055c32ca986a805/tensorboard/webapp/metrics/metrics_module.ts#L174-L179);
it should be reasonable to save selected hparam columns to localstorage
as well.

## Technical description of changes
Adds a new `dashboardDisplayedHparamColumns` PersistableSetting to save
selected hparam columns (similar to the existing
`singleSelectionHeaders` and `rangeSelectionHeaders` settings)

## Detailed steps to verify changes work correctly (as executed by you)
Unit tests pass
@hoonji hoonji merged commit 94129a8 into master Jan 24, 2024
@hoonji hoonji deleted the hparam_redux_final branch January 24, 2024 02:39
hoonji added a commit that referenced this pull request Jan 31, 2024
## Motivation for features / changes
To prepare for showing shared hparam columns across runs and scalar
tables, we need to unify the column re-ordering logic to use the same
source/destination parameters (introduced in #6727).

## Technical description of changes
- Changes the DataTable component (shared by runs and scalar tables) to
use the new ReorderColumnEvent type when column order is changed. The
changes propagate to scalar card scalar column editor containers. Most
of the changes are getting the tests to pass with the new signature.
- Changes the metrics reducers to correctly handle these new events.
Logic is mostly unchanged, except that sort order will now be preserved
even after column toggle (previously, toggling would group all disabled
columns together, which destroys relative column order

misc:
- creates moveColumn utility to abstract shared logic between the
hparams and metrics reducers. Removes redundant tests in hparams reducer

## Detailed steps to verify changes work correctly (as executed by you)
- Unit tests pass
- Manually tested sorting behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants