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

Do not drop experiment selection when an experiment is running and exp show errors #4042

Merged
merged 2 commits into from
Jun 6, 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
119 changes: 118 additions & 1 deletion extension/src/experiments/model/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { join } from 'path'
import { commands } from 'vscode'
import { ExperimentsModel } from '.'
import { copyOriginalColors } from './status/colors'
import gitLogFixture from '../../test/fixtures/expShow/base/gitLog'
import rowOrderFixture from '../../test/fixtures/expShow/base/rowOrder'
import outputFixture from '../../test/fixtures/expShow/base/output'
Expand All @@ -20,7 +21,9 @@ import survivalRowsFixture from '../../test/fixtures/expShow/survival/rows'
import {
ExperimentStatus,
EXPERIMENT_WORKSPACE_ID,
Executor
Executor,
ExpWithError,
ExpShowOutput
} from '../../cli/dvc/contract'
import { PersistenceKey } from '../../persistence/constants'

Expand All @@ -40,6 +43,8 @@ const DEFAULT_DATA: [
{ [branch: string]: number }
] = ['', false, [], { main: 2000 }]

type TransformAndSetInputs = [ExpShowOutput, ...typeof DEFAULT_DATA]

describe('ExperimentsModel', () => {
it('should return the expected rows when given the base fixture', () => {
const model = new ExperimentsModel('', buildMockMemento())
Expand Down Expand Up @@ -405,4 +410,116 @@ describe('ExperimentsModel', () => {
'C'
])
})

const getSelectedRevisions = (
model: ExperimentsModel
): { id: string; displayColor: string }[] =>
model
.getSelectedRevisions()
.map(({ displayColor, id }) => ({ displayColor, id }))

it('should not update the status of experiments if exp show fails and there was a running experiment', () => {
const memento = buildMockMemento()
const model = new ExperimentsModel('', memento)
const colorList = copyOriginalColors()
const expectedSelection = [
{ id: 'exp-83425', displayColor: colorList[0] },
{ id: 'exp-e7a67', displayColor: colorList[1] },
{ id: EXPERIMENT_WORKSPACE_ID, displayColor: colorList[2] }
]

const runningExperimentData: TransformAndSetInputs = [
outputFixture,
gitLogFixture,
false,
[],
{
main: 2000
}
]

const transientErrorData: TransformAndSetInputs = [
[
{
rev: EXPERIMENT_WORKSPACE_ID,
error: {
type: 'caught error',
msg:
'unexpected error - [Errno 2]' +
"No such file or directory: '.dvc/tmp/exps/run/ee47660cc5723ec201b88aa0fb8002e47508ee65/ee47660cc5723ec201b88aa0fb8002e47508ee65.run'" +
'Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!'
}
} as ExpWithError
],
gitLogFixture,
false,
[],
{
main: 2000
}
]

model.transformAndSet(...runningExperimentData)

model.toggleStatus('exp-e7a67')
model.toggleStatus(EXPERIMENT_WORKSPACE_ID)

expect(getSelectedRevisions(model)).toStrictEqual(expectedSelection)
expect(model.hasRunningExperiment()).toBe(true)

model.transformAndSet(...transientErrorData)

expect(getSelectedRevisions(model)).toStrictEqual(
expectedSelection.slice(2)
)
expect(model.hasRunningExperiment()).toBe(true)

model.transformAndSet(...runningExperimentData)

expect(getSelectedRevisions(model)).toStrictEqual(expectedSelection)
expect(model.hasRunningExperiment()).toBe(true)
})

it('should update the status of experiments if exp show fails and there was not a running experiment', () => {
const memento = buildMockMemento()
const model = new ExperimentsModel('', memento)
const colorList = copyOriginalColors()

const noRunningExperimentData: TransformAndSetInputs = [
survivalOutputFixture,
...DEFAULT_DATA
]

const unexpectedErrorData: TransformAndSetInputs = [
[
{
rev: EXPERIMENT_WORKSPACE_ID,
error: {
type: 'caught error',
msg: 'unexpected - error'
}
} as ExpWithError
],
...DEFAULT_DATA
]

model.transformAndSet(...noRunningExperimentData)

model.toggleStatus('main')

expect(getSelectedRevisions(model)).toStrictEqual([
{ id: 'main', displayColor: colorList[0] }
])
expect(model.hasRunningExperiment()).toBe(false)

model.transformAndSet(...unexpectedErrorData)

expect(getSelectedRevisions(model)).toStrictEqual([])
expect(model.hasRunningExperiment()).toBe(false)

model.transformAndSet(...noRunningExperimentData)

expect(getSelectedRevisions(model)).toStrictEqual([])
expect(model.hasRunningExperiment()).toBe(false)
})
})
4 changes: 4 additions & 0 deletions extension/src/experiments/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export class ExperimentsModel extends ModelWithPersistence {
this.experimentsByCommit = experimentsByCommit
this.checkpoints = hasCheckpoints

const isTransientError = this.hasRunningExperiment() && workspace.error
if (isTransientError) {
return
}
this.setColoredStatus(runningExperiments)
}

Expand Down