Skip to content

Commit 44b0df4

Browse files
authored
Fix never ending loading on no experiments data (#4117)
1 parent e992aa8 commit 44b0df4

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

extension/src/cli/dvc/contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export type ExpWithError = {
100100
type ExpWithData = {
101101
rev: string
102102
name?: string
103-
data: ExpData
103+
data?: ExpData
104104
}
105105

106106
export type ExpState = ExpWithData | ExpWithError

extension/src/experiments/columns/collect/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ describe('collectChanges', () => {
420420
}
421421

422422
expect(changes).toStrictEqual(
423-
Object.keys(workspace.data.deps || {})
423+
Object.keys(workspace?.data?.deps || {})
424424
.map(dep => `deps:${dep}`)
425425
.sort()
426426
)

extension/src/experiments/columns/collect/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const collectParamsFiles = (
101101
if (experimentHasError(workspace)) {
102102
return new Set()
103103
}
104-
const files = Object.keys(workspace.data.params || {})
104+
const files = Object.keys(workspace?.data?.params || {})
105105
.filter(Boolean)
106106
.map(file => standardizePath(join(dvcRoot, file)))
107107
return new Set(files)

extension/src/experiments/model/collect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ const hasCheckpoints = (data: ExpShowOutput) => {
328328
return false
329329
}
330330

331-
return !!workspace.data.meta.has_checkpoints
331+
return !!workspace?.data?.meta.has_checkpoints
332332
}
333333

334334
const collectCliError = (

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ suite('exp show --show-json', () => {
4545
'object'
4646
)
4747

48-
expect(commit.data.timestamp, 'should have a timestamp').to.be.a(
48+
expect(commit?.data?.timestamp, 'should have a timestamp').to.be.a(
4949
'string'
5050
)
5151

52-
expect(commit.data.params, 'should have params').to.be.an('object')
53-
expect(commit.data.metrics, 'should have metrics').to.be.an('object')
52+
expect(commit?.data?.params, 'should have params').to.be.an('object')
53+
expect(commit?.data?.metrics, 'should have metrics').to.be.an('object')
5454

5555
for (const file of Object.values({
56-
...commit.data.params,
57-
...commit.data.metrics
56+
...commit?.data?.params,
57+
...commit?.data?.metrics
5858
})) {
5959
expect(file, 'should have children').to.be.an('object')
6060
if (fileHasError(file)) {
@@ -64,8 +64,8 @@ suite('exp show --show-json', () => {
6464
expect(isEmpty(file.data), 'should have data').to.be.false
6565
}
6666

67-
expect(commit.data.deps, 'should have deps').to.be.an('object')
68-
expect(commit.data.outs, 'should have outs').to.be.an('object')
67+
expect(commit?.data?.deps, 'should have deps').to.be.an('object')
68+
expect(commit?.data?.outs, 'should have outs').to.be.an('object')
6969

7070
for (const file of Object.values({
7171
...commit.data?.deps,

extension/src/test/suite/plots/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { isErrorItem } from '../../../tree'
4545
import { RegisteredCommands } from '../../../commands/external'
4646
import { REVISIONS } from '../../fixtures/plotsDiff'
4747
import * as FileSystem from '../../../fileSystem'
48-
import { experimentHasError } from '../../../cli/dvc/contract'
48+
import { ExpShowOutput, experimentHasError } from '../../../cli/dvc/contract'
4949
import { COMMITS_SEPARATOR } from '../../../cli/git/constants'
5050

5151
suite('Plots Test Suite', () => {
@@ -139,7 +139,7 @@ suite('Plots Test Suite', () => {
139139
bypassProcessManagerDebounce(mockNow)
140140
void experiments.setState({
141141
availableNbCommits: { main: 6 },
142-
expShow: updatedExpShowFixture,
142+
expShow: updatedExpShowFixture as ExpShowOutput,
143143
gitLog: newCommit + COMMITS_SEPARATOR + gitLogFixture,
144144
rowOrder: [{ branch: 'main', sha: newCommit }, ...rowOrderFixture]
145145
})

0 commit comments

Comments
 (0)