Skip to content

Commit

Permalink
Merge branch 'main' into remove-unused-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephanie Roy committed Oct 30, 2023
2 parents fc76c71 + 65cb8e5 commit 8afc581
Show file tree
Hide file tree
Showing 11 changed files with 950 additions and 633 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## [1.1.12] - 2023-10-27

### 🚀 New Features and Enhancements

- Remove check for stages in plot wizard [#4904](https://github.com/iterative/vscode-dvc/pull/4904) by [@julieg18](https://github.com/julieg18)

### 🔨 Maintenance

- Fix unstable `quickPickUserOrderedValues` test in windows [#4900](https://github.com/iterative/vscode-dvc/pull/4900) by [@julieg18](https://github.com/julieg18)
- Split drag and drop container into different files [#4880](https://github.com/iterative/vscode-dvc/pull/4880) by [@sroy3](https://github.com/sroy3)

## [1.1.11] - 2023-10-25

### 🚀 New Features and Enhancements
Expand Down
8 changes: 4 additions & 4 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"extensionDependencies": [
"vscode.git"
],
"version": "1.1.11",
"version": "1.1.12",
"license": "Apache-2.0",
"readme": "./README.md",
"repository": {
Expand Down Expand Up @@ -1715,7 +1715,7 @@
"appdirs": "1.1.0",
"execa": "5.1.1",
"fs-extra": "11.1.1",
"json-2-csv": "4.1.0",
"json-2-csv": "4.1.1",
"json5": "2.2.3",
"lodash.clonedeep": "4.5.0",
"lodash.get": "4.4.2",
Expand All @@ -1732,7 +1732,7 @@
"yaml": "2.3.3"
},
"devDependencies": {
"@swc/core": "1.3.93",
"@swc/core": "1.3.94",
"@swc/jest": "0.2.29",
"@types/chai": "4.3.9",
"@types/chai-as-promised": "7.1.7",
Expand Down Expand Up @@ -1770,7 +1770,7 @@
"mocha": "10.2.0",
"mock-require": "3.0.3",
"shx": "0.3.4",
"sinon": "16.1.3",
"sinon": "17.0.0",
"sinon-chai": "3.7.0",
"ts-loader": "9.5.0",
"vscode-uri": "3.0.8",
Expand Down
29 changes: 29 additions & 0 deletions extension/src/fileSystem/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,29 @@ describe('addPlotToDvcYamlFile', () => {
' y:',
' data.json: accuracy'
]

it('should add a plots list with the new plot if the dvc.yaml file does not exist', () => {
const mockPlotYamlContent = ['', 'plots:', ...mockNewPlotLines, ''].join(
'\n'
)
mockedReadFileSync.mockReturnValueOnce('')
mockedReadFileSync.mockReturnValueOnce('')

addPlotToDvcYamlFile('/', {
template: 'simple',
title: 'Simple Plot',
x: { 'data.json': ['epochs'] },
y: { 'data.json': ['accuracy'] }
})

expect(mockedEnsureFileSync).toHaveBeenCalledWith('//dvc.yaml')
expect(mockedOpenTextDocument).toHaveBeenCalledTimes(1)
expect(mockedWriteFileSync).toHaveBeenCalledWith(
'//dvc.yaml',
mockPlotYamlContent
)
})

it('should add a plots list with the new plot if the dvc.yaml file has no plots', () => {
const mockDvcYamlContent = mockStagesLines.join('\n')
const mockPlotYamlContent = ['', 'plots:', ...mockNewPlotLines, ''].join(
Expand All @@ -655,6 +678,7 @@ describe('addPlotToDvcYamlFile', () => {
y: { 'data.json': ['accuracy'] }
})

expect(mockedOpenTextDocument).toHaveBeenCalledTimes(1)
expect(mockedWriteFileSync).toHaveBeenCalledWith(
'//dvc.yaml',
mockDvcYamlContent + mockPlotYamlContent
Expand Down Expand Up @@ -684,6 +708,7 @@ describe('addPlotToDvcYamlFile', () => {
y: { 'acc.json': ['accuracy'] }
})

expect(mockedOpenTextDocument).toHaveBeenCalledTimes(1)
expect(mockedWriteFileSync).toHaveBeenCalledWith(
'//dvc.yaml',
mockDvcYamlContent + mockPlotYamlContent
Expand Down Expand Up @@ -714,6 +739,7 @@ describe('addPlotToDvcYamlFile', () => {
y: { 'data.json': ['accuracy', 'epochs'] }
})

expect(mockedOpenTextDocument).toHaveBeenCalledTimes(1)
expect(mockedWriteFileSync).toHaveBeenCalledWith(
'//dvc.yaml',
mockDvcYamlContent + mockPlotYamlContent
Expand All @@ -735,6 +761,7 @@ describe('addPlotToDvcYamlFile', () => {

mockDvcYamlContent.splice(7, 0, ...mockPlotYamlContent)

expect(mockedOpenTextDocument).toHaveBeenCalledTimes(1)
expect(mockedWriteFileSync).toHaveBeenCalledWith(
'//dvc.yaml',
mockDvcYamlContent.join('\n')
Expand All @@ -756,6 +783,7 @@ describe('addPlotToDvcYamlFile', () => {
y: { 'data.json': ['accuracy'] }
})

expect(mockedOpenTextDocument).toHaveBeenCalledTimes(1)
expect(mockedWriteFileSync).toHaveBeenCalledWith(
'//dvc.yaml',
mockDvcYamlContent + mockPlotYamlContent
Expand Down Expand Up @@ -794,6 +822,7 @@ describe('addPlotToDvcYamlFile', () => {
y: { 'data.json': ['accuracy'] }
})

expect(mockedOpenTextDocument).toHaveBeenCalledTimes(1)
expect(mockedWriteFileSync).toHaveBeenCalledWith(
'//dvc.yaml',
mockDvcYamlContent + mockPlotYamlContent
Expand Down
6 changes: 4 additions & 2 deletions extension/src/fileSystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ const getPlotsYaml = (plotObj: PlotConfigData, indentSearchLines: string[]) => {

export const addPlotToDvcYamlFile = (cwd: string, plotObj: PlotConfigData) => {
const dvcYamlFile = `${cwd}/dvc.yaml`
ensureFileSync(dvcYamlFile)
const dvcYamlDoc = loadYamlAsDoc(dvcYamlFile)

if (!dvcYamlDoc) {
Expand All @@ -276,8 +277,9 @@ export const addPlotToDvcYamlFile = (cwd: string, plotObj: PlotConfigData) => {
if (!plots?.range) {
const plotYaml = getPlotsYaml(plotObj, dvcYamlLines)
dvcYamlLines.push(...plotYaml)
writeFileSync(dvcYamlFile, dvcYamlLines.join('\n'))
return

void openFileInEditor(dvcYamlFile)
return writeFileSync(dvcYamlFile, dvcYamlLines.join('\n'))
}

const plotsEndPos = lineCounter.linePos(plots.range[2]).line
Expand Down
51 changes: 25 additions & 26 deletions extension/src/pipeline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,8 @@ export class Pipeline extends DeferredDisposable {
}

public async getCwd() {
const focusedPipeline = this.getFocusedPipeline()
if (focusedPipeline) {
return focusedPipeline
}

await this.checkOrAddPipeline()

const pipelines = this.model.getPipelines()
if (!pipelines?.size) {
return
}
if (pipelines.has(this.dvcRoot)) {
return this.dvcRoot
}
if (pipelines.size === 1) {
return [...pipelines][0]
}

return quickPickOne(
[...pipelines],
'Select a Pipeline to Run Command Against'
)
return this.findPipelineCwd()
}

public async checkOrAddPipeline() {
Expand Down Expand Up @@ -158,11 +138,7 @@ export class Pipeline extends DeferredDisposable {
}

public async addDataSeriesPlot() {
const cwd = await this.getCwd()

if (!cwd) {
return
}
const cwd = (await this.findPipelineCwd()) || this.dvcRoot

const plotConfiguration = await pickPlotConfiguration(cwd)

Expand All @@ -177,6 +153,29 @@ export class Pipeline extends DeferredDisposable {
return appendFileSync(join(this.dvcRoot, TEMP_DAG_FILE), '\n')
}

private findPipelineCwd() {
const focusedPipeline = this.getFocusedPipeline()
if (focusedPipeline) {
return focusedPipeline
}

const pipelines = this.model.getPipelines()
if (!pipelines?.size) {
return
}
if (pipelines.has(this.dvcRoot)) {
return this.dvcRoot
}
if (pipelines.size === 1) {
return [...pipelines][0]
}

return quickPickOne(
[...pipelines],
'Select a Pipeline to Run Command Against'
)
}

private async initialize() {
this.dispose.track(
this.data.onDidUpdate(({ dag, stages }) => {
Expand Down
46 changes: 40 additions & 6 deletions extension/src/test/suite/pipeline/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,9 @@ suite('Pipeline Test Suite', () => {
})
})

it('should add a data series plot', async () => {
it('should add a data series plot when a dvc.yaml file exists', async () => {
const { pipeline } = buildPipeline({
disposer: disposable,
dvcRoot: dvcDemoPath
disposer: disposable
})
const mockPickPlotConfiguration = stub(
PipelineQuickPick,
Expand All @@ -340,7 +339,7 @@ suite('Pipeline Test Suite', () => {

await pipeline.addDataSeriesPlot()

expect(mockPickPlotConfiguration).to.be.calledOnce
expect(mockPickPlotConfiguration).to.be.calledOnceWithExactly(dvcDemoPath)
expect(mockAddPlotToDvcFile).not.to.be.called

const mockPlotConfig: PipelineQuickPick.PlotConfigData = {
Expand All @@ -354,8 +353,43 @@ suite('Pipeline Test Suite', () => {

await pipeline.addDataSeriesPlot()

expect(mockPickPlotConfiguration).to.be.calledTwice
expect(mockAddPlotToDvcFile).to.be.called
expect(mockPickPlotConfiguration).to.be.calledWithExactly(dvcDemoPath)
expect(mockAddPlotToDvcFile).to.be.calledOnceWithExactly(
dvcDemoPath,
mockPlotConfig
)
})

it('should add a data series plot without trying to add a missing dvc.yaml file or stage', async () => {
const { pipeline } = buildPipeline({
disposer: disposable,
dvcYamls: []
})
const mockPickPlotConfiguration = stub(
PipelineQuickPick,
'pickPlotConfiguration'
)
const mockAddPlotToDvcFile = stub(FileSystem, 'addPlotToDvcYamlFile')
const mockCheckOrAddPipeline = stub(pipeline, 'checkOrAddPipeline')
const mockPlotConfig: PipelineQuickPick.PlotConfigData = {
template: 'simple',
title: 'Great Plot Name',
x: { 'results.json': ['step'] },
y: { 'results.json': ['acc'] }
}

mockPickPlotConfiguration.onFirstCall().resolves(mockPlotConfig)

await pipeline.isReady()
await pipeline.addDataSeriesPlot()

expect(mockCheckOrAddPipeline, 'should not check for a pipeline stage').not
.to.be.called
expect(mockPickPlotConfiguration).to.be.calledOnceWithExactly(dvcDemoPath)
expect(mockAddPlotToDvcFile).to.be.calledOnceWithExactly(
dvcDemoPath,
mockPlotConfig
)
})

it('should set the appropriate context value when a dvc.yaml is open in the active editor', async () => {
Expand Down
8 changes: 4 additions & 4 deletions extension/src/test/suite/plots/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ suite('Plots Test Suite', () => {
RegisteredCommands.PLOTS_CUSTOM_REMOVE,
dvcDemoPath
)
})
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should handle an update smooth plot values message from the webview', async () => {
const { mockMessageReceived, plotsModel } = await buildPlotsWebview({
Expand Down Expand Up @@ -1195,7 +1195,7 @@ suite('Plots Test Suite', () => {
templatePlot.id,
0.5
)
})
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should handle an update comparison multi plot value message from the webview', async () => {
const { mockMessageReceived, plotsModel } = await buildPlotsWebview({
Expand Down Expand Up @@ -1231,7 +1231,7 @@ suite('Plots Test Suite', () => {
multiImg.path,
5
)
})
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should handle an add plot message from the webview', async () => {
const { mockMessageReceived } = await buildPlotsWebview({
Expand All @@ -1249,7 +1249,7 @@ suite('Plots Test Suite', () => {
RegisteredCommands.ADD_PLOT,
dvcDemoPath
)
})
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should handle the CLI throwing an error', async () => {
const { data, errorsModel, mockPlotsDiff, plots, plotsModel } =
Expand Down
2 changes: 1 addition & 1 deletion languageServer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test": "jest --collect-coverage"
},
"devDependencies": {
"@swc/core": "1.3.93",
"@swc/core": "1.3.94",
"@swc/jest": "0.2.29",
"@types/jest": "29.5.6",
"clean-webpack-plugin": "4.0.0",
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@
"@typescript-eslint/eslint-plugin": "6.8.0",
"@typescript-eslint/parser": "6.8.0",
"@vscode/codicons": "0.0.33",
"eslint": "8.51.0",
"eslint": "8.52.0",
"eslint-config-prettier": "9.0.0",
"eslint-config-prettier-standard": "4.0.1",
"eslint-config-standard": "17.1.0",
"eslint-plugin-check-file": "2.6.2",
"eslint-plugin-etc": "2.0.3",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jest": "27.4.2",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jest": "27.4.3",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-n": "16.2.0",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-sonarjs": "0.21.0",
Expand All @@ -62,12 +63,12 @@
"prettier": "3.0.3",
"prettier-config-standard": "7.0.0",
"ts-node": "10.9.1",
"turbo": "1.10.15",
"turbo": "1.10.16",
"typescript": "5.2.2"
},
"resolutions": {
"decode-uri-component": "0.2.2",
"@types/react": "18.2.29",
"@types/react": "18.2.31",
"**/recursive-readdir/minimatch": "6.2.0",
"fastify": "3.29.5",
"json5": "2.2.3",
Expand Down
Loading

0 comments on commit 8afc581

Please sign in to comment.