Skip to content
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
18 changes: 16 additions & 2 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@
"category": "DVC",
"icon": "$(run-all)"
},
{
"title": "%command.stopExperimentsQueue%",
"command": "dvc.stopExperimentsQueue",
"category": "DVC"
},
{
"title": "%command.resetAndRunCheckpointExperiment%",
"command": "dvc.resetAndRunCheckpointExperiment",
Expand Down Expand Up @@ -775,7 +780,11 @@
},
{
"command": "dvc.startExperimentsQueue",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.stopExperimentsQueue",
"when": "dvc.commands.available && dvc.project.available"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stop queue command is always available even when the queue isn't running. Would we want the command to only be available when the queue is running?

Copy link
Contributor Author

@mattseddon mattseddon Jan 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to interrogate dvc queue status to know whether or not there is anything running as the information is not readily available from exp show (queue can be started outside of VS Code, e.g in a terminal). It is essentially a no-op when the queue is not running. For now, this is good enough.

},
{
"command": "dvc.selectForCompare",
Expand Down Expand Up @@ -1257,9 +1266,14 @@
},
{
"command": "dvc.startExperimentsQueue",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running",
"when": "view == dvc.views.experimentsTree",
"group": "3_queue@2"
},
{
"command": "dvc.stopExperimentsQueue",
"when": "view == dvc.views.experimentsTree",
"group": "3_queue@3"
},
{
"command": "dvc.addExperimentsTableSort",
"when": "view == dvc.views.experimentsSortByTree",
Expand Down
1 change: 1 addition & 0 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"command.runExperiment": "Run Experiment",
"command.resumeCheckpointExperiment": "Resume Experiment",
"command.startExperimentsQueue": "Start the Experiments Queue",
"command.stopExperimentsQueue": "Stop the Experiments Queue",
"command.resetAndRunCheckpointExperiment": "Run Experiment",
"command.selectForCompare": "Select for Compare",
"command.selectFocusedProjects": "Select Project(s) to Focus (set dvc.focusedProjects)",
Expand Down
3 changes: 2 additions & 1 deletion extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export enum ExperimentSubCommand {
}

export enum QueueSubCommand {
START = 'start'
START = 'start',
STOP = 'stop'
}

export enum ExperimentFlag {
Expand Down
21 changes: 21 additions & 0 deletions extension/src/cli/dvc/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,27 @@ describe('CliExecutor', () => {
})
})

describe('queueStop', () => {
it("should call createProcess with the correct parameters to stop the experiment's queue", async () => {
const cwd = __dirname

const stdout = 'Queue workers will stop after running tasks finish.'

mockedCreateProcess.mockReturnValueOnce(getMockedProcess(stdout))

const output = await dvcExecutor.queueStop(cwd)

expect(output).toStrictEqual(stdout)

expect(mockedCreateProcess).toHaveBeenCalledWith({
args: ['queue', 'stop'],
cwd,
env: mockedEnv,
executable: 'dvc'
})
})
})

describe('remove', () => {
it('should call createProcess with the correct parameters to remove a .dvc file', async () => {
const cwd = __dirname
Expand Down
5 changes: 5 additions & 0 deletions extension/src/cli/dvc/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const autoRegisteredCommands = {
PULL: 'pull',
PUSH: 'push',
QUEUE_START: 'queueStart',
QUEUE_STOP: 'queueStop',
REMOVE: 'remove'
} as const

Expand Down Expand Up @@ -138,6 +139,10 @@ export class DvcExecutor extends DvcCli {
)
}

public queueStop(cwd: string) {
return this.executeDvcProcess(cwd, Command.QUEUE, QueueSubCommand.STOP)
}

public remove(cwd: string, ...args: Args) {
return this.blockAndExecuteProcess(cwd, Command.REMOVE, ...args)
}
Expand Down
1 change: 1 addition & 0 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum RegisteredCliCommands {
EXPERIMENT_SHARE_AS_COMMIT = 'dvc.shareExperimentAsCommit',
QUEUE_EXPERIMENT = 'dvc.queueExperiment',
QUEUE_START = 'dvc.startExperimentsQueue',
QUEUE_STOP = 'dvc.stopExperimentsQueue',

EXPERIMENT_VIEW_APPLY = 'dvc.views.experiments.applyExperiment',
EXPERIMENT_VIEW_BRANCH = 'dvc.views.experiments.branchExperiment',
Expand Down
5 changes: 5 additions & 0 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const registerExperimentCwdCommands = (
)
)

internalCommands.registerExternalCliCommand(
RegisteredCliCommands.QUEUE_STOP,
() => experiments.getCwdThenReport(AvailableCommands.QUEUE_STOP)
)

internalCommands.registerExternalCliCommand(
RegisteredCliCommands.MODIFY_EXPERIMENT_PARAMS_AND_QUEUE,
() =>
Expand Down
1 change: 1 addition & 0 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_VIEW_SHARE_AS_COMMIT]: undefined
[EventName.QUEUE_EXPERIMENT]: undefined
[EventName.QUEUE_START]: undefined
[EventName.QUEUE_STOP]: undefined

[EventName.EXPERIMENT_VIEW_QUEUE]: undefined
[EventName.EXPERIMENT_VIEW_RESUME]: undefined
Expand Down
22 changes: 20 additions & 2 deletions extension/src/test/suite/experiments/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ suite('Workspace Experiments Test Suite', () => {
})

describe('dvc.startExperimentsQueue', () => {
it('should be able to execute all experiments in the run queue', async () => {
it('should be able to start the experiments queue with the selected number of workers', async () => {
const mockQueueStart = stub(DvcExecutor.prototype, 'queueStart').resolves(
undefined
)
Expand All @@ -454,11 +454,29 @@ suite('Workspace Experiments Test Suite', () => {
await commands.executeCommand(RegisteredCliCommands.QUEUE_START)

expect(mockQueueStart).to.be.calledOnce
expect(mockQueueStart).to.be.calledWith(dvcDemoPath, dDosNumberOfJobs)
expect(mockQueueStart).to.be.calledWithExactly(
dvcDemoPath,
dDosNumberOfJobs
)
expect(mockInputBox)
})
})

describe('dvc.stopExperimentsQueue', () => {
it('should be able to stop the experiments queue', async () => {
const mockQueueStop = stub(DvcExecutor.prototype, 'queueStop').resolves(
undefined
)

stubWorkspaceExperimentsGetters(dvcDemoPath)

await commands.executeCommand(RegisteredCliCommands.QUEUE_STOP)

expect(mockQueueStop).to.be.calledOnce
expect(mockQueueStop).to.be.calledWithExactly(dvcDemoPath)
})
})

describe('dvc.applyExperiment', () => {
it('should ask the user to pick an experiment and then apply that experiment to the workspace', async () => {
const selectedExperiment = 'test-branch'
Expand Down