Skip to content
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

Pass extra args to Reset and Run command #1879

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extension/src/cli/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export class CliRunner extends Disposable implements ICli {
)
}

public runExperimentReset(dvcRoot: string) {
return this.runExperiment(dvcRoot, ExperimentFlag.RESET)
public runExperimentReset(dvcRoot: string, ...args: Args) {
return this.runExperiment(dvcRoot, ExperimentFlag.RESET, ...args)
}

public runExperimentQueue(dvcRoot: string) {
Expand Down
3 changes: 2 additions & 1 deletion extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
CommandId,
InternalCommands
} from '../commands/internal'
import { Args } from '../cli/constants'
import { ExperimentsOutput } from '../cli/reader'
import { ViewKey } from '../webview/constants'
import { BaseRepository } from '../webview/repository'
Expand Down Expand Up @@ -420,7 +421,7 @@ export class Experiments extends BaseRepository<TableData> {
)
}

private async runCommand(commandId: CommandId, ...args: string[]) {
private async runCommand(commandId: CommandId, ...args: Args) {
await Toast.showOutput(
this.internalCommands.executeCommand(commandId, this.dvcRoot, ...args)
)
Expand Down
5 changes: 3 additions & 2 deletions extension/src/experiments/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { EventEmitter, Memento } from 'vscode'
import { Experiments } from '.'
import { TableData } from './webview/contract'
import { Args } from '../cli/constants'
import { CommandId, InternalCommands } from '../commands/internal'
import { ResourceLocator } from '../resourceLocator'
import { Toast } from '../vscode/toast'
Expand Down Expand Up @@ -209,15 +210,15 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
commandId: CommandId,
cwd: string,
title: Title,
...args: string[]
...args: Args
) {
const input = await getInput(title)
if (input) {
return this.runCommand(commandId, cwd, ...args, input)
}
}

public runCommand(commandId: CommandId, cwd: string, ...args: string[]) {
public runCommand(commandId: CommandId, cwd: string, ...args: Args) {
return Toast.showOutput(
this.internalCommands.executeCommand(commandId, cwd, ...args)
)
Expand Down
16 changes: 11 additions & 5 deletions extension/src/test/suite/experiments/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import * as Telemetry from '../../../telemetry'
import { EventName } from '../../../telemetry/constants'
import * as VscodeContext from '../../../vscode/context'
import { Title } from '../../../vscode/title'
import { ExperimentFlag } from '../../../cli/constants'

suite('Experiments Test Suite', () => {
const disposable = Disposable.fn()
Expand Down Expand Up @@ -549,8 +550,10 @@ suite('Experiments Test Suite', () => {
})

it("should be able to handle a message to modify an experiment's params reset and run a new experiment", async () => {
const { experiments, mockExecuteCommand } =
setupExperimentsAndMockCommands()
const { experiments, cliRunner } = buildExperiments(
disposable,
expShowFixture
)

const mockModifiedParams = [
'-S',
Expand All @@ -560,6 +563,9 @@ suite('Experiments Test Suite', () => {
]

stub(experiments, 'pickAndModifyParams').resolves(mockModifiedParams)
const mockRunExperiment = stub(cliRunner, 'runExperiment').resolves(
undefined
)

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

await tableChangePromise
expect(mockExecuteCommand).to.be.calledOnce
expect(mockExecuteCommand).to.be.calledWithExactly(
AvailableCommands.EXPERIMENT_RESET_AND_RUN,
expect(mockRunExperiment).to.be.calledOnce
expect(mockRunExperiment).to.be.calledWithExactly(
dvcDemoPath,
ExperimentFlag.RESET,
...mockModifiedParams
)
})
Expand Down