Skip to content

Commit 4ee2f9e

Browse files
authored
Rename experiment status to executor status (#4359)
1 parent c0f3902 commit 4ee2f9e

File tree

19 files changed

+119
-111
lines changed

19 files changed

+119
-111
lines changed

extension/src/cli/dvc/contract.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const isValueTree = (
3838
): value is NonNullable<ValueTree> =>
3939
!!(value && !Array.isArray(value) && typeof value === 'object')
4040

41-
export enum ExperimentStatus {
41+
export enum ExecutorStatus {
4242
FAILED = 'failed',
4343
QUEUED = 'queued',
4444
RUNNING = 'running',
@@ -81,7 +81,7 @@ export enum Executor {
8181
}
8282

8383
export type ExecutorState = {
84-
state: ExperimentStatus
84+
state: ExecutorStatus
8585
name: Executor | null
8686
local: {
8787
root: string | null

extension/src/experiments/model/collect.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from '../webview/contract'
1616
import {
1717
EXPERIMENT_WORKSPACE_ID,
18-
ExperimentStatus,
18+
ExecutorStatus,
1919
ExpShowOutput,
2020
ExpState,
2121
Executor,
@@ -229,19 +229,19 @@ const collectExecutorInfo = (
229229

230230
const { name, state } = executor
231231

232-
if (name && state === ExperimentStatus.RUNNING) {
232+
if (name && state === ExecutorStatus.RUNNING) {
233233
experiment.executor = name
234234
}
235-
if (state && state !== ExperimentStatus.SUCCESS) {
236-
experiment.status = state
235+
if (state && state !== ExecutorStatus.SUCCESS) {
236+
experiment.executorStatus = state
237237
}
238238
}
239239

240240
const collectRunningExperiment = (
241241
acc: ExperimentsAccumulator,
242242
experiment: Experiment
243243
): void => {
244-
if (!isRunning(experiment.status)) {
244+
if (!isRunning(experiment.executorStatus)) {
245245
return
246246
}
247247
acc.runningExperiments.push({
@@ -310,7 +310,7 @@ const setWorkspaceAsRunning = (
310310
)
311311
) {
312312
acc.workspace.executor = Executor.WORKSPACE
313-
acc.workspace.status = ExperimentStatus.RUNNING
313+
acc.workspace.executorStatus = ExecutorStatus.RUNNING
314314
}
315315

316316
if (dvcLiveOnly) {
@@ -435,7 +435,7 @@ const collectExperimentsAndCommit = (
435435
): void => {
436436
acc.push(commit)
437437
for (const experiment of experiments) {
438-
if (isQueued(experiment.status)) {
438+
if (isQueued(experiment.executorStatus)) {
439439
continue
440440
}
441441
acc.push(experiment)

extension/src/experiments/model/index.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import dataTypesOutputFixture from '../../test/fixtures/expShow/dataTypes/output
2020
import survivalOutputFixture from '../../test/fixtures/expShow/survival/output'
2121
import survivalRowsFixture from '../../test/fixtures/expShow/survival/rows'
2222
import {
23-
ExperimentStatus,
23+
ExecutorStatus,
2424
EXPERIMENT_WORKSPACE_ID,
2525
Executor,
2626
ExpWithError,
@@ -111,7 +111,9 @@ describe('ExperimentsModel', () => {
111111
// eslint-disable-next-line @typescript-eslint/no-explicit-any
112112
const runningWorkspace = (model as any).workspace
113113
expect(runningWorkspace?.executor).toStrictEqual(EXPERIMENT_WORKSPACE_ID)
114-
expect(runningWorkspace?.status).toStrictEqual(ExperimentStatus.RUNNING)
114+
expect(runningWorkspace?.executorStatus).toStrictEqual(
115+
ExecutorStatus.RUNNING
116+
)
115117

116118
model.transformAndSetLocal(dvcLiveOnly, ...DEFAULT_DATA)
117119
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -292,7 +294,7 @@ describe('ExperimentsModel', () => {
292294
executor: {
293295
local: null,
294296
name: Executor.WORKSPACE,
295-
state: ExperimentStatus.RUNNING
297+
state: ExecutorStatus.RUNNING
296298
},
297299
name: runningExpName,
298300
rev: EXPERIMENT_WORKSPACE_ID
@@ -305,7 +307,7 @@ describe('ExperimentsModel', () => {
305307
executor: {
306308
local: null,
307309
name: Executor.DVC_TASK,
308-
state: ExperimentStatus.RUNNING
310+
state: ExecutorStatus.RUNNING
309311
},
310312
name: runningTaskName,
311313
rev: EXPERIMENT_WORKSPACE_ID

extension/src/experiments/model/index.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ import {
3030
WORKSPACE_BRANCH
3131
} from '../webview/contract'
3232
import { reorderListSubset } from '../../util/array'
33-
import {
34-
Executor,
35-
ExpShowOutput,
36-
ExperimentStatus
37-
} from '../../cli/dvc/contract'
33+
import { Executor, ExpShowOutput, ExecutorStatus } from '../../cli/dvc/contract'
3834
import { flattenMapValues } from '../../util/map'
3935
import { ModelWithPersistence } from '../../persistence/model'
4036
import { PersistenceKey } from '../../persistence/constants'
@@ -184,7 +180,7 @@ export class ExperimentsModel extends ModelWithPersistence {
184180
({ id: expId }) => expId === id
185181
)
186182

187-
if (isQueued(experiment?.status)) {
183+
if (isQueued(experiment?.executorStatus)) {
188184
return UNSELECTED
189185
}
190186

@@ -378,8 +374,8 @@ export class ExperimentsModel extends ModelWithPersistence {
378374
}
379375

380376
public getExperiments() {
381-
return this.getExperimentsAndQueued().filter(({ status }) => {
382-
return !isQueued(status)
377+
return this.getExperimentsAndQueued().filter(({ executorStatus }) => {
378+
return !isQueued(executorStatus)
383379
})
384380
}
385381

@@ -397,7 +393,7 @@ export class ExperimentsModel extends ModelWithPersistence {
397393

398394
public getRunningExperiments() {
399395
return this.getExperimentsAndQueued().filter(experiment =>
400-
isRunning(experiment.status)
396+
isRunning(experiment.executorStatus)
401397
)
402398
}
403399

@@ -471,7 +467,7 @@ export class ExperimentsModel extends ModelWithPersistence {
471467
return this.getExperimentsByCommit(commit)?.map(experiment => ({
472468
...experiment,
473469
hasChildren: false,
474-
type: this.getExperimentType(experiment.status)
470+
type: this.getExperimentType(experiment.executorStatus)
475471
}))
476472
}
477473

@@ -569,7 +565,7 @@ export class ExperimentsModel extends ModelWithPersistence {
569565
if (
570566
this.remoteExpShas === undefined ||
571567
!experiment.sha ||
572-
![undefined, ExperimentStatus.SUCCESS].includes(experiment.status)
568+
![undefined, ExecutorStatus.SUCCESS].includes(experiment.executorStatus)
573569
) {
574570
return
575571
}
@@ -670,11 +666,11 @@ export class ExperimentsModel extends ModelWithPersistence {
670666
}
671667
}
672668

673-
private getExperimentType(status?: ExperimentStatus) {
674-
if (isQueued(status)) {
669+
private getExperimentType(executorStatus?: ExecutorStatus) {
670+
if (isQueued(executorStatus)) {
675671
return ExperimentType.QUEUED
676672
}
677-
if (isRunning(status)) {
673+
if (isRunning(executorStatus)) {
678674
return ExperimentType.RUNNING
679675
}
680676

extension/src/experiments/model/status/collect.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { collectColoredStatus } from './collect'
33
import { copyOriginalColors } from './colors'
44
import { Experiment } from '../../webview/contract'
55
import {
6-
ExperimentStatus,
6+
ExecutorStatus,
77
EXPERIMENT_WORKSPACE_ID
88
} from '../../../cli/dvc/contract'
99

@@ -39,7 +39,7 @@ describe('collectColoredStatus', () => {
3939
it('should not push queued experiments into the returned object', () => {
4040
const experiments = [
4141
{ id: 'exp1' },
42-
{ id: 'exp2', status: ExperimentStatus.QUEUED }
42+
{ executorStatus: ExecutorStatus.QUEUED, id: 'exp2' }
4343
] as Experiment[]
4444
const colors = copyOriginalColors()
4545

@@ -214,8 +214,8 @@ describe('collectColoredStatus', () => {
214214
[
215215
{
216216
executor: null,
217-
id: 'exp-1',
218-
status: ExperimentStatus.SUCCESS
217+
executorStatus: ExecutorStatus.SUCCESS,
218+
id: 'exp-1'
219219
},
220220
{
221221
id: EXPERIMENT_WORKSPACE_ID

extension/src/experiments/model/status/collect.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const canAssign = (
1818
): boolean => canSelect(coloredStatus) && definedAndNonEmpty(unassignedColors)
1919

2020
const collectStatus = (acc: ColoredStatus, experiment: Experiment): void => {
21-
const { id, status } = experiment
21+
const { id, executorStatus: status } = experiment
2222
if (!id || isQueued(status) || hasKey(acc, id)) {
2323
return
2424
}
@@ -164,8 +164,10 @@ const assignSelected = (
164164
return { availableColors, coloredStatus }
165165
}
166166

167-
const cannotSelect = (ids: Set<string>, { id, status }: Experiment): boolean =>
168-
isQueued(status) || ids.has(id)
167+
const cannotSelect = (
168+
ids: Set<string>,
169+
{ id, executorStatus: status }: Experiment
170+
): boolean => isQueued(status) || ids.has(id)
169171

170172
export const collectSelectable = (
171173
selectedExperiments: Experiment[]

extension/src/experiments/model/status/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { canSelect, limitToMaxSelected } from '.'
22
import { copyOriginalColors } from './colors'
33
import { Experiment } from '../../webview/contract'
4-
import { ExperimentStatus } from '../../../cli/dvc/contract'
4+
import { ExecutorStatus } from '../../../cli/dvc/contract'
55

66
describe('canSelect', () => {
77
const colors = copyOriginalColors()
@@ -51,9 +51,9 @@ describe('limitToMaxSelected', () => {
5151
...mockedExperiments,
5252
{
5353
branch: 'main',
54+
executorStatus: ExecutorStatus.RUNNING,
5455
id: '1',
55-
label: 'R',
56-
status: ExperimentStatus.RUNNING
56+
label: 'R'
5757
}
5858
])
5959
.map(({ label }) => label)

extension/src/experiments/model/status/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const compareTimestamps = (a: Experiment, b: Experiment) =>
2525
export const limitToMaxSelected = (experiments: Experiment[]) =>
2626
[...experiments]
2727
.sort((a, b) => {
28-
if (a.status === b.status) {
28+
if (a.executorStatus === b.executorStatus) {
2929
return compareTimestamps(a, b)
3030
}
31-
return isRunning(a.status) ? -1 : 1
31+
return isRunning(a.executorStatus) ? -1 : 1
3232
})
3333
.slice(0, MAX_SELECTED_EXPERIMENTS)

extension/src/experiments/webview/contract.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Executor, ExperimentStatus, ValueTree } from '../../cli/dvc/contract'
1+
import { Executor, ExecutorStatus, ValueTree } from '../../cli/dvc/contract'
22
import { SortDefinition } from '../model/sortBy'
3-
4-
export { ExperimentStatus } from '../../cli/dvc/contract'
3+
export { ExecutorStatus } from '../../cli/dvc/contract'
54

65
export interface MetricOrParamColumns {
76
[filename: string]: ValueTree
@@ -51,24 +50,25 @@ export type Experiment = {
5150
selected?: boolean
5251
sha?: string
5352
starred?: boolean
54-
status?: ExperimentStatus
53+
executorStatus?: ExecutorStatus
5554
timestamp?: string | null
5655
branch?: string | typeof WORKSPACE_BRANCH
5756
}
5857

59-
export const isRunning = (status: ExperimentStatus | undefined): boolean =>
60-
status === ExperimentStatus.RUNNING
58+
export const isRunning = (
59+
executorStatus: ExecutorStatus | undefined
60+
): boolean => executorStatus === ExecutorStatus.RUNNING
6161

62-
export const isQueued = (status: ExperimentStatus | undefined): boolean =>
63-
status === ExperimentStatus.QUEUED
62+
export const isQueued = (executorStatus: ExecutorStatus | undefined): boolean =>
63+
executorStatus === ExecutorStatus.QUEUED
6464

6565
export const isRunningInQueue = ({
66-
status,
66+
executorStatus,
6767
executor
6868
}: {
69-
status?: ExperimentStatus
69+
executorStatus?: ExecutorStatus
7070
executor?: string | null
71-
}): boolean => isRunning(status) && executor === Executor.DVC_TASK
71+
}): boolean => isRunning(executorStatus) && executor === Executor.DVC_TASK
7272

7373
export interface Commit extends Experiment {
7474
subRows?: Experiment[]

extension/src/test/fixtures/expShow/base/output.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { join } from '../../../util/path'
22
import {
33
EXPERIMENT_WORKSPACE_ID,
44
Executor,
5-
ExperimentStatus,
5+
ExecutorStatus,
66
ExpShowOutput
77
} from '../../../../cli/dvc/contract'
88

@@ -345,7 +345,7 @@ const data: ExpShowOutput = [
345345
],
346346
executor: {
347347
name: Executor.DVC_TASK,
348-
state: ExperimentStatus.RUNNING,
348+
state: ExecutorStatus.RUNNING,
349349
local: null
350350
}
351351
},
@@ -580,7 +580,7 @@ const data: ExpShowOutput = [
580580
executor: {
581581
name: Executor.WORKSPACE,
582582
local: { pid: 1234, root: null, log: null, returncode: null },
583-
state: ExperimentStatus.RUNNING
583+
state: ExecutorStatus.RUNNING
584584
}
585585
},
586586
{
@@ -593,7 +593,7 @@ const data: ExpShowOutput = [
593593
}
594594
}
595595
],
596-
executor: { state: ExperimentStatus.FAILED, local: null, name: null }
596+
executor: { state: ExecutorStatus.FAILED, local: null, name: null }
597597
},
598598
{
599599
name: 'exp-f13bca',
@@ -811,7 +811,7 @@ const data: ExpShowOutput = [
811811
}
812812
],
813813
executor: {
814-
state: ExperimentStatus.QUEUED,
814+
state: ExecutorStatus.QUEUED,
815815
name: Executor.DVC_TASK,
816816
local: {
817817
root: null,
@@ -902,7 +902,7 @@ const data: ExpShowOutput = [
902902
}
903903
}
904904
],
905-
executor: { state: ExperimentStatus.FAILED, local: null, name: null }
905+
executor: { state: ExecutorStatus.FAILED, local: null, name: null }
906906
}
907907
]
908908
},

0 commit comments

Comments
 (0)