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

Remove queue from csv command #1276

Merged
merged 1 commit into from
Feb 1, 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: 0 additions & 4 deletions demo/queue.csv

This file was deleted.

14 changes: 0 additions & 14 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,6 @@
"category": "DVC",
"icon": "$(cloud-upload)"
},
{
"title": "%command.queueExperimentsFromCsv%",
"command": "dvc.queueExperimentsFromCsv",
"category": "DVC",
"icon": {
"dark": "resources/dark/queue-experiment.svg",
"light": "resources/light/queue-experiment.svg"
}
},
{
"title": "%command.queueExperimentFromExisting%",
"command": "dvc.queueExperimentFromExisting",
Expand Down Expand Up @@ -486,10 +477,6 @@
"command": "dvc.pushTarget",
"when": "false"
},
{
"command": "dvc.queueExperimentsFromCsv",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.queueExperimentFromExisting",
"when": "dvc.commands.available && dvc.project.available"
Expand Down Expand Up @@ -1074,7 +1061,6 @@
"dependencies": {
"@hediet/std": "^0.6.0",
"chokidar": "^3.5.2",
"csv-parse": "^5.0.3",
"execa": "^5.1.1",
"fs-extra": "^10.0.0",
"lodash.clonedeep": "^4.5.0",
Expand Down
1 change: 0 additions & 1 deletion extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"command.pullTarget": "Pull",
"command.push": "Push",
"command.pushTarget": "Push",
"command.queueExperimentsFromCsv": "Queue Experiments From CSV",
"command.queueExperimentFromExisting": "Queue Experiment From Existing",
"command.queueExperiment": "Queue Experiment",
"command.removeExperiment": "Remove Experiment",
Expand Down
1 change: 0 additions & 1 deletion extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export enum RegisteredCommands {
EXPERIMENT_SORTS_REMOVE = 'dvc.removeExperimentsTableSorts',
EXPERIMENT_SORTS_REMOVE_ALL = 'dvc.views.experimentsSortByTree.removeAllSorts',
EXPERIMENT_TOGGLE = 'dvc.views.experimentsTree.toggleStatus',
QUEUE_EXPERIMENTS_FROM_CSV = 'dvc.queueExperimentsFromCsv',
QUEUE_EXPERIMENT_FROM_EXISTING = 'dvc.queueExperimentFromExisting',
STOP_EXPERIMENT = 'dvc.stopRunningExperiment',

Expand Down
8 changes: 0 additions & 8 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ const registerExperimentCwdCommands = (
)
)

internalCommands.registerExternalCommand(
RegisteredCommands.QUEUE_EXPERIMENTS_FROM_CSV,
() =>
experiments.pauseUpdatesThenRun(() =>
experiments.queueExperimentsFromCsv()
)
)

internalCommands.registerExternalCommand(
RegisteredCommands.QUEUE_EXPERIMENT_FROM_EXISTING,
() =>
Expand Down
32 changes: 0 additions & 32 deletions extension/src/experiments/model/queue/index.ts

This file was deleted.

28 changes: 0 additions & 28 deletions extension/src/experiments/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { EventEmitter, Memento } from 'vscode'
import { Experiments } from '.'
import { readToQueueFromCsv } from './model/queue'
import { TableData } from './webview/contract'
import {
CommandId,
Expand All @@ -12,7 +11,6 @@ import { reportOutput } from '../vscode/reporting'
import { getInput } from '../vscode/inputBox'
import { BaseWorkspaceWebviews } from '../webview/workspace'
import { WorkspacePlots } from '../plots/workspace'
import { pickCsv } from '../vscode/resourcePicker'

export class WorkspaceExperiments extends BaseWorkspaceWebviews<
Experiments,
Expand Down Expand Up @@ -103,32 +101,6 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
return this.getRepository(dvcRoot).autoApplyFilters(enable)
}

public async queueExperimentsFromCsv() {
const cwd = await this.getFocusedOrOnlyOrPickProject()
if (!cwd) {
return
}
const repository = this.getRepository(cwd)

const csv = await pickCsv('Select a CSV to queue experiments from')
if (!csv) {
return
}

const toQueue = await readToQueueFromCsv(csv)

for (const params of toQueue) {
await repository.forceUpdate()
await reportOutput(
this.internalCommands.executeCommand(
AvailableCommands.EXPERIMENT_QUEUE,
cwd,
...params
)
)
}
}

public async queueExperimentFromExisting() {
const cwd = await this.getFocusedOrOnlyOrPickProject()
if (!cwd) {
Expand Down
12 changes: 1 addition & 11 deletions extension/src/fileSystem/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { basename, extname, join, relative, resolve } from 'path'
import {
createReadStream,
existsSync,
lstatSync,
readdir,
removeSync
} from 'fs-extra'
import { existsSync, lstatSync, readdir, removeSync } from 'fs-extra'
import { Uri } from 'vscode'
import { parse, Parser } from 'csv-parse'
import { definedAndNonEmpty } from '../util/array'

export const exists = (path: string): boolean => existsSync(path)
Expand Down Expand Up @@ -72,7 +65,4 @@ export const isAnyDvcYaml = (path?: string): boolean =>
export const relativeWithUri = (dvcRoot: string, uri: Uri) =>
relative(dvcRoot, uri.fsPath)

export const readCsv = (path: string): Parser =>
createReadStream(path).pipe(parse({ columns: true, delimiter: ',' }))

export const removeDir = (path: string): void => removeSync(path)
1 change: 0 additions & 1 deletion extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_SORTS_REMOVE_ALL]: undefined
[EventName.EXPERIMENT_TOGGLE]: undefined
[EventName.QUEUE_EXPERIMENT]: undefined
[EventName.QUEUE_EXPERIMENTS_FROM_CSV]: undefined
[EventName.QUEUE_EXPERIMENT_FROM_EXISTING]: undefined
[EventName.STOP_EXPERIMENT]: { stopped: boolean; wasRunning: boolean }

Expand Down
54 changes: 1 addition & 53 deletions extension/src/test/suite/experiments/workspace.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, it, suite } from 'mocha'
import { expect } from 'chai'
import { stub, restore, SinonStub } from 'sinon'
import { window, commands, QuickPickItem, Uri, QuickPickOptions } from 'vscode'
import { window, commands, QuickPickItem, QuickPickOptions } from 'vscode'
import {
buildExperiments,
buildMultiRepoExperiments,
Expand All @@ -20,7 +20,6 @@ import {
} from '../../../commands/external'
import * as Telemetry from '../../../telemetry'
import { CliRunner } from '../../../cli/runner'
import { join } from '../../util/path'
import { Param } from '../../../experiments/model/queue/collect'
import { QuickPickItemWithValue } from '../../../vscode/quickPick'

Expand Down Expand Up @@ -89,57 +88,6 @@ suite('Workspace Experiments Test Suite', () => {
})
}).timeout(8000)

describe('dvc.queueExperimentsFromCsv', () => {
it('should be able to queue multiple experiments from a csv', async () => {
const mockExperimentRunQueue = stub(
CliExecutor.prototype,
'experimentRunQueue'
).resolves('true')

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

const mockForceUpdate = stub()

stub(WorkspaceExperiments.prototype, 'getRepository').returns({
forceUpdate: mockForceUpdate
} as unknown as Experiments)

const mockUri = Uri.file(join(dvcDemoPath, 'queue.csv'))

stub(window, 'showOpenDialog').resolves([mockUri])

await commands.executeCommand(
RegisteredCommands.QUEUE_EXPERIMENTS_FROM_CSV
)

expect(mockForceUpdate).to.be.calledThrice
expect(mockExperimentRunQueue).to.be.calledThrice
expect(mockExperimentRunQueue).to.be.calledWith(
dvcDemoPath,
'-S',
'lr=0.0001',
'-S',
'weight_decay=0.02'
)
expect(mockExperimentRunQueue).to.be.calledWith(
dvcDemoPath,
'-S',
'lr=0.00075',
'-S',
'weight_decay=0.01'
)
expect(mockExperimentRunQueue).to.be.calledWith(
dvcDemoPath,
'-S',
'lr=0.0005'
)
})
})

describe('dvc.queueExperimentsFromExisting', () => {
it('should be able to queue an experiment using an existing one as a base', async () => {
const { experiments } = buildExperiments(disposable)
Expand Down
15 changes: 0 additions & 15 deletions extension/src/vscode/resourcePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@ export const pickFile = async (title: string): Promise<string | undefined> => {
}
}

export const pickCsv = async (title: string): Promise<string | undefined> => {
const uris = await window.showOpenDialog({
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: false,
filters: { CSV: ['csv'] },
title
})

if (uris) {
const [{ fsPath }] = uris
return fsPath
}
}

export const pickResources = (title: string): Thenable<Uri[] | undefined> => {
return window.showOpenDialog({
canSelectFiles: true,
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6383,11 +6383,6 @@ csstype@^3.0.2:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.9.tgz#6410af31b26bd0520933d02cbc64fce9ce3fbf0b"
integrity sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==

csv-parse@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.0.3.tgz#eeb0b1ac8bf2970f703176c8f54d313325b6d2e8"
integrity sha512-86R0WU4aEEF/1fPZKxP3NmDAYC4Ce1t9iFgKPZogG5Lvk4m9WZQkCEsDANktG29jppejwclTtEOzubN2ieCJqw==

cyclist@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
Expand Down