Skip to content
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
2 changes: 1 addition & 1 deletion demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dvc[s3]==2.29.0
dvc[s3]==2.30.0
torch==1.12.0
torchvision==0.13.0
4 changes: 2 additions & 2 deletions extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path'

export const MIN_CLI_VERSION = '2.24.0'
export const LATEST_TESTED_CLI_VERSION = '2.29.0'
export const MIN_CLI_VERSION = '2.30.0'
export const LATEST_TESTED_CLI_VERSION = '2.30.0'
export const MAX_CLI_VERSION = '3'

export const UNEXPECTED_ERROR_CODE = 255
Expand Down
10 changes: 8 additions & 2 deletions extension/src/cli/dvc/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ export interface ValueTreeNode {

export type ValueTree = ValueTreeRoot | ValueTreeNode

export enum ExperimentStatus {
FAILED = 'Failed',
QUEUED = 'Queued',
RUNNING = 'Running',
SUCCESS = 'Success'
}

export interface BaseExperimentFields {
name?: string
timestamp?: string | null
queued?: boolean
running?: boolean
status?: ExperimentStatus
executor?: string | null
checkpoint_tip?: string
checkpoint_parent?: string
Expand Down
5 changes: 2 additions & 3 deletions extension/src/experiments/data/collect.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path'
import { collectFiles } from './collect'
import { ExperimentsOutput } from '../../cli/dvc/contract'
import { ExperimentsOutput, ExperimentStatus } from '../../cli/dvc/contract'
import expShowFixture from '../../test/fixtures/expShow/output'

describe('collectFiles', () => {
Expand Down Expand Up @@ -100,8 +100,7 @@ describe('collectFiles', () => {
}
}
},
queued: false,
running: true,
status: ExperimentStatus.RUNNING,
timestamp: null
}
}
Expand Down
4 changes: 2 additions & 2 deletions extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ColumnsModel } from './columns/model'
import { CheckpointsModel } from './checkpoints/model'
import { ExperimentsData } from './data'
import { askToDisableAutoApplyFilters } from './toast'
import { Experiment, ColumnType, TableData } from './webview/contract'
import { Experiment, ColumnType, TableData, isQueued } from './webview/contract'
import { WebviewMessages } from './webview/messages'
import { DecorationProvider } from './model/decorationProvider'
import { starredFilter } from './model/filterBy/constants'
Expand Down Expand Up @@ -333,7 +333,7 @@ export class Experiments extends BaseRepository<TableData> {
if (useFilters) {
const filteredExperiments = this.experiments
.getUnfilteredExperiments()
.filter(exp => !exp.queued)
.filter(exp => !isQueued(exp.status))
if (tooManySelected(filteredExperiments)) {
await this.warnAndDoNotAutoApply(filteredExperiments)
} else {
Expand Down
4 changes: 2 additions & 2 deletions extension/src/experiments/model/accumulator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Experiment } from '../webview/contract'
import { Experiment, isRunning } from '../webview/contract'

export class ExperimentsAccumulator {
public workspace = {} as Experiment
Expand All @@ -11,6 +11,6 @@ export class ExperimentsAccumulator {
if (workspace) {
this.workspace = workspace
}
this.hasRunning = !!workspace?.running
this.hasRunning = isRunning(workspace?.status)
}
}
25 changes: 13 additions & 12 deletions extension/src/experiments/model/collect.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { collectExperiments, collectMutableRevisions } from './collect'
import { Experiment } from '../webview/contract'
import modifiedFixture from '../../test/fixtures/expShow/modified'
import { ExperimentStatus } from '../../cli/dvc/contract'

describe('collectExperiments', () => {
it('should return an empty array if no branches are present', () => {
Expand Down Expand Up @@ -132,16 +133,16 @@ describe('collectExperiments', () => {

describe('collectMutableRevisions', () => {
const baseExperiments = [
{ label: 'branch-A', running: false, selected: false },
{ label: 'workspace', running: false, selected: false }
{ label: 'branch-A', selected: false, status: ExperimentStatus.SUCCESS },
{ label: 'workspace', selected: false, status: ExperimentStatus.FAILED }
] as Experiment[]

it('should not return the workspace when there is a selected running checkpoint experiment (race condition)', () => {
const experiments = [
{
label: 'exp-123',
running: true,
selected: true
selected: true,
status: ExperimentStatus.RUNNING
},
...baseExperiments
] as Experiment[]
Expand All @@ -154,8 +155,8 @@ describe('collectMutableRevisions', () => {
const experiments = [
{
label: 'exp-123',
running: true,
selected: false
selected: false,
status: ExperimentStatus.RUNNING
},
...baseExperiments
] as Experiment[]
Expand All @@ -166,8 +167,8 @@ describe('collectMutableRevisions', () => {

it('should return the workspace when there are no checkpoints', () => {
const experiments = [
{ label: 'branch-A', running: false, selected: false },
{ label: 'workspace', running: false, selected: false }
{ label: 'branch-A', selected: false, status: ExperimentStatus.SUCCESS },
{ label: 'workspace', selected: false, status: ExperimentStatus.SUCCESS }
] as Experiment[]

const mutableRevisions = collectMutableRevisions(experiments, false)
Expand All @@ -176,10 +177,10 @@ describe('collectMutableRevisions', () => {

it('should return all running experiments when there are checkpoints', () => {
const experiments = [
{ label: 'branch-A', running: false, selected: false },
{ label: 'workspace', running: false, selected: false },
{ label: 'running-1', running: true, selected: false },
{ label: 'running-2', running: true, selected: true }
{ label: 'branch-A', selected: false, status: ExperimentStatus.SUCCESS },
{ label: 'workspace', selected: false, status: ExperimentStatus.SUCCESS },
{ label: 'running-1', selected: false, status: ExperimentStatus.RUNNING },
{ label: 'running-2', selected: true, status: ExperimentStatus.RUNNING }
] as Experiment[]

const mutableRevisions = collectMutableRevisions(experiments, false)
Expand Down
17 changes: 9 additions & 8 deletions extension/src/experiments/model/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import omit from 'lodash.omit'
import { ExperimentType } from '.'
import { ExperimentsAccumulator } from './accumulator'
import { extractColumns } from '../columns/extract'
import { Experiment, ColumnType } from '../webview/contract'
import { Experiment, ColumnType, isRunning } from '../webview/contract'
import {
ExperimentFieldsOrError,
ExperimentFields,
ExperimentsBranchOutput,
ExperimentsOutput
ExperimentsOutput,
ExperimentStatus
} from '../../cli/dvc/contract'
import { addToMapArray } from '../../util/map'
import { uniqueValues } from '../../util/array'
Expand Down Expand Up @@ -228,7 +229,7 @@ const collectHasRunningExperiment = (
acc: ExperimentsAccumulator,
experiment: Experiment
) => {
if (experiment.running) {
if (isRunning(experiment.status)) {
acc.hasRunning = true
}
}
Expand Down Expand Up @@ -327,19 +328,19 @@ const getDefaultMutableRevision = (hasCheckpoints: boolean): string[] => {

const noWorkspaceVsSelectedRaceCondition = (
hasCheckpoints: boolean,
running: boolean | undefined,
status: ExperimentStatus | undefined,
selected: boolean | undefined
): boolean => !!(hasCheckpoints && running && !selected)
): boolean => !!(hasCheckpoints && isRunning(status) && !selected)

const collectMutableRevision = (
acc: string[],
{ label, running, selected }: Experiment,
{ label, status, selected }: Experiment,
hasCheckpoints: boolean
) => {
if (noWorkspaceVsSelectedRaceCondition(hasCheckpoints, running, selected)) {
if (noWorkspaceVsSelectedRaceCondition(hasCheckpoints, status, selected)) {
acc.push('workspace')
}
if (running && !hasCheckpoints) {
if (isRunning(status) && !hasCheckpoints) {
acc.push(label)
}
}
Expand Down
13 changes: 5 additions & 8 deletions extension/src/experiments/model/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
dataTypesOutput,
rows as dataTypesRows
} from '../../test/fixtures/expShow/dataTypes'
import { ExperimentStatus } from '../../cli/dvc/contract'

jest.mock('vscode')

Expand Down Expand Up @@ -96,8 +97,7 @@ describe('ExperimentsModel', () => {
data: {
executor: null,
params: { 'params.yaml': { data: { epochs: 100 } } },
queued: false,
running: false,
status: ExperimentStatus.SUCCESS,
timestamp: null
}
}
Expand All @@ -109,8 +109,7 @@ describe('ExperimentsModel', () => {
executor: null,
name: 'main',
params: { 'params.yaml': { data: { epochs: 100 } } },
queued: false,
running: false,
status: ExperimentStatus.SUCCESS,
timestamp: '2022-08-10T19:40:14'
}
},
Expand All @@ -126,8 +125,7 @@ describe('ExperimentsModel', () => {
},
executor: null,
name: 'exp-750e4',
queued: false,
running: false,
status: ExperimentStatus.SUCCESS,
timestamp: '2022-08-11T23:04:39'
}
},
Expand All @@ -137,8 +135,7 @@ describe('ExperimentsModel', () => {
executor: null,
name: 'exp-d6ddc',
params: { 'params.yaml': { data: { epochs: 100 } } },
queued: false,
running: false,
status: ExperimentStatus.SUCCESS,
timestamp: '2022-08-11T22:55:46'
}
}
Expand Down
38 changes: 14 additions & 24 deletions extension/src/experiments/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ import {
UNSELECTED
} from './status'
import { collectFlatExperimentParams } from './modify/collect'
import { Experiment, Row } from '../webview/contract'
import { Experiment, isQueued, Row } from '../webview/contract'
import {
definedAndNonEmpty,
reorderListSubset,
reorderObjectList
} from '../../util/array'
import { ExperimentsOutput } from '../../cli/dvc/contract'
import { setContextValue } from '../../vscode/context'
import { hasKey } from '../../util/object'
import { flattenMapValues } from '../../util/map'
import { ModelWithPersistence } from '../../persistence/model'
import { PersistenceKey } from '../../persistence/constants'
Expand Down Expand Up @@ -129,8 +128,11 @@ export class ExperimentsModel extends ModelWithPersistence {

public toggleStatus(id: string) {
if (
this.getFlattenedExperiments().find(({ id: queuedId }) => queuedId === id)
?.queued
isQueued(
this.getFlattenedExperiments().find(
({ id: queuedId }) => queuedId === id
)?.status
)
) {
return
}
Expand Down Expand Up @@ -318,8 +320,8 @@ export class ExperimentsModel extends ModelWithPersistence {
public getExperimentsWithCheckpoints(): ExperimentWithCheckpoints[] {
const experimentsWithCheckpoints: ExperimentWithCheckpoints[] = []
for (const experiment of this.getAllExperiments()) {
const { id, queued } = experiment
if (queued) {
const { id, status } = experiment
if (isQueued(status)) {
continue
}

Expand Down Expand Up @@ -412,7 +414,7 @@ export class ExperimentsModel extends ModelWithPersistence {
return this.getExperimentsByBranch(branch)?.map(experiment => ({
...experiment,
hasChildren: definedAndNonEmpty(this.checkpointsByTip.get(experiment.id)),
type: experiment.queued
type: isQueued(experiment.status)
? ExperimentType.QUEUED
: ExperimentType.EXPERIMENT
}))
Expand Down Expand Up @@ -494,11 +496,11 @@ export class ExperimentsModel extends ModelWithPersistence {
}

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

Expand Down Expand Up @@ -569,23 +571,11 @@ export class ExperimentsModel extends ModelWithPersistence {
private addDetails(experiment: Experiment) {
const { id } = experiment

const starred = !!this.isStarred(id)

if (!hasKey(this.coloredStatus, id)) {
return {
...experiment,
selected: false,
starred
}
}

const selected = this.isSelected(id)

return {
...experiment,
displayColor: this.getDisplayColor(id),
selected,
starred
selected: this.isSelected(id),
starred: !!this.isStarred(id)
}
}

Expand Down
1 change: 0 additions & 1 deletion extension/src/experiments/model/sortBy/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('sortExperiments', () => {
checkpoint_tip: 'd3f4a0d3661c5977540d2205d819470cf0d2145a',
id: testId,
label: testLabel,
queued: false,
timestamp: testTimestamp
}
const testPathArray: [ColumnType, string, string] = [
Expand Down
3 changes: 2 additions & 1 deletion extension/src/experiments/model/status/collect.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { collectColoredStatus } from './collect'
import { copyOriginalColors } from './colors'
import { Experiment } from '../../webview/contract'
import { ExperimentStatus } from '../../../cli/dvc/contract'

describe('collectColoredStatus', () => {
const buildMockExperiments = (n: number, prefix = 'exp') => {
Expand Down Expand Up @@ -41,7 +42,7 @@ describe('collectColoredStatus', () => {
it('should not push queued experiments into the returned object', () => {
const experiments = [
{ id: 'exp1' },
{ id: 'exp2', queued: true }
{ id: 'exp2', status: ExperimentStatus.QUEUED }
] as Experiment[]
const colors = copyOriginalColors()

Expand Down
6 changes: 3 additions & 3 deletions extension/src/experiments/model/status/collect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { canSelect, ColoredStatus, UNSELECTED } from '.'
import { Color, copyOriginalColors } from './colors'
import { hasKey } from '../../../util/object'
import { Experiment } from '../../webview/contract'
import { Experiment, isQueued } from '../../webview/contract'
import { definedAndNonEmpty, reorderListSubset } from '../../../util/array'
import { flattenMapValues } from '../../../util/map'

Expand All @@ -21,8 +21,8 @@ const collectStatus = (
experiment: Experiment,
unassignColors?: Color[]
) => {
const { id, queued } = experiment
if (!id || queued || hasKey(acc, id)) {
const { id, status } = experiment
if (!id || isQueued(status) || hasKey(acc, id)) {
return
}

Expand Down
Loading