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

Enable experiment operations when experiment(s) are running in the queue #3832

Merged
merged 7 commits into from
May 8, 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
111 changes: 58 additions & 53 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,11 @@
},
{
"command": "dvc.applyExperiment",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] We only want to suppress actions when there is an experiment running in the workspace.

},
{
"command": "dvc.branchExperiment",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.checkout",
Expand Down Expand Up @@ -708,7 +708,7 @@
},
{
"command": "dvc.experimentGarbageCollect",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.findInFolder",
Expand Down Expand Up @@ -752,35 +752,35 @@
},
{
"command": "dvc.modifyExperimentParamsAndQueue",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.modifyExperimentParamsAndRun",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running && !dvc.experiment.checkpoints"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace && !dvc.experiment.checkpoints"
},
{
"command": "dvc.modifyExperimentParamsAndResume",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running && dvc.experiment.checkpoints"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace && dvc.experiment.checkpoints"
},
{
"command": "dvc.modifyExperimentParamsResetAndRun",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running && dvc.experiment.checkpoints"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace && dvc.experiment.checkpoints"
},
{
"command": "dvc.pushExperiments",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.queueExperiment",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.removeExperiments",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.removeExperimentQueue",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.removeExperimentsTableFilters",
Expand Down Expand Up @@ -808,15 +808,15 @@
},
{
"command": "dvc.runExperiment",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running && !dvc.experiment.checkpoints"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace && !dvc.experiment.checkpoints"
},
{
"command": "dvc.resumeCheckpointExperiment",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running && dvc.experiment.checkpoints"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace && dvc.experiment.checkpoints"
},
{
"command": "dvc.resetAndRunCheckpointExperiment",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running && dvc.experiment.checkpoints"
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace && dvc.experiment.checkpoints"
},
{
"command": "dvc.startExperimentsQueue",
Expand Down Expand Up @@ -1029,59 +1029,64 @@
],
"editor/title": [
{
"command": "dvc.runExperiment",
"command": "dvc.stopAllRunningExperiments",
"group": "navigation@0",
"when": "dvc.params.file.active && !dvc.experiment.running && dvc.commands.available && !dvc.experiment.checkpoints"
"when": "dvc.params.file.active && dvc.experiment.running && dvc.commands.available"
},
{
"command": "dvc.runExperiment",
"command": "dvc.stopAllRunningExperiments",
"group": "navigation@0",
"when": "dvc.experiments.webview.active && !dvc.experiment.running && dvc.commands.available && !dvc.experiment.checkpoints"
"when": "dvc.experiments.webview.active && dvc.experiment.running && dvc.commands.available"
},
{
"command": "dvc.stopAllRunningExperiments",
"group": "navigation@0",
"when": "dvc.experiment.running && dvc.commands.available"
"command": "dvc.runExperiment",
"group": "navigation@1",
"when": "dvc.params.file.active && !dvc.experiment.running.workspace && dvc.commands.available && !dvc.experiment.checkpoints"
},
{
"command": "dvc.resetAndRunCheckpointExperiment",
"command": "dvc.runExperiment",
"group": "navigation@1",
"when": "dvc.experiments.webview.active && !dvc.experiment.running && dvc.commands.available && dvc.experiment.checkpoints"
"when": "dvc.experiments.webview.active && !dvc.experiment.running.workspace && dvc.commands.available && !dvc.experiment.checkpoints"
},
{
"command": "dvc.resetAndRunCheckpointExperiment",
"group": "navigation@1",
"when": "dvc.params.file.active && !dvc.experiment.running && dvc.commands.available && dvc.experiment.checkpoints"
"group": "navigation@2",
"when": "dvc.experiments.webview.active && !dvc.experiment.running.workspace && dvc.commands.available && dvc.experiment.checkpoints"
},
{
"command": "dvc.resumeCheckpointExperiment",
"command": "dvc.resetAndRunCheckpointExperiment",
"group": "navigation@2",
"when": "dvc.experiments.webview.active && !dvc.experiment.running && dvc.commands.available && dvc.experiment.checkpoints"
"when": "dvc.params.file.active && !dvc.experiment.running.workspace && dvc.commands.available && dvc.experiment.checkpoints"
},
{
"command": "dvc.resumeCheckpointExperiment",
"group": "navigation@2",
"when": "dvc.params.file.active && !dvc.experiment.running && dvc.commands.available && dvc.experiment.checkpoints"
"group": "navigation@3",
"when": "dvc.experiments.webview.active && !dvc.experiment.running.workspace && dvc.commands.available && dvc.experiment.checkpoints"
},
{
"command": "dvc.startExperimentsQueue",
"command": "dvc.resumeCheckpointExperiment",
"group": "navigation@3",
"when": "dvc.experiments.webview.active && !dvc.experiment.running && dvc.commands.available"
"when": "dvc.params.file.active && !dvc.experiment.running.workspace && dvc.commands.available && dvc.experiment.checkpoints"
},
{
"command": "dvc.startExperimentsQueue",
"group": "navigation@3",
"when": "dvc.params.file.active && !dvc.experiment.running && dvc.commands.available"
"group": "navigation@4",
"when": "dvc.experiments.webview.active && dvc.commands.available"
},
{
"command": "dvc.queueExperiment",
"command": "dvc.startExperimentsQueue",
"group": "navigation@4",
"when": "dvc.experiments.webview.active && !dvc.experiment.running && dvc.commands.available"
"when": "dvc.params.file.active && dvc.commands.available"
},
{
"command": "dvc.queueExperiment",
"group": "navigation@4",
"when": "dvc.params.file.active && !dvc.experiment.running && dvc.commands.available"
"group": "navigation@5",
"when": "dvc.experiments.webview.active && !dvc.experiment.running.workspace && dvc.commands.available"
},
{
"command": "dvc.queueExperiment",
"group": "navigation@5",
"when": "dvc.params.file.active && !dvc.experiment.running.workspace && dvc.commands.available"
}
],
"view/item/context": [
Expand Down Expand Up @@ -1158,42 +1163,42 @@
{
"command": "dvc.views.experiments.applyExperiment",
"group": "inline@1",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running.workspace"
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] viewItem == experiment means none of these actions will be available for running experiments.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to add stop inline as a follow up

},
{
"command": "dvc.views.experiments.branchExperiment",
"group": "inline@2",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running.workspace"
},
{
"command": "dvc.views.experimentsTree.removeExperiment",
"group": "inline@3",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(experiment|queued)$/ && !dvc.experiment.running"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(experiment|queued)$/ && !dvc.experiment.running.workspace"
},
{
"command": "dvc.views.experimentsTree.pushExperiment",
"group": "1_share@0",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running.workspace"
},
{
"command": "dvc.views.experiments.runExperiment",
"group": "2_modify@1",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running && !dvc.experiment.checkpoints"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running.workspace && !dvc.experiment.checkpoints"
},
{
"command": "dvc.views.experiments.resetAndRunCheckpointExperiment",
"group": "2_modify@1",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running && dvc.experiment.checkpoints"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running.workspace && dvc.experiment.checkpoints"
},
{
"command": "dvc.views.experiments.resumeCheckpointExperiment",
"group": "2_modify@2",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running && dvc.experiment.checkpoints"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running.workspace && dvc.experiment.checkpoints"
},
{
"command": "dvc.views.experiments.queueExperiment",
"group": "2_modify@3",
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running"
"when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem =~ /^(workspace|commit|experiment|queued)$/ && !dvc.experiment.running.workspace"
}
],
"view/title": [
Expand All @@ -1214,17 +1219,17 @@
},
{
"command": "dvc.runExperiment",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running && !dvc.experiment.checkpoints",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace && !dvc.experiment.checkpoints",
"group": "navigation@1"
},
{
"command": "dvc.resetAndRunCheckpointExperiment",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running && dvc.experiment.checkpoints",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace && dvc.experiment.checkpoints",
"group": "navigation@1"
},
{
"command": "dvc.resumeCheckpointExperiment",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running && dvc.experiment.checkpoints",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace && dvc.experiment.checkpoints",
"group": "navigation@2"
},
{
Expand All @@ -1249,27 +1254,27 @@
},
{
"command": "dvc.modifyExperimentParamsAndRun",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running && !dvc.experiment.checkpoints",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace && !dvc.experiment.checkpoints",
"group": "2_modify@1"
},
{
"command": "dvc.modifyExperimentParamsAndResume",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running && dvc.experiment.checkpoints",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace && dvc.experiment.checkpoints",
"group": "2_modify@1"
},
{
"command": "dvc.modifyExperimentParamsResetAndRun",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running && dvc.experiment.checkpoints",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace && dvc.experiment.checkpoints",
"group": "2_modify@2"
},
{
"command": "dvc.modifyExperimentParamsAndQueue",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace",
"group": "2_modify@3"
},
{
"command": "dvc.queueExperiment",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running",
"when": "view == dvc.views.experimentsTree && !dvc.experiment.running.workspace",
"group": "3_queue@1"
},
{
Expand Down
16 changes: 14 additions & 2 deletions extension/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,22 @@ export class Context extends Disposable {
}

private setIsExperimentRunning(repositories: Experiments[] = []) {
const workspaceRunningInRunner = this.dvcRunner.isExperimentRunning()

const getContextValue = (
method: 'hasRunningWorkspaceExperiment' | 'hasRunningExperiment'
): boolean =>
workspaceRunningInRunner ||
repositories.some(experiments => experiments[method]())

void setContextValue(
ContextKey.EXPERIMENT_RUNNING_WORKSPACE,
getContextValue('hasRunningWorkspaceExperiment')
)

void setContextValue(
ContextKey.EXPERIMENT_RUNNING,
this.dvcRunner.isExperimentRunning() ||
repositories.some(experiments => experiments.hasRunningExperiment())
getContextValue('hasRunningExperiment')
)
}
}
6 changes: 5 additions & 1 deletion extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ export class Experiments extends BaseRepository<TableData> {
return this.experiments.hasRunningExperiment()
}

public hasRunningWorkspaceExperiment() {
return this.experiments.hasRunningWorkspaceExperiment()
}

public getFirstThreeColumnOrder() {
return this.columns.getFirstThreeColumnOrder()
}
Expand Down Expand Up @@ -617,7 +621,7 @@ export class Experiments extends BaseRepository<TableData> {
this.dvcLiveOnlyCleanupInitialized = true
void pollSignalFileForProcess(this.dvcLiveOnlySignalFile, () => {
this.dvcLiveOnlyCleanupInitialized = false
if (this.hasRunningExperiment()) {
if (this.hasRunningWorkspaceExperiment()) {
void this.data.update()
}
})
Expand Down
27 changes: 21 additions & 6 deletions extension/src/experiments/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { definedAndNonEmpty, reorderListSubset } from '../../util/array'
import {
EXPERIMENT_WORKSPACE_ID,
Executor,
ExpShowOutput
ExpShowOutput,
ExperimentStatus
} from '../../cli/dvc/contract'
import { flattenMapValues } from '../../util/map'
import { ModelWithPersistence } from '../../persistence/model'
Expand All @@ -39,10 +40,11 @@ export type SelectedExperimentWithColor = Experiment & {
}

export enum ExperimentType {
WORKSPACE = 'workspace',
COMMIT = 'commit',
EXPERIMENT = 'experiment',
QUEUED = 'queued'
RUNNING = 'running',
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] We need this to prevent actions being run from the experimentsTree context menu for running experiments.

QUEUED = 'queued',
WORKSPACE = 'workspace'
}

export class ExperimentsModel extends ModelWithPersistence {
Expand Down Expand Up @@ -166,6 +168,10 @@ export class ExperimentsModel extends ModelWithPersistence {
return this.running.length > 0
}

public hasRunningWorkspaceExperiment() {
return this.running.some(({ executor }) => executor === Executor.WORKSPACE)
}

public hasCheckpoints() {
return this.checkpoints
}
Expand Down Expand Up @@ -372,9 +378,7 @@ export class ExperimentsModel extends ModelWithPersistence {
return this.getExperimentsByCommit(commit)?.map(experiment => ({
...experiment,
hasChildren: false,
type: isQueued(experiment.status)
? ExperimentType.QUEUED
: ExperimentType.EXPERIMENT
type: this.getExperimentType(experiment.status)
}))
}

Expand Down Expand Up @@ -556,6 +560,17 @@ export class ExperimentsModel extends ModelWithPersistence {
}
}

private getExperimentType(status?: ExperimentStatus) {
if (isQueued(status)) {
return ExperimentType.QUEUED
}
if (isRunning(status)) {
return ExperimentType.RUNNING
}

return ExperimentType.EXPERIMENT
}

private getDisplayColor(id: string) {
const color = this.coloredStatus[id]
if (!color) {
Expand Down
Loading