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

Add remove experiment queue command #1453

Merged
merged 2 commits into from
Mar 17, 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
9 changes: 9 additions & 0 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@
"command": "dvc.removeExperiment",
"category": "DVC"
},
{
"title": "%command.removeExperimentQueue%",
"command": "dvc.removeExperimentQueue",
"category": "DVC"
},
{
"title": "%command.removeExperimentsTableFilters%",
"command": "dvc.removeExperimentsTableFilters",
Expand Down Expand Up @@ -496,6 +501,10 @@
"command": "dvc.removeExperiment",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.removeExperimentQueue",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.removeExperimentsTableFilters",
"when": "dvc.commands.available && dvc.project.available"
Expand Down
1 change: 1 addition & 0 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"command.queueExperimentFromExisting": "Queue Experiment From Existing",
"command.queueExperiment": "Queue Experiment",
"command.removeExperiment": "Remove Experiment",
"command.removeExperimentQueue": "Remove All Queued Experiments",
"command.removeExperimentsTableFilters": "Remove Filter(s) From Experiments Table",
"command.removeExperimentsTableSorts": "Remove Sort(s) From Experiments Table",
"command.removeTarget": "Remove",
Expand Down
18 changes: 18 additions & 0 deletions extension/src/cli/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,24 @@ describe('CliExecutor', () => {
})
})

describe('experimentRemoveQueue', () => {
it('should call createProcess with the correct parameters to remove all existing queued experiments from the workspace', async () => {
const cwd = __dirname
const stdout = ''
mockedCreateProcess.mockReturnValueOnce(getMockedProcess(stdout))

const output = await cliExecutor.experimentRemoveQueue(cwd)
expect(output).toStrictEqual(stdout)

expect(mockedCreateProcess).toBeCalledWith({
args: ['exp', 'remove', '--queue'],
cwd,
env: mockedEnv,
executable: 'dvc'
})
})
})

describe('experimentRunQueue', () => {
it('should call createProcess with the correct parameters to queue an experiment for later execution', async () => {
const cwd = __dirname
Expand Down
5 changes: 5 additions & 0 deletions extension/src/cli/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const autoRegisteredCommands = {
EXPERIMENT_GARBAGE_COLLECT: 'experimentGarbageCollect',
EXPERIMENT_QUEUE: 'experimentRunQueue',
EXPERIMENT_REMOVE: 'experimentRemove',
EXPERIMENT_REMOVE_QUEUE: 'experimentRemoveQueue',
INIT: 'init',
MOVE: 'move',
PULL: 'pull',
Expand Down Expand Up @@ -83,6 +84,10 @@ export class CliExecutor extends Cli {
)
}

public experimentRemoveQueue(cwd: string) {
return this.experimentRemove(cwd, ExperimentFlag.QUEUE)
}

public experimentRunQueue(cwd: string, ...args: Args) {
return this.executeExperimentProcess(
cwd,
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 @@ -3,6 +3,7 @@ export enum RegisteredCliCommands {
EXPERIMENT_BRANCH = 'dvc.branchExperiment',
EXPERIMENT_GARBAGE_COLLECT = 'dvc.experimentGarbageCollect',
EXPERIMENT_REMOVE = 'dvc.removeExperiment',
EXPERIMENT_REMOVE_QUEUE = 'dvc.removeExperimentQueue',
EXPERIMENT_RUN = 'dvc.runExperiment',
EXPERIMENT_RUN_QUEUED = 'dvc.runQueuedExperiments',
EXPERIMENT_RUN_RESET = 'dvc.runResetExperiment',
Expand Down
6 changes: 6 additions & 0 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const registerExperimentCwdCommands = (
experiments.queueExperimentFromExisting()
)
)

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

const registerExperimentNameCommands = (
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 @@ -81,6 +81,7 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_GARBAGE_COLLECT]: undefined
[EventName.EXPERIMENT_METRICS_AND_PARAMS_TOGGLE]: undefined
[EventName.EXPERIMENT_REMOVE]: undefined
[EventName.EXPERIMENT_REMOVE_QUEUE]: undefined
[EventName.EXPERIMENT_RUN]: undefined
[EventName.EXPERIMENT_RUN_QUEUED]: undefined
[EventName.EXPERIMENT_RUN_RESET]: undefined
Expand Down
30 changes: 30 additions & 0 deletions extension/src/test/suite/experiments/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,34 @@ suite('Workspace Experiments Test Suite', () => {
expect(mockExperimentRemove).to.be.calledWith(dvcDemoPath, mockExperiment)
})
})

describe('dvc.removeExperimentQueue', () => {
it('should remove all queued experiments from the selected repository', async () => {
const { experiments } = buildExperiments(disposable)

await experiments.isReady()

stub(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(WorkspaceExperiments as any).prototype,
'getOnlyOrPickProject'
).returns(dvcDemoPath)
stub(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(WorkspaceExperiments as any).prototype,
'getRepository'
).returns(experiments)

const mockExperimentRemove = stub(
CliExecutor.prototype,
'experimentRemove'
)

await commands.executeCommand(
RegisteredCliCommands.EXPERIMENT_REMOVE_QUEUE
)

expect(mockExperimentRemove).to.be.calledWith(dvcDemoPath, '--queue')
})
})
})