Skip to content

Commit 26f8342

Browse files
authored
Create default exp show output constant (#3911)
1 parent 3391243 commit 26f8342

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

extension/src/cli/dvc/contract.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ export type MetricsOrParams = RelPathObject<FileDataOrError>
6060
export const fileHasError = (file: FileDataOrError): file is DvcError =>
6161
!!(file as DvcError).error
6262

63+
export const DEFAULT_EXP_SHOW_OUTPUT = [
64+
{
65+
branch: undefined,
66+
rev: EXPERIMENT_WORKSPACE_ID
67+
}
68+
]
69+
6370
export type ExpData = {
6471
rev: string
6572
timestamp: string | null

extension/src/cli/dvc/reader.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {
1010
} from './constants'
1111
import {
1212
DataStatusOutput,
13+
DEFAULT_EXP_SHOW_OUTPUT,
1314
DvcError,
14-
EXPERIMENT_WORKSPACE_ID,
15+
ExpShowOutput,
1516
PlotsOutput,
1617
PlotsOutputOrError,
17-
RawPlotsOutput,
18-
ExpShowOutput
18+
RawPlotsOutput
1919
} from './contract'
2020
import { getOptions } from './options'
2121
import { typeCheckCommands } from '..'
@@ -76,8 +76,7 @@ export class DvcReader extends DvcCli {
7676
if (isDvcError(output) || isEmpty(output)) {
7777
return [
7878
{
79-
branch: undefined,
80-
rev: EXPERIMENT_WORKSPACE_ID,
79+
...DEFAULT_EXP_SHOW_OUTPUT[0],
8180
...(output as DvcError)
8281
}
8382
]

extension/src/test/cli/expShow.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { TEMP_DIR } from './constants'
55
import { dvcReader, initializeDemoRepo, initializeEmptyRepo } from './util'
66
import { dvcDemoPath } from '../util'
77
import {
8-
EXPERIMENT_WORKSPACE_ID,
98
fileHasError,
10-
experimentHasError
9+
experimentHasError,
10+
DEFAULT_EXP_SHOW_OUTPUT
1111
} from '../../cli/dvc/contract'
1212
import { ExperimentFlag } from '../../cli/dvc/constants'
1313

@@ -87,11 +87,7 @@ suite('exp show --show-json', () => {
8787
await initializeEmptyRepo()
8888
const output = await dvcReader.expShow(TEMP_DIR)
8989

90-
expect(output).to.deep.equal([
91-
{
92-
rev: EXPERIMENT_WORKSPACE_ID
93-
}
94-
])
90+
expect(output).to.deep.equal(DEFAULT_EXP_SHOW_OUTPUT)
9591
})
9692
})
9793
})

0 commit comments

Comments
 (0)