-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
tensorboard/webapp/metrics/data_source/saved_pins_data_source_test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
There was a problem hiding this 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", |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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]) => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()), |
There was a problem hiding this comment.
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?
tensorboard/tensorboard/webapp/persistent_settings/_redux/persistent_settings_selectors.ts
Line 26 in 04a064f
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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()), |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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]) => { |
There was a problem hiding this comment.
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
## 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
## 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
## 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
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.saveScalarPin
,removeScalarPin
, andgetSavedScalarPins
.Added
addOrRemovePin$
effect in themetrics/effects/index.ts
actions. cardPinStateToggled
is triggered, find the card info in thevisibeCardFetchInfos
, 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)
Alternate designs / implementations considered (or N/A)
N/A