Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove error for invalid dvc.yaml if no dvc.yaml file #3514

Merged
merged 7 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion extension/src/experiments/webview/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { ConfigKey, setConfigValue } from '../../vscode/config'
import { Toast } from '../../vscode/toast'
import { EXPERIMENT_WORKSPACE_ID } from '../../cli/dvc/contract'
import { stopWorkspaceExperiment } from '../processExecution'
import { hasDvcYamlFile } from '../../fileSystem'

export class WebviewMessages {
private readonly dvcRoot: string
Expand Down Expand Up @@ -77,7 +78,7 @@ export class WebviewMessages {

public async changeHasConfig(update?: boolean) {
const stages = await this.hasStages()
this.hasValidDvcYaml = stages !== undefined
this.hasValidDvcYaml = !hasDvcYamlFile(this.dvcRoot) || stages !== undefined
this.hasConfig = !!stages
update && this.sendWebviewMessage()
}
Expand Down
2 changes: 2 additions & 0 deletions extension/src/fileSystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export const openImageFileInEditor = async (imagePath: string) =>
viewColumn: ViewColumn.Beside
})

export const hasDvcYamlFile = (cwd: string) => existsSync(`${cwd}/dvc.yaml`)

export const findOrCreateDvcYamlFile = (
cwd: string,
trainingScript: string,
Expand Down
90 changes: 90 additions & 0 deletions extension/src/test/suite/experiments/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,96 @@ suite('Experiments Test Suite', () => {
expect(windowSpy).not.to.have.been.called
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should set hasValidDvcYaml to false if there is an error getting stages and there is a dvc.yaml file', async () => {
stub(DvcReader.prototype, 'listStages').resolves(undefined)
stub(FileSystem, 'hasDvcYamlFile').resolves(true)

const { experiments, messageSpy } = buildExperiments(
disposable,
expShowFixture
)

await experiments.showWebview()

const expectedTableData: TableData = {
changes: workspaceChangesFixture,
columnOrder: columnsOrderFixture,
columnWidths: {},
columns: columnsFixture,
filteredCounts: { checkpoints: 0, experiments: 0 },
filters: [],
hasCheckpoints: true,
hasColumns: true,
hasConfig: false,
hasRunningExperiment: true,
hasValidDvcYaml: false,
rows: rowsFixture,
sorts: []
}

expect(messageSpy).to.be.calledWithExactly(expectedTableData)
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should set hasValidDvcYaml to true if there is an error getting stages and there is no dvc.yaml file', async () => {
stub(DvcReader.prototype, 'listStages').resolves(undefined)
stub(FileSystem, 'hasDvcYamlFile').resolves(false)

const { experiments, messageSpy } = buildExperiments(
disposable,
expShowFixture
)

await experiments.showWebview()

const expectedTableData: TableData = {
changes: workspaceChangesFixture,
columnOrder: columnsOrderFixture,
columnWidths: {},
columns: columnsFixture,
filteredCounts: { checkpoints: 0, experiments: 0 },
filters: [],
hasCheckpoints: true,
hasColumns: true,
hasConfig: false,
hasRunningExperiment: true,
hasValidDvcYaml: true,
rows: rowsFixture,
sorts: []
}

expect(messageSpy).to.be.calledWithExactly(expectedTableData)
}).timeout(WEBVIEW_TEST_TIMEOUT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[F] This one seems like a genuine cross-platform failure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, just me using resolves for the stub instead or returns. I had an await for it that I removed after the lint stage before pushing my changes, so local tests passed, but they were not doing what they should have and were changed before committing.


it('should set hasValidDvcYaml to true if there are no errors getting stages', async () => {
stub(DvcReader.prototype, 'listStages').resolves('')
stub(FileSystem, 'hasDvcYamlFile').resolves(false)

const { experiments, messageSpy } = buildExperiments(
disposable,
expShowFixture
)

await experiments.showWebview()

const expectedTableData: TableData = {
changes: workspaceChangesFixture,
columnOrder: columnsOrderFixture,
columnWidths: {},
columns: columnsFixture,
filteredCounts: { checkpoints: 0, experiments: 0 },
filters: [],
hasCheckpoints: true,
hasColumns: true,
hasConfig: false,
hasRunningExperiment: true,
hasValidDvcYaml: true,
rows: rowsFixture,
sorts: []
}

expect(messageSpy).to.be.calledWithExactly(expectedTableData)
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should set hasConfig to false if there are no stages', async () => {
stub(DvcReader.prototype, 'listStages').resolves('')

Expand Down