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

[Global pins] Saving pins to localStorage #6819

Merged
merged 7 commits into from
Apr 3, 2024

Conversation

roseayeon
Copy link
Contributor

@roseayeon roseayeon commented Apr 1, 2024

Motivation for features / changes

[Global pins] To extend pinned card info available globally, this PR saves pinned info to localStorage

Technical description of changes

  • Introduced savedPinsDataSource to store pinned card tag information in local storage.

    • Since the focus in on saving scalar cards, only the tag name is persisted.
    • Implemented methods saveScalarPin, removeScalarPin, and getSavedScalarPins.
  • Added addOrRemovePin$ effect in the metrics/effects/index.ts

    • When the actions. cardPinStateToggled is triggered, find the card info in the visibeCardFetchInfos , and the scalar pin info is saved or removed accordingly.

Screenshots of UI changes (or N/A)

N/A

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

  • Unit tests pass

Alternate designs / implementations considered (or N/A)

N/A

Copy link
Member

@hoonji hoonji left a comment

Choose a reason for hiding this comment

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

Looks great! Note that @rileyajones is OOO atm.

tensorboard/webapp/metrics/effects/index.ts Outdated Show resolved Hide resolved
tensorboard/webapp/metrics/effects/metrics_effects_test.ts Outdated Show resolved Hide resolved
tensorboard/webapp/metrics/effects/metrics_effects_test.ts Outdated Show resolved Hide resolved
@roseayeon roseayeon requested review from bmd3k and hoonji and removed request for rileyajones April 2, 2024 06:06
Copy link
Contributor

@bmd3k bmd3k left a comment

Choose a reason for hiding this comment

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

Approved! But please consider protecting with a feature flag before merging.

],
deps = [
":saved_pins_data_source",
"//tensorboard/webapp/angular:expect_angular_core_testing",
Copy link
Contributor

Choose a reason for hiding this comment

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

If you haven't already, please don't forget to use copybara_presubmit to import the changes into a local google3 repo and run TAP on it.

(I have no reason to believe that the import will fail but I just want to make sure you've done that step).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I almost forgot to use copybara_presubmit. I checked that TAP passed.

private readonly addOrRemovePin$ = this.actions$.pipe(
ofType(actions.cardPinStateToggled),
withLatestFrom(this.getVisibleCardFetchInfos()),
map(([{cardId, canCreateNewPins, wasPinned}, fetchInfos]) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we protect this with a feature flag until you have the entire feature built and tested end-to-end?

I'm worried you will build out the rest of the feature and test it and find some reason to make changes to the storage layer. However, people will already have started writing their pins to local storage (even if they don't see the rest of this feature) and perhaps what they store will be incompatible with the final version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SGTM! Added a new feature flag

@@ -261,6 +263,23 @@ export class MetricsEffects implements OnInitEffects {
})
);

private readonly addOrRemovePin$ = this.actions$.pipe(
ofType(actions.cardPinStateToggled),
withLatestFrom(this.getVisibleCardFetchInfos()),
Copy link
Contributor

Choose a reason for hiding this comment

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

(For a followup PR):

Can we check getShouldPersistSettings() before deciding whether to write state?

export const getShouldPersistSettings = createSelector(

The idea is:

  • Internally we have a share feature (in tbcorp).
  • If you load a shared tensorboard, we don't believe any decisions you make should be persisted in local storage and affect your regular usage.
  • getShouldPersistSettings captures this (it returns true by default but returns false if you load a shared dashboard)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC, if a shared TensorBoard is used, we should not store user activities in local storage. To determine this, we need to check if getShouldPersistSettings is true. If so, we can store in the local storage; otherwise, we should not. Is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is exactly what I would recommend.

Copy link
Contributor Author

@roseayeon roseayeon left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed comments! It was so helpful

@@ -261,6 +263,23 @@ export class MetricsEffects implements OnInitEffects {
})
);

private readonly addOrRemovePin$ = this.actions$.pipe(
ofType(actions.cardPinStateToggled),
withLatestFrom(this.getVisibleCardFetchInfos()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC, if a shared TensorBoard is used, we should not store user activities in local storage. To determine this, we need to check if getShouldPersistSettings is true. If so, we can store in the local storage; otherwise, we should not. Is this correct?

],
deps = [
":saved_pins_data_source",
"//tensorboard/webapp/angular:expect_angular_core_testing",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I almost forgot to use copybara_presubmit. I checked that TAP passed.

private readonly addOrRemovePin$ = this.actions$.pipe(
ofType(actions.cardPinStateToggled),
withLatestFrom(this.getVisibleCardFetchInfos()),
map(([{cardId, canCreateNewPins, wasPinned}, fetchInfos]) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

SGTM! Added a new feature flag

@roseayeon roseayeon merged commit 4f4801c into tensorflow:master Apr 3, 2024
13 checks passed
roseayeon added a commit that referenced this pull request Apr 4, 2024
## Motivation for features / changes
Following #6819 [Global pins] To extend pinned card info available
globally , this PR load saved pins in the localStorage.
## Technical description of changes
* 3e5b052 Introduced new action
called`metricsUnresolvedPinnedCardsAdded`.
* When `metricsUnresolvedPinnedCardsAdded` is dispatched, the reducer
adds the provided card info to the `state.
unresolvedImportedPinnedCards`.

* aae9be4 Added `loadSavedPins$` effect in the
`metrics/effects/index.ts`
* When `coreActions.pluginsListingLoaded` is triggered, it loads saved
scalar pins in the localStorage and dispatch
`metricsUnresolvedPinnedCardsAdded` with saved pinned cards.
  
* Added `getShouldPersistSettings()` checking logic (metioned in
#6819 (comment))
* 2dc49aa To use selector globally, added
`persistent_settings_selectors` to the `webapp/selectors`.
* Add checking `getShouldPersistSettings` in the `loadSavedPins$` and
`addOrRemovePin$`.
 
## Screenshots of UI changes (or N/A)
N/A
## Detailed steps to verify changes work correctly (as executed by you)
* Unit test pass & TAP presubmit pass 
## Alternate designs / implementations considered (or N/A)
N.A
@roseayeon roseayeon deleted the global-pin branch April 5, 2024 04:53
AnuarTB pushed a commit to AnuarTB/tensorboard that referenced this pull request May 3, 2024
## Motivation for features / changes
[Global pins] To extend pinned card info available globally, this PR
saves pinned info to localStorage

## Technical description of changes
* Introduced `savedPinsDataSource` to store pinned card tag information
in local storage.
* Since the focus in on saving scalar cards, only the tag name is
persisted.
* Implemented methods `saveScalarPin`, `removeScalarPin`, and
`getSavedScalarPins`.

* Added `addOrRemovePin$` effect in the `metrics/effects/index.ts`
* When the `actions. cardPinStateToggled` is triggered, find the card
info in the `visibeCardFetchInfos` , and the scalar pin info is saved or
removed accordingly.


## Screenshots of UI changes (or N/A)
N/A
## Detailed steps to verify changes work correctly (as executed by you)
* Unit tests pass
## Alternate designs / implementations considered (or N/A)
N/A
AnuarTB pushed a commit to AnuarTB/tensorboard that referenced this pull request May 3, 2024
## Motivation for features / changes
Following tensorflow#6819 [Global pins] To extend pinned card info available
globally , this PR load saved pins in the localStorage.
## Technical description of changes
* 3e5b052 Introduced new action
called`metricsUnresolvedPinnedCardsAdded`.
* When `metricsUnresolvedPinnedCardsAdded` is dispatched, the reducer
adds the provided card info to the `state.
unresolvedImportedPinnedCards`.

* aae9be4 Added `loadSavedPins$` effect in the
`metrics/effects/index.ts`
* When `coreActions.pluginsListingLoaded` is triggered, it loads saved
scalar pins in the localStorage and dispatch
`metricsUnresolvedPinnedCardsAdded` with saved pinned cards.
  
* Added `getShouldPersistSettings()` checking logic (metioned in
tensorflow#6819 (comment))
* 2dc49aa To use selector globally, added
`persistent_settings_selectors` to the `webapp/selectors`.
* Add checking `getShouldPersistSettings` in the `loadSavedPins$` and
`addOrRemovePin$`.
 
## Screenshots of UI changes (or N/A)
N/A
## Detailed steps to verify changes work correctly (as executed by you)
* Unit test pass & TAP presubmit pass 
## Alternate designs / implementations considered (or N/A)
N.A
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.

None yet

3 participants