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

Combine remove experiments and remove queued experiment quick picks #3166

Merged
merged 1 commit into from
Jan 27, 2023
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
13 changes: 2 additions & 11 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
},
{
"title": "%command.removeExperiments%",
"command": "dvc.removeExperiment",
"command": "dvc.removeExperiments",
"category": "DVC"
},
{
Expand All @@ -307,11 +307,6 @@
"category": "DVC",
"icon": "$(close-all)"
},
{
"title": "%command.removeQueuedExperiment%",
"command": "dvc.removeQueuedExperiment",
"category": "DVC"
},
{
"title": "%command.removeTarget%",
"command": "dvc.removeTarget",
Expand Down Expand Up @@ -740,7 +735,7 @@
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
},
{
"command": "dvc.removeExperiment",
"command": "dvc.removeExperiments",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
},
{
Expand All @@ -755,10 +750,6 @@
"command": "dvc.removeExperimentsTableSorts",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.removeQueuedExperiment",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
},
{
"command": "dvc.removeTarget",
"when": "false"
Expand Down
3 changes: 1 addition & 2 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@
"command.modifyExperimentParamsAndResume": "Modify Experiment Param(s) and Resume",
"command.modifyExperimentParamsResetAndRun": "Modify Experiment Param(s) and Run",
"command.queueExperiment": "Queue Experiment",
"command.removeExperiments": "Remove Experiments",
"command.removeExperiments": "Remove Experiment(s)",
"command.removeExperimentQueue": "Remove All Queued Experiments",
"command.removeExperimentsTableFilters": "Remove Filter(s) From Experiments Table",
"command.removeExperimentsTableSorts": "Remove Sort(s) From Experiments Table",
"command.removeQueuedExperiment": "Remove Queued Experiment",
"command.removeTarget": "Remove",
"command.renameTarget": "Rename",
"command.runExperiment": "Run Experiment",
Expand Down
3 changes: 1 addition & 2 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ export enum RegisteredCliCommands {
EXPERIMENT_APPLY = 'dvc.applyExperiment',
EXPERIMENT_BRANCH = 'dvc.branchExperiment',
EXPERIMENT_GARBAGE_COLLECT = 'dvc.experimentGarbageCollect',
EXPERIMENT_REMOVE = 'dvc.removeExperiment',
EXPERIMENT_REMOVE = 'dvc.removeExperiments',
EXPERIMENT_REMOVE_QUEUE = 'dvc.removeExperimentQueue',
EXPERIMENT_REMOVE_QUEUED = 'dvc.removeQueuedExperiment',
EXPERIMENT_RESET_AND_RUN = 'dvc.resetAndRunCheckpointExperiment',
EXPERIMENT_RESUME = 'dvc.resumeCheckpointExperiment',
EXPERIMENT_RUN = 'dvc.runExperiment',
Expand Down
5 changes: 0 additions & 5 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ const registerExperimentNameCommands = (
...ids
)
)

internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_REMOVE_QUEUED,
() => experiments.getQueuedExpThenRun(AvailableCommands.EXPERIMENT_REMOVE)
)
}

const registerExperimentInputCommands = (
Expand Down
11 changes: 2 additions & 9 deletions extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,7 @@ export class Experiments extends BaseRepository<TableData> {

public pickCurrentExperiment() {
return pickExperiment(
this.experiments.getCurrentExperiments(),
this.getFirstThreeColumnOrder()
)
}

public pickQueuedExperiment() {
return pickExperiment(
this.experiments.getQueuedExperiments(),
this.experiments.getExperimentsWithoutQueued(),
this.getFirstThreeColumnOrder()
)
}
Expand All @@ -409,7 +402,7 @@ export class Experiments extends BaseRepository<TableData> {

public pickExperimentsToRemove() {
return pickExperiments(
this.experiments.getCurrentExperiments(),
this.experiments.getExperimentsWithQueued(),
this.getFirstThreeColumnOrder(),
Title.SELECT_EXPERIMENTS_REMOVE
)
Expand Down
45 changes: 17 additions & 28 deletions extension/src/experiments/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class ExperimentsModel extends ModelWithPersistence {
public toggleStatus(id: string) {
if (
isQueued(
this.getFlattenedExperiments().find(
this.getExperimentsWithQueued().find(
({ id: queuedId }) => queuedId === id
)?.status
)
Expand Down Expand Up @@ -185,7 +185,7 @@ export class ExperimentsModel extends ModelWithPersistence {
}

public setRevisionCollected(revisions: string[]) {
for (const { id } of this.getFlattenedExperiments().filter(({ label }) =>
for (const { id } of this.getExperimentsWithQueued().filter(({ label }) =>
revisions.includes(label)
)) {
if (this.finishedRunning[id]) {
Expand Down Expand Up @@ -281,7 +281,7 @@ export class ExperimentsModel extends ModelWithPersistence {
}

public getSelectedExperiments() {
return this.getSelectedFromList(() => this.getFlattenedExperiments())
return this.getSelectedFromList(() => this.getExperimentsWithQueued())
}

public setSelected(selectedExperiments: Experiment[]) {
Expand Down Expand Up @@ -348,7 +348,7 @@ export class ExperimentsModel extends ModelWithPersistence {
}

public getAllExperiments() {
return [...this.getExperiments(), ...this.getFlattenedExperiments()]
return [...this.getExperiments(), ...this.getExperimentsWithQueued()]
}

public getErrors() {
Expand Down Expand Up @@ -385,16 +385,20 @@ export class ExperimentsModel extends ModelWithPersistence {
return collectFlatExperimentParams(params)
}

public getCurrentExperiments() {
return this.splitExperimentsByQueued()
public getExperimentsWithoutQueued() {
return this.getExperimentsWithQueued().filter(({ status }) => {
return !isQueued(status)
})
}

public getQueuedExperiments() {
return this.splitExperimentsByQueued(true)
public getExperimentsWithQueued() {
return flattenMapValues(this.experimentsByBranch).map(experiment =>
this.addDetails(experiment)
)
}

public getRunningQueueTasks() {
return this.getFlattenedExperiments().filter(
return this.getExperimentsWithQueued().filter(
({ status, executor }) => isRunning(status) && executor === 'dvc-task'
)
}
Expand Down Expand Up @@ -438,7 +442,7 @@ export class ExperimentsModel extends ModelWithPersistence {
public getExperimentCount() {
return sum([
this.getFlattenedCheckpoints().length,
this.getFlattenedExperiments().length,
this.getExperimentsWithQueued().length,
this.branches.length,
1
])
Expand All @@ -453,7 +457,7 @@ export class ExperimentsModel extends ModelWithPersistence {
return [
this.workspace,
...this.branches,
...this.getFlattenedExperiments(),
...this.getExperimentsWithQueued(),
...this.getFlattenedCheckpoints()
]
}
Expand Down Expand Up @@ -505,7 +509,7 @@ export class ExperimentsModel extends ModelWithPersistence {
private getFilteredExperiments() {
const acc: ExperimentWithType[] = []

for (const experiment of this.getCurrentExperiments()) {
for (const experiment of this.getExperimentsWithoutQueued()) {
const checkpoints = this.getCheckpointsWithType(experiment.id) || []
collectFiltered(acc, this.getFilters(), experiment, checkpoints)
}
Expand Down Expand Up @@ -541,21 +545,6 @@ export class ExperimentsModel extends ModelWithPersistence {
return sortExperiments(this.getSorts(), experiments)
}

private getFlattenedExperiments() {
return flattenMapValues(this.experimentsByBranch).map(experiment =>
this.addDetails(experiment)
)
}

private splitExperimentsByQueued(getQueued = false) {
return this.getFlattenedExperiments().filter(({ status }) => {
if (getQueued) {
return isQueued(status)
}
return !isQueued(status)
})
}

private getFlattenedCheckpoints() {
return flattenMapValues(this.checkpointsByTip).map(checkpoint =>
this.addDetails(checkpoint)
Expand Down Expand Up @@ -593,7 +582,7 @@ export class ExperimentsModel extends ModelWithPersistence {

this.finishedRunning = collectFinishedRunningExperiments(
{ ...this.finishedRunning },
this.getFlattenedExperiments(),
this.getExperimentsWithQueued(),
this.running,
stillRunning,
this.coloredStatus
Expand Down
6 changes: 0 additions & 6 deletions extension/src/experiments/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,6 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
)
}

public getQueuedExpThenRun(commandId: CommandId) {
return this.pickExpThenRun(commandId, cwd =>
this.getRepository(cwd).pickQueuedExperiment()
)
}

public async getCwdAndQuickPickThenRun(
commandId: CommandId,
quickPick: () => Thenable<string[] | undefined>
Expand Down
1 change: 0 additions & 1 deletion extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_METRICS_AND_PARAMS_TOGGLE]: undefined
[EventName.EXPERIMENT_REMOVE]: undefined
[EventName.EXPERIMENT_REMOVE_QUEUE]: undefined
[EventName.EXPERIMENT_REMOVE_QUEUED]: undefined
[EventName.EXPERIMENT_RESUME]: undefined
[EventName.EXPERIMENT_RUN]: undefined
[EventName.EXPERIMENT_RESET_AND_RUN]: undefined
Expand Down
41 changes: 13 additions & 28 deletions extension/src/test/suite/experiments/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ suite('Workspace Experiments Test Suite', () => {
})
})

describe('dvc.removeExperiment', () => {
it('should ask the user to pick experiment(s) and then remove selected experiments from the workspace', async () => {
describe('dvc.removeExperiments', () => {
it('should ask the user to pick experiment(s) and then remove selected ones from the workspace', async () => {
const mockExperiment = 'exp-e7a67'
const secondMockExperiment = 'exp-83425'
type QuickPickReturnValue = QuickPickItemWithValue<{
Expand Down Expand Up @@ -867,6 +867,17 @@ suite('Workspace Experiments Test Suite', () => {
label: 'f0f9186',
value: { id: 'exp-f13bca', name: 'exp-f13bca' }
},
{
description: undefined,
detail: `Created:${formatDate(
'2020-12-29T15:25:27'
)}, loss:-, accuracy:-`,
label: '90aea7f',
value: {
id: '90aea7f2482117a55dfcadcdb901aaa6610fbbc9',
name: '90aea7f'
}
},
{
description: undefined,
detail: `Created:${formatDate(
Expand Down Expand Up @@ -918,30 +929,4 @@ suite('Workspace Experiments Test Suite', () => {
expect(mockExperimentRemove).to.be.calledWith(dvcDemoPath, '--queue')
})
})

describe('dvc.removeQueuedExperiment', () => {
it('should ask the user to pick a queued experiment and then remove that experiment from the workspace', async () => {
const mockExperiment = 'queued-exp-to-remove'

const { experiments } = buildExperiments(disposable)

await experiments.isReady()

stubWorkspaceExperimentsGetters(dvcDemoPath, experiments)

stub(window, 'showQuickPick').resolves({
value: { id: mockExperiment, name: mockExperiment }
} as QuickPickItemWithValue<{ id: string; name: string }>)
const mockExperimentRemove = stub(
DvcExecutor.prototype,
'experimentRemove'
)

await commands.executeCommand(
RegisteredCliCommands.EXPERIMENT_REMOVE_QUEUED
)

expect(mockExperimentRemove).to.be.calledWith(dvcDemoPath, mockExperiment)
})
})
})