Skip to content

Commit b4c944f

Browse files
authored
Pass extra args to reset and run experiment (#1879)
1 parent 6627f8e commit b4c944f

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

extension/src/cli/runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export class CliRunner extends Disposable implements ICli {
108108
)
109109
}
110110

111-
public runExperimentReset(dvcRoot: string) {
112-
return this.runExperiment(dvcRoot, ExperimentFlag.RESET)
111+
public runExperimentReset(dvcRoot: string, ...args: Args) {
112+
return this.runExperiment(dvcRoot, ExperimentFlag.RESET, ...args)
113113
}
114114

115115
public runExperimentQueue(dvcRoot: string) {

extension/src/experiments/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
CommandId,
2525
InternalCommands
2626
} from '../commands/internal'
27+
import { Args } from '../cli/constants'
2728
import { ExperimentsOutput } from '../cli/reader'
2829
import { ViewKey } from '../webview/constants'
2930
import { BaseRepository } from '../webview/repository'
@@ -420,7 +421,7 @@ export class Experiments extends BaseRepository<TableData> {
420421
)
421422
}
422423

423-
private async runCommand(commandId: CommandId, ...args: string[]) {
424+
private async runCommand(commandId: CommandId, ...args: Args) {
424425
await Toast.showOutput(
425426
this.internalCommands.executeCommand(commandId, this.dvcRoot, ...args)
426427
)

extension/src/experiments/workspace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EventEmitter, Memento } from 'vscode'
22
import { Experiments } from '.'
33
import { TableData } from './webview/contract'
4+
import { Args } from '../cli/constants'
45
import { CommandId, InternalCommands } from '../commands/internal'
56
import { ResourceLocator } from '../resourceLocator'
67
import { Toast } from '../vscode/toast'
@@ -209,15 +210,15 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
209210
commandId: CommandId,
210211
cwd: string,
211212
title: Title,
212-
...args: string[]
213+
...args: Args
213214
) {
214215
const input = await getInput(title)
215216
if (input) {
216217
return this.runCommand(commandId, cwd, ...args, input)
217218
}
218219
}
219220

220-
public runCommand(commandId: CommandId, cwd: string, ...args: string[]) {
221+
public runCommand(commandId: CommandId, cwd: string, ...args: Args) {
221222
return Toast.showOutput(
222223
this.internalCommands.executeCommand(commandId, cwd, ...args)
223224
)

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import * as Telemetry from '../../../telemetry'
6060
import { EventName } from '../../../telemetry/constants'
6161
import * as VscodeContext from '../../../vscode/context'
6262
import { Title } from '../../../vscode/title'
63+
import { ExperimentFlag } from '../../../cli/constants'
6364

6465
suite('Experiments Test Suite', () => {
6566
const disposable = Disposable.fn()
@@ -549,8 +550,10 @@ suite('Experiments Test Suite', () => {
549550
})
550551

551552
it("should be able to handle a message to modify an experiment's params reset and run a new experiment", async () => {
552-
const { experiments, mockExecuteCommand } =
553-
setupExperimentsAndMockCommands()
553+
const { experiments, cliRunner } = buildExperiments(
554+
disposable,
555+
expShowFixture
556+
)
554557

555558
const mockModifiedParams = [
556559
'-S',
@@ -560,6 +563,9 @@ suite('Experiments Test Suite', () => {
560563
]
561564

562565
stub(experiments, 'pickAndModifyParams').resolves(mockModifiedParams)
566+
const mockRunExperiment = stub(cliRunner, 'runExperiment').resolves(
567+
undefined
568+
)
563569

564570
const webview = await experiments.showWebview()
565571
const mockMessageReceived = getMessageReceivedEmitter(webview)
@@ -572,10 +578,10 @@ suite('Experiments Test Suite', () => {
572578
})
573579

574580
await tableChangePromise
575-
expect(mockExecuteCommand).to.be.calledOnce
576-
expect(mockExecuteCommand).to.be.calledWithExactly(
577-
AvailableCommands.EXPERIMENT_RESET_AND_RUN,
581+
expect(mockRunExperiment).to.be.calledOnce
582+
expect(mockRunExperiment).to.be.calledWithExactly(
578583
dvcDemoPath,
584+
ExperimentFlag.RESET,
579585
...mockModifiedParams
580586
)
581587
})

0 commit comments

Comments
 (0)