Skip to content

Commit d6bacf4

Browse files
sroy3mattseddon
andauthored
Remove the plot section renamer feature (#1855)
Co-authored-by: mattseddon <[email protected]>
1 parent 4fe9c51 commit d6bacf4

File tree

25 files changed

+42
-332
lines changed

25 files changed

+42
-332
lines changed

extension/src/persistence/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ export enum PersistenceKey {
1111
PLOT_SECTION_COLLAPSED = 'plotSectionCollapsed:',
1212
PLOT_SELECTED_METRICS = 'plotSelectedMetrics:',
1313
PLOT_SIZES = 'plotSizes:',
14-
PLOT_SECTION_NAMES = 'plotSectionNames:',
1514
PLOT_TEMPLATE_ORDER = 'plotTemplateOrder:'
1615
}

extension/src/plots/index.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export class Plots extends BaseRepository<TPlotsData> {
188188

189189
return {
190190
plots,
191-
sectionName: this.plots.getSectionName(Section.TEMPLATE_PLOTS),
192191
size: this.plots.getPlotSize(Section.TEMPLATE_PLOTS)
193192
}
194193
}
@@ -204,7 +203,6 @@ export class Plots extends BaseRepository<TPlotsData> {
204203
plots: comparison.map(({ path, revisions }) => {
205204
return { path, revisions: this.getRevisionsWithCorrectUrls(revisions) }
206205
}),
207-
sectionName: this.plots.getSectionName(Section.COMPARISON_TABLE),
208206
size: this.plots.getPlotSize(Section.COMPARISON_TABLE)
209207
}
210208
}
@@ -248,11 +246,6 @@ export class Plots extends BaseRepository<TPlotsData> {
248246
)
249247
case MessageFromWebviewType.TOGGLE_PLOTS_SECTION:
250248
return this.setSectionCollapsed(message.payload)
251-
case MessageFromWebviewType.RENAME_SECTION:
252-
return this.setSectionName(
253-
message.payload.section,
254-
message.payload.name
255-
)
256249
case MessageFromWebviewType.REORDER_PLOTS_COMPARISON:
257250
return this.setComparisonOrder(message.payload)
258251
case MessageFromWebviewType.REORDER_PLOTS_TEMPLATES:
@@ -302,15 +295,6 @@ export class Plots extends BaseRepository<TPlotsData> {
302295
)
303296
}
304297

305-
private setSectionName(section: Section, name: string) {
306-
this.plots?.setSectionName(section, name)
307-
sendTelemetryEvent(
308-
EventName.VIEWS_PLOTS_RENAME_SECTION,
309-
{ section },
310-
undefined
311-
)
312-
}
313-
314298
private setComparisonOrder(order: string[]) {
315299
this.plots?.setComparisonOrder(order)
316300
this.webview?.show({

extension/src/plots/model/index.test.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PlotsModel } from '.'
22
import {
33
DEFAULT_SECTION_COLLAPSED,
4-
DEFAULT_SECTION_NAMES,
54
DEFAULT_SECTION_SIZES,
65
PlotSize,
76
Section
@@ -87,49 +86,6 @@ describe('plotsModel', () => {
8786
)
8887
})
8988

90-
it('should change the the sectionName of a section when calling setSectionName', () => {
91-
expect(model.getSectionName(Section.CHECKPOINT_PLOTS)).toStrictEqual(
92-
DEFAULT_SECTION_NAMES[Section.CHECKPOINT_PLOTS]
93-
)
94-
expect(model.getSectionName(Section.TEMPLATE_PLOTS)).toStrictEqual(
95-
DEFAULT_SECTION_NAMES[Section.TEMPLATE_PLOTS]
96-
)
97-
98-
const newCheckpointPlotsName = 'Previously called live'
99-
model.setSectionName(Section.CHECKPOINT_PLOTS, newCheckpointPlotsName)
100-
101-
expect(model.getSectionName(Section.CHECKPOINT_PLOTS)).toStrictEqual(
102-
newCheckpointPlotsName
103-
)
104-
expect(model.getSectionName(Section.TEMPLATE_PLOTS)).toStrictEqual(
105-
DEFAULT_SECTION_NAMES[Section.TEMPLATE_PLOTS]
106-
)
107-
108-
const newTemplatePlotsName = 'Previously Called Static'
109-
model.setSectionName(Section.TEMPLATE_PLOTS, newTemplatePlotsName)
110-
expect(model.getSectionName(Section.TEMPLATE_PLOTS)).toStrictEqual(
111-
newTemplatePlotsName
112-
)
113-
})
114-
115-
it('should update the persisted section names when calling setSectionName', () => {
116-
const mementoUpdateSpy = jest.spyOn(memento, 'update')
117-
118-
const newName = 'Important Plots'
119-
model.setSectionName(Section.CHECKPOINT_PLOTS, newName)
120-
121-
expect(mementoUpdateSpy).toHaveBeenCalledTimes(1)
122-
expect(mementoUpdateSpy).toHaveBeenCalledWith(
123-
PersistenceKey.PLOT_SECTION_NAMES + exampleDvcRoot,
124-
{
125-
[Section.CHECKPOINT_PLOTS]: newName,
126-
[Section.TEMPLATE_PLOTS]: DEFAULT_SECTION_NAMES[Section.TEMPLATE_PLOTS],
127-
[Section.COMPARISON_TABLE]:
128-
DEFAULT_SECTION_NAMES[Section.COMPARISON_TABLE]
129-
}
130-
)
131-
})
132-
13389
it('should update the persisted collapsible section state when calling setSectionCollapsed', () => {
13490
const mementoUpdateSpy = jest.spyOn(memento, 'update')
13591

extension/src/plots/model/index.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
Revision,
2020
ComparisonRevisionData,
2121
DEFAULT_SECTION_COLLAPSED,
22-
DEFAULT_SECTION_NAMES,
2322
DEFAULT_SECTION_SIZES,
2423
PlotSize,
2524
Section,
@@ -39,7 +38,6 @@ export class PlotsModel extends ModelWithPersistence {
3938

4039
private plotSizes: Record<Section, PlotSize>
4140
private sectionCollapsed: SectionCollapsed
42-
private sectionNames: Record<Section, string>
4341
private branchRevisions: Record<string, string> = {}
4442
private workspaceRunningCheckpoint: string | undefined
4543

@@ -71,10 +69,6 @@ export class PlotsModel extends ModelWithPersistence {
7169
PersistenceKey.PLOT_SECTION_COLLAPSED,
7270
DEFAULT_SECTION_COLLAPSED
7371
)
74-
this.sectionNames = this.revive(
75-
PersistenceKey.PLOT_SECTION_NAMES,
76-
DEFAULT_SECTION_NAMES
77-
)
7872
this.comparisonOrder = this.revive(PersistenceKey.PLOT_COMPARISON_ORDER, [])
7973
this.selectedMetrics = this.revive(
8074
PersistenceKey.PLOT_SELECTED_METRICS,
@@ -153,7 +147,6 @@ export class PlotsModel extends ModelWithPersistence {
153147
return {
154148
colors,
155149
plots: this.getPlots(this.checkpointPlots, selectedExperiments),
156-
sectionName: this.getSectionName(Section.CHECKPOINT_PLOTS),
157150
selectedMetrics: this.getSelectedMetrics(),
158151
size: this.getPlotSize(Section.CHECKPOINT_PLOTS)
159152
}
@@ -289,15 +282,6 @@ export class PlotsModel extends ModelWithPersistence {
289282
return this.sectionCollapsed
290283
}
291284

292-
public setSectionName(section: Section, name: string) {
293-
this.sectionNames[section] = name
294-
this.persist(PersistenceKey.PLOT_SECTION_NAMES, this.sectionNames)
295-
}
296-
297-
public getSectionName(section: Section): string {
298-
return this.sectionNames[section] || DEFAULT_SECTION_NAMES[section]
299-
}
300-
301285
private removeStaleData() {
302286
return Promise.all([
303287
this.removeStaleBranches(),

extension/src/plots/webview/contract.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ export enum Section {
1616
COMPARISON_TABLE = 'comparison-table'
1717
}
1818

19-
export const DEFAULT_SECTION_NAMES = {
20-
[Section.CHECKPOINT_PLOTS]: 'Trends',
21-
[Section.TEMPLATE_PLOTS]: 'Data Series',
22-
[Section.COMPARISON_TABLE]: 'Images'
23-
}
24-
2519
export const DEFAULT_SECTION_SIZES = {
2620
[Section.CHECKPOINT_PLOTS]: PlotSize.REGULAR,
2721
[Section.TEMPLATE_PLOTS]: PlotSize.REGULAR,
@@ -52,7 +46,6 @@ export type Revision = {
5246

5347
export interface PlotsComparisonData {
5448
plots: ComparisonPlots
55-
sectionName: string
5649
size: PlotSize
5750
}
5851

@@ -73,7 +66,6 @@ export type CheckpointPlotsData = {
7366
plots: CheckpointPlotData[]
7467
colors: ColorScale
7568
size: PlotSize
76-
sectionName: string
7769
selectedMetrics?: string[]
7870
}
7971

@@ -121,7 +113,6 @@ export type TemplatePlotSection = {
121113

122114
export interface TemplatePlotsData {
123115
plots: TemplatePlotSection[]
124-
sectionName: string
125116
size: PlotSize
126117
}
127118

extension/src/telemetry/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const EventName = Object.assign(
5454
VIEWS_PLOTS_FOCUS_CHANGED: 'views.plots.focusChanged',
5555
VIEWS_PLOTS_MANUAL_REFRESH: 'views.plots.manualRefresh',
5656
VIEWS_PLOTS_METRICS_SELECTED: 'views.plots.metricsSelected',
57-
VIEWS_PLOTS_RENAME_SECTION: 'views.plots.sectionRenamed',
5857
VIEWS_PLOTS_REVISIONS_REORDERED: 'views.plots.revisionsReordered',
5958
VIEWS_PLOTS_SECTION_RESIZED: 'views.plots.sectionResized',
6059
VIEWS_PLOTS_SECTION_TOGGLE: 'views.plots.toggleSection',
@@ -207,7 +206,6 @@ export interface IEventNamePropertyMapping {
207206
[EventName.VIEWS_PLOTS_FOCUS_CHANGED]: WebviewFocusChangedProperties
208207
[EventName.VIEWS_PLOTS_MANUAL_REFRESH]: { revisions: number }
209208
[EventName.VIEWS_PLOTS_METRICS_SELECTED]: undefined
210-
[EventName.VIEWS_PLOTS_RENAME_SECTION]: { section: Section }
211209
[EventName.VIEWS_PLOTS_REVISIONS_REORDERED]: undefined
212210
[EventName.VIEWS_PLOTS_SECTION_RESIZED]: { section: Section; size: PlotSize }
213211
[EventName.VIEWS_PLOTS_SECTION_TOGGLE]: Partial<SectionCollapsed>

extension/src/test/fixtures/expShow/checkpointPlots.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { copyOriginalColors } from '../../../experiments/model/status/colors'
2-
import {
3-
DEFAULT_SECTION_NAMES,
4-
CheckpointPlotsData,
5-
PlotSize,
6-
Section
7-
} from '../../../plots/webview/contract'
2+
import { CheckpointPlotsData, PlotSize } from '../../../plots/webview/contract'
83

94
const colors = copyOriginalColors()
105

@@ -89,8 +84,7 @@ const data: CheckpointPlotsData = {
8984
'summary.json:val_loss',
9085
'summary.json:val_accuracy'
9186
],
92-
size: PlotSize.REGULAR,
93-
sectionName: DEFAULT_SECTION_NAMES[Section.CHECKPOINT_PLOTS]
87+
size: PlotSize.REGULAR
9488
}
9589

9690
export const manyCheckpointPlots = (length: number) =>

extension/src/test/fixtures/plotsDiff/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import { PlotsOutput } from '../../../cli/reader'
55
import {
66
ComparisonPlots,
77
ComparisonRevisionData,
8-
DEFAULT_SECTION_NAMES,
98
TemplatePlotSection,
109
PlotSize,
1110
PlotsType,
12-
Section,
1311
TemplatePlotGroup,
1412
TemplatePlotsData,
1513
TemplatePlots
@@ -531,14 +529,12 @@ export const getRevisions = () => {
531529

532530
export const getMinimalWebviewMessage = () => ({
533531
plots: extendedSpecs(basicVega),
534-
sectionName: DEFAULT_SECTION_NAMES[Section.TEMPLATE_PLOTS],
535532
size: PlotSize.REGULAR,
536533
revisions: getRevisions()
537534
})
538535

539536
export const getTemplateWebviewMessage = (): TemplatePlotsData => ({
540537
plots: extendedSpecs({ ...basicVega, ...require('./vega').default }),
541-
sectionName: DEFAULT_SECTION_NAMES[Section.TEMPLATE_PLOTS],
542538
size: PlotSize.REGULAR
543539
})
544540

@@ -548,7 +544,6 @@ export const getManyTemplatePlotsWebviewMessage = (
548544
plots: extendedSpecs({
549545
...multipleVega(length)
550546
}),
551-
sectionName: DEFAULT_SECTION_NAMES[Section.TEMPLATE_PLOTS],
552547
size: PlotSize.REGULAR
553548
})
554549

@@ -574,7 +569,6 @@ export const getComparisonWebviewMessage = (
574569

575570
return {
576571
plots: plotAcc,
577-
sectionName: DEFAULT_SECTION_NAMES[Section.COMPARISON_TABLE],
578572
size: PlotSize.REGULAR
579573
}
580574
}

extension/src/test/suite/plots/index.test.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -384,37 +384,6 @@ suite('Plots Test Suite', () => {
384384
)
385385
}).timeout(WEBVIEW_TEST_TIMEOUT)
386386

387-
it('should handle a section renamed message from the webview', async () => {
388-
const { plots, plotsModel } = await buildPlots(disposable)
389-
390-
const webview = await plots.showWebview()
391-
392-
const mockSendTelemetryEvent = stub(Telemetry, 'sendTelemetryEvent')
393-
const mockMessageReceived = getMessageReceivedEmitter(webview)
394-
395-
const mockSetSectionName = stub(plotsModel, 'setSectionName').returns(
396-
undefined
397-
)
398-
const mockName = 'some cool section name'
399-
400-
mockMessageReceived.fire({
401-
payload: { name: mockName, section: Section.TEMPLATE_PLOTS },
402-
type: MessageFromWebviewType.RENAME_SECTION
403-
})
404-
405-
expect(mockSetSectionName).to.be.calledOnce
406-
expect(mockSetSectionName).to.be.calledWithExactly(
407-
Section.TEMPLATE_PLOTS,
408-
mockName
409-
)
410-
expect(mockSendTelemetryEvent).to.be.calledOnce
411-
expect(mockSendTelemetryEvent).to.be.calledWithExactly(
412-
EventName.VIEWS_PLOTS_RENAME_SECTION,
413-
{ section: Section.TEMPLATE_PLOTS },
414-
undefined
415-
)
416-
}).timeout(WEBVIEW_TEST_TIMEOUT)
417-
418387
it('should handle a comparison revisions reordered message from the webview', async () => {
419388
const { plots, plotsModel, messageSpy } = await buildPlots(
420389
disposable,

extension/src/test/suite/plots/util.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const getExpectedCheckpointPlotsData = (
9595
domain: string[],
9696
range: Color[]
9797
) => {
98-
const { plots, sectionName, selectedMetrics, size } = checkpointPlotsFixture
98+
const { plots, selectedMetrics, size } = checkpointPlotsFixture
9999
return {
100100
checkpoint: {
101101
colors: {
@@ -106,7 +106,6 @@ export const getExpectedCheckpointPlotsData = (
106106
title: plot.title,
107107
values: plot.values.filter(values => domain.includes(values.group))
108108
})),
109-
sectionName,
110109
selectedMetrics,
111110
size
112111
}

0 commit comments

Comments
 (0)