Skip to content

Commit c322a1d

Browse files
authored
Exclude queued experiments from select experiments for plots quick pick (#2410)
1 parent 5f0dbaf commit c322a1d

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

extension/src/experiments/model/index.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,21 @@ export class ExperimentsModel extends ModelWithPersistence {
324324
}
325325

326326
public getExperimentsWithCheckpoints(): ExperimentWithCheckpoints[] {
327-
return this.getExperiments().map(experiment => {
328-
const checkpoints = this.getCheckpointsWithType(experiment.id)
327+
const experimentsWithCheckpoints: ExperimentWithCheckpoints[] = []
328+
for (const experiment of this.getExperiments()) {
329+
const { id, queued } = experiment
330+
if (queued) {
331+
continue
332+
}
333+
334+
const checkpoints = this.getCheckpointsWithType(id)
329335
if (!definedAndNonEmpty(checkpoints)) {
330-
return experiment
336+
experimentsWithCheckpoints.push(experiment)
337+
continue
331338
}
332-
return { ...experiment, checkpoints }
333-
})
339+
experimentsWithCheckpoints.push({ ...experiment, checkpoints })
340+
}
341+
return experimentsWithCheckpoints
334342
}
335343

336344
public getExperimentParams(id: string) {

extension/src/test/suite/experiments/model/tree.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
QuickPickItemWithValue,
4545
QuickPickOptionsWithTitle
4646
} from '../../../../vscode/quickPick'
47+
import * as QuickPickWrapper from '../../../../vscode/quickPick'
4748
import { Response } from '../../../../vscode/response'
4849
import { DvcExecutor } from '../../../../cli/dvc/executor'
4950
import { Param } from '../../../../experiments/model/modify/collect'
@@ -63,6 +64,7 @@ suite('Experiments Tree Test Suite', () => {
6364
disposable.dispose()
6465
})
6566

67+
// eslint-disable-next-line sonarjs/cognitive-complexity
6668
describe('ExperimentsTree', () => {
6769
const { colors } = checkpointPlotsFixture
6870
const { domain, range } = colors
@@ -150,6 +152,34 @@ suite('Experiments Tree Test Suite', () => {
150152
).to.be.calledOnceWith(false)
151153
}).timeout(WEBVIEW_TEST_TIMEOUT)
152154

155+
it('should not show queued experiments in the dvc.views.experimentsTree.selectExperiments quick pick', async () => {
156+
await buildPlots(disposable)
157+
158+
const mockQuickPickLimitedValues = stub(
159+
QuickPickWrapper,
160+
'quickPickLimitedValues'
161+
).resolves(undefined)
162+
163+
await commands.executeCommand(RegisteredCommands.EXPERIMENT_SELECT)
164+
165+
const [availableItems] = mockQuickPickLimitedValues.lastCall.args
166+
167+
expect(availableItems.length).to.be.greaterThan(0)
168+
const queued = []
169+
170+
for (const experimentOrSeparator of availableItems) {
171+
if (
172+
(experimentOrSeparator?.value as { type: ExperimentType })?.type ===
173+
ExperimentType.QUEUED
174+
) {
175+
queued.push(experimentOrSeparator)
176+
}
177+
}
178+
179+
expect(mockQuickPickLimitedValues).to.be.calledOnce
180+
expect(queued).to.deep.equal([])
181+
}).timeout(WEBVIEW_TEST_TIMEOUT)
182+
153183
it('should be able to select / de-select experiments using dvc.views.experimentsTree.selectExperiments', async () => {
154184
const { plots, messageSpy } = await buildPlots(disposable)
155185

0 commit comments

Comments
 (0)