Skip to content

Commit

Permalink
Merge branch 'main' into update-dvc
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon authored Jun 6, 2023
2 parents 140a810 + 82f94f7 commit dd121b1
Show file tree
Hide file tree
Showing 26 changed files with 257 additions and 200 deletions.
4 changes: 2 additions & 2 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@
},
{
"view": "dvc.views.welcome",
"contents": "The extension is currently unable to initialize.\n[Show Setup](command:dvc.showDvcSetup)",
"contents": "The extension is currently unable to initialize.\n[Show Setup](command:dvc.showDvcSetup)\nNew to the extension? Watch a [demo of the extension](https://youtu.be/E26IaD7bNXg?t=1177) in action or quickly try the extension yourself with our [example project](https://github.com/iterative/example-dvc-experiments.git). Dive deeper into DVC at [dvc.org](https://dvc.org/).",
"when": "true"
},
{
Expand Down Expand Up @@ -1651,7 +1651,7 @@
"vscode-languageclient": "8.1.0"
},
"devDependencies": {
"@swc/core": "1.3.60",
"@swc/core": "1.3.61",
"@swc/jest": "0.2.26",
"@types/chai": "4.3.5",
"@types/chai-as-promised": "7.1.5",
Expand Down
3 changes: 0 additions & 3 deletions extension/src/cli/dvc/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export const fileHasError = (file: FileDataOrError): file is DvcError =>

export const DEFAULT_EXP_SHOW_OUTPUT = [
{
branch: undefined,
rev: EXPERIMENT_WORKSPACE_ID
}
]
Expand Down Expand Up @@ -97,13 +96,11 @@ export type ExecutorState = {
export type ExpWithError = {
rev: string
name?: string
branch: string | undefined
} & DvcError

type ExpWithData = {
rev: string
name?: string
branch: string | undefined
data: ExpData
}

Expand Down
5 changes: 1 addition & 4 deletions extension/src/cli/dvc/reader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ describe('CliReader', () => {
const cliOutput = await dvcReader.expShow(cwd)
expect(cliOutput).toStrictEqual([
{
branch: undefined,
error: { msg: unexpectedStderr, type: 'Caught error' },
rev: EXPERIMENT_WORKSPACE_ID
}
Expand All @@ -111,9 +110,7 @@ describe('CliReader', () => {
)

const cliOutput = await dvcReader.expShow(cwd)
expect(cliOutput).toStrictEqual([
{ branch: undefined, rev: EXPERIMENT_WORKSPACE_ID }
])
expect(cliOutput).toStrictEqual([{ rev: EXPERIMENT_WORKSPACE_ID }])
})
})

Expand Down
1 change: 0 additions & 1 deletion extension/src/experiments/columns/collect/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ describe('collectRelativeMetricsFiles', () => {
expect(
collectRelativeMetricsFiles([
{
branch: 'main',
rev: EXPERIMENT_WORKSPACE_ID,
error: { msg: 'I broke', type: 'not important' }
}
Expand Down
4 changes: 1 addition & 3 deletions extension/src/experiments/model/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const collectExpState = (
expState: ExpState,
commitData: { [sha: string]: CommitData }
): Experiment | undefined => {
const { rev, name, branch } = expState
const { rev, name } = expState
const label =
rev === EXPERIMENT_WORKSPACE_ID
? EXPERIMENT_WORKSPACE_ID
Expand All @@ -168,7 +168,6 @@ const collectExpState = (
const description: string | undefined = formatCommitMessage(commit?.message)

const experiment: Experiment = {
branch,
commit,
description,
id,
Expand Down Expand Up @@ -342,7 +341,6 @@ export const collectExperiments = (
hasCheckpoints: hasCheckpoints(expShow),
runningExperiments: [],
workspace: {
branch: undefined,
id: EXPERIMENT_WORKSPACE_ID,
label: EXPERIMENT_WORKSPACE_ID
}
Expand Down
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)
})
})
6 changes: 5 additions & 1 deletion 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 Expand Up @@ -374,7 +378,7 @@ export class ExperimentsModel extends ModelWithPersistence {
}

return [
this.addDetails(this.workspace),
{ branch: undefined, ...this.addDetails(this.workspace) },
...this.rowOrder.map(({ branch, sha }) => {
const commit = { ...commitsBySha[sha], branch }
const experiments = this.getExperimentsByCommit(commit)
Expand Down
2 changes: 1 addition & 1 deletion extension/src/experiments/webview/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type Experiment = {
starred?: boolean
status?: ExperimentStatus
timestamp?: string | null
branch?: string
branch?: string | undefined
}

export const isRunning = (status: ExperimentStatus | undefined): boolean =>
Expand Down
11 changes: 0 additions & 11 deletions extension/src/test/fixtures/expShow/base/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const ERROR_SHAS = [

const data: ExpShowOutput = [
{
branch: 'main',
rev: EXPERIMENT_WORKSPACE_ID,
data: {
rev: EXPERIMENT_WORKSPACE_ID,
Expand Down Expand Up @@ -123,7 +122,6 @@ const data: ExpShowOutput = [
}
},
{
branch: 'main',
rev: '53c3851f46955fa3e2b8f6e1c52999acc8c9ea77',
name: 'main',
data: {
Expand Down Expand Up @@ -236,7 +234,6 @@ const data: ExpShowOutput = [
name: 'exp-e7a67',
revs: [
{
branch: 'main',
rev: '4fb124aebddb2adf1545030907687fa9a4c80e70',
name: 'exp-e7a67',
data: {
Expand Down Expand Up @@ -356,7 +353,6 @@ const data: ExpShowOutput = [
name: 'test-branch',
revs: [
{
branch: 'main',
rev: '42b8736b08170529903cd203a1f40382a4b4a8cd',
name: 'test-branch',
data: {
Expand Down Expand Up @@ -472,7 +468,6 @@ const data: ExpShowOutput = [
name: 'exp-83425',
revs: [
{
branch: 'main',
rev: EXPERIMENT_WORKSPACE_ID,
name: 'exp-83425',
data: {
Expand Down Expand Up @@ -591,7 +586,6 @@ const data: ExpShowOutput = [
{
revs: [
{
branch: 'main',
rev: ERROR_SHAS[0],
error: {
type: 'YAMLFileCorruptedError',
Expand All @@ -605,7 +599,6 @@ const data: ExpShowOutput = [
name: 'exp-f13bca',
revs: [
{
branch: 'main',
rev: ERROR_SHAS[1],
name: 'exp-f13bca',
data: {
Expand Down Expand Up @@ -718,7 +711,6 @@ const data: ExpShowOutput = [
{
revs: [
{
branch: 'main',
rev: '90aea7f2482117a55dfcadcdb901aaa6610fbbc9',
data: {
rev: '90aea7f2482117a55dfcadcdb901aaa6610fbbc9',
Expand Down Expand Up @@ -833,7 +825,6 @@ const data: ExpShowOutput = [
{
revs: [
{
branch: 'main',
rev: ERROR_SHAS[2],
data: {
rev: ERROR_SHAS[2],
Expand Down Expand Up @@ -916,7 +907,6 @@ const data: ExpShowOutput = [
]
},
{
branch: 'main',
rev: 'fe2919bb4394b30494bea905c253e10077b9a1bd',
data: {
rev: 'fe2919bb4394b30494bea905c253e10077b9a1bd',
Expand Down Expand Up @@ -1025,7 +1015,6 @@ const data: ExpShowOutput = [
}
},
{
branch: 'main',
rev: '7df876cb5147800cd3e489d563bc6dcd67188621',
data: {
rev: '7df876cb5147800cd3e489d563bc6dcd67188621',
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/fixtures/expShow/base/rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const colorsList = copyOriginalColors()

const rowsFixture: Commit[] = [
{
branch: 'main',
branch: undefined,
commit: undefined,
description: undefined,
deps: {
Expand Down
2 changes: 0 additions & 2 deletions extension/src/test/fixtures/expShow/dataTypes/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {

const data: ExpShowOutput = [
{
branch: 'main',
data: {
deps: null,
meta: { has_checkpoints: false },
Expand All @@ -31,7 +30,6 @@ const data: ExpShowOutput = [
rev: EXPERIMENT_WORKSPACE_ID
},
{
branch: 'main',
data: {
deps: null,
meta: { has_checkpoints: false },
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/fixtures/expShow/dataTypes/rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Commit } from '../../../../experiments/webview/contract'

const data: Commit[] = [
{
branch: 'main',
branch: undefined,
displayColor: undefined,
id: EXPERIMENT_WORKSPACE_ID,
label: EXPERIMENT_WORKSPACE_ID,
Expand Down
Loading

0 comments on commit dd121b1

Please sign in to comment.