Skip to content

Commit ee78d51

Browse files
Merge pull request #57 from Demonstrandum/cursor/smoothing-url-parameter-b9fd
Smoothing URL parameter
2 parents 5f84f0d + b6ae977 commit ee78d51

2 files changed

Lines changed: 19 additions & 43 deletions

File tree

tensorbored/webapp/routes/dashboard_deeplink_provider.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
SMOOTHING_KEY,
4242
TAG_FILTER_KEY,
4343
} from './dashboard_deeplink_provider_types';
44+
// Note: SMOOTHING_KEY is only used for deserialization (backwards compat with old URLs).
4445
import {featureFlagsToSerializableQueryParams} from './feature_flag_serializer';
4546

4647
const COLOR_GROUP_REGEX_VALUE_PREFIX = 'regex:';
@@ -49,17 +50,20 @@ const COLOR_GROUP_REGEX_BY_EXP_VALUE_PREFIX = 'regex_by_exp:';
4950
/**
5051
* Provides deeplinking for the core dashboards page.
5152
*
52-
* Note: Pinned cards are NO LONGER stored in the URL to avoid URL length
53-
* limitations. Pins are now stored in localStorage via the profile system.
53+
* Note: Pinned cards and smoothing are NO LONGER stored in the URL.
54+
* Pins are stored in localStorage via the profile system to avoid URL length
55+
* limitations. Smoothing is persisted in localStorage only.
5456
* See https://github.com/tensorflow/tensorboard/issues/4242 for context.
5557
*
5658
* The URL still supports:
5759
* - tagFilter: for filtering displayed tags
58-
* - smoothing: scalar smoothing setting
5960
* - runColorGroup: run color grouping configuration
6061
* - runFilter: run selector regex filter
6162
* - Feature flags
6263
*
64+
* For backwards compatibility, smoothing and pinnedCards are still
65+
* deserialized from the URL if present (e.g. from old bookmarked URLs).
66+
*
6367
* For sharing complete dashboard configurations including pins, use the
6468
* profile export/import functionality.
6569
*/
@@ -91,19 +95,6 @@ export class DashboardDeepLinkProvider extends DeepLinkProvider {
9195
);
9296
})
9397
),
94-
store.select(selectors.getMetricsSettingOverrides).pipe(
95-
map((settingOverrides) => {
96-
if (Number.isFinite(settingOverrides.scalarSmoothing)) {
97-
return [
98-
{
99-
key: SMOOTHING_KEY,
100-
value: String(settingOverrides.scalarSmoothing),
101-
},
102-
];
103-
}
104-
return [];
105-
})
106-
),
10798
store.select(selectors.getRunUserSetGroupBy).pipe(
10899
map((groupBy) => {
109100
if (!groupBy) return [];

tensorbored/webapp/routes/dashboard_deeplink_provider_test.ts

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,19 @@ describe('core deeplink provider', () => {
6969

7070
describe('time series', () => {
7171
describe('smoothing state', () => {
72-
it('serializes the smoothing state to the URL', () => {
72+
it('does NOT serialize smoothing to the URL (stored in localStorage instead)', () => {
7373
store.overrideSelector(selectors.getMetricsSettingOverrides, {
74-
scalarSmoothing: 0,
74+
scalarSmoothing: 0.6,
7575
});
76+
store.overrideSelector(selectors.getMetricsTagFilter, 'trigger');
7677
store.refreshState();
7778

78-
expect(queryParamsSerialized[queryParamsSerialized.length - 1]).toEqual(
79-
[
80-
{
81-
key: 'smoothing',
82-
value: '0',
83-
},
84-
]
85-
);
86-
});
87-
88-
it('does not reflect state when there is no override', () => {
89-
store.overrideSelector(selectors.getMetricsSettingOverrides, {});
90-
91-
store.refreshState();
92-
93-
expect(queryParamsSerialized[queryParamsSerialized.length - 1]).toEqual(
94-
[]
95-
);
79+
const lastEmission =
80+
queryParamsSerialized[queryParamsSerialized.length - 1];
81+
expect(lastEmission).toBeDefined();
82+
expect(
83+
lastEmission.find((p: {key: string}) => p.key === 'smoothing')
84+
).toBeUndefined();
9685
});
9786

9887
it('deserializes the state in the URL without much sanitization', () => {
@@ -176,23 +165,19 @@ describe('core deeplink provider', () => {
176165
it('serializes nothing when states are empty', () => {
177166
store.overrideSelector(selectors.getPinnedCardsWithMetadata, []);
178167
store.overrideSelector(selectors.getUnresolvedImportedPinnedCards, []);
179-
// Trigger an emission by changing a serialized selector (smoothing)
180-
store.overrideSelector(selectors.getMetricsSettingOverrides, {
181-
scalarSmoothing: 0.5,
182-
});
168+
// Trigger an emission by changing a serialized selector (tag filter)
169+
store.overrideSelector(selectors.getMetricsTagFilter, 'trigger');
183170
store.refreshState();
184171

185-
// Verify emission occurred and does NOT contain pinned cards
186172
const lastEmission =
187173
queryParamsSerialized[queryParamsSerialized.length - 1];
188174
expect(lastEmission).toBeDefined();
189-
// Should only have smoothing, no pinnedCards
190175
expect(
191176
lastEmission.find((p: {key: string}) => p.key === 'pinnedCards')
192177
).toBeUndefined();
193178
expect(
194179
lastEmission.find((p: {key: string}) => p.key === 'smoothing')
195-
).toBeDefined();
180+
).toBeUndefined();
196181
});
197182

198183
// Deserialization still works for backwards compatibility with old URLs

0 commit comments

Comments
 (0)