Skip to content

Commit efea638

Browse files
committed
Merge branch 'main' into show-exp-show-error
2 parents 1f3f509 + baf45a6 commit efea638

File tree

21 files changed

+405
-246
lines changed

21 files changed

+405
-246
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

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

5+
## [1.0.0] - 2023-06-09
6+
7+
### 🚀 New Features and Enhancements
8+
9+
- Add PYTHONPATH to environment variables if the Python extension makes it available [#4045](https://github.com/iterative/vscode-dvc/pull/4045) by [@mattseddon](https://github.com/mattseddon)
10+
11+
### 🐛 Bug Fixes
12+
13+
- fix(plots): correct the empty screen link to the dvc docs [#4068](https://github.com/iterative/vscode-dvc/pull/4068) by [@shcheklein](https://github.com/shcheklein)
14+
15+
### 🔨 Maintenance
16+
17+
- Fix failing tests [#4070](https://github.com/iterative/vscode-dvc/pull/4070) by [@mattseddon](https://github.com/mattseddon)
18+
519
## [0.9.6] - 2023-06-08
620

721
### 🚀 New Features and Enhancements

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,12 @@ This extension augments VS Code in the following ways:
127127
Open the Command Palette (`F1` or ⇧⌃P on Windows/Linux or ⇧⌘P on macOS) and type
128128
in one of the following commands:
129129

130-
| Command | Description |
131-
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
132-
| `DVC: Get Started` | Open the extension's walkthrough. Which details all of the current features and provides links to extra learning resources. |
133-
| `View: Show DVC` | Open the extension's view container. |
134-
| `DVC: Setup The Workspace` | Activate the extension's workspace setup wizard. |
135-
| `DVC: Show Experiments` | Show an interactive version of DVC's `exp show` [command](https://dvc.org/doc/command-reference/exp/show). |
136-
| `DVC: Show Plots` | Show an interactive version of DVC's `plots diff` [command](https://dvc.org/doc/command-reference/plots/diff). |
130+
| Command | Description |
131+
| ----------------------- | -------------------------------------------------------------------------------------------------------------- |
132+
| `DVC: Show Setup` | Show the extension's setup page. Which can be used to setup the DVC project, view the walkthrough and more. |
133+
| `View: Show DVC` | Open the extension's view container. |
134+
| `DVC: Show Experiments` | Show an interactive version of DVC's `exp show` [command](https://dvc.org/doc/command-reference/exp/show). |
135+
| `DVC: Show Plots` | Show an interactive version of DVC's `plots diff` [command](https://dvc.org/doc/command-reference/plots/diff). |
137136

138137
Learn more about the extension's [commands].
139138

extension/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"extensionDependencies": [
1010
"vscode.git"
1111
],
12-
"version": "0.9.6",
12+
"version": "1.0.0",
1313
"license": "Apache-2.0",
1414
"readme": "./README.md",
1515
"repository": {
@@ -1651,7 +1651,7 @@
16511651
"vscode-languageclient": "8.1.0"
16521652
},
16531653
"devDependencies": {
1654-
"@swc/core": "1.3.61",
1654+
"@swc/core": "1.3.62",
16551655
"@swc/jest": "0.2.26",
16561656
"@types/chai": "4.3.5",
16571657
"@types/chai-as-promised": "7.1.5",
@@ -1675,9 +1675,9 @@
16751675
"@types/vscode": "1.64.0",
16761676
"@vscode/test-electron": "2.3.2",
16771677
"@vscode/vsce": "2.19.0",
1678-
"@wdio/cli": "8.10.6",
1679-
"@wdio/local-runner": "8.10.6",
1680-
"@wdio/mocha-framework": "8.10.6",
1678+
"@wdio/cli": "8.10.7",
1679+
"@wdio/local-runner": "8.10.7",
1680+
"@wdio/mocha-framework": "8.10.7",
16811681
"@wdio/spec-reporter": "8.10.6",
16821682
"chai": "4.3.7",
16831683
"chai-as-promised": "7.1.1",
@@ -1695,9 +1695,9 @@
16951695
"ts-loader": "9.4.3",
16961696
"vscode-uri": "3.0.7",
16971697
"wdio-vscode-service": "5.1.0",
1698-
"webdriverio": "8.10.6",
1699-
"webpack": "5.85.0",
1700-
"webpack-cli": "5.1.1"
1698+
"webdriverio": "8.10.7",
1699+
"webpack": "5.85.1",
1700+
"webpack-cli": "5.1.3"
17011701
},
17021702
"peerDependencies": {
17031703
"typescript": "*"

extension/src/extensions/python.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export const getOnDidChangePythonEnvironmentVariables = async () => {
6868

6969
export const isPythonExtensionInstalled = () => isInstalled(PYTHON_EXTENSION_ID)
7070

71+
export const createPythonEnv = () => {
72+
void commands.executeCommand('python.createEnvironment')
73+
}
74+
7175
export const selectPythonInterpreter = () => {
7276
void commands.executeCommand('python.setInterpreter')
7377
}

extension/src/setup/index.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import { validateTokenInput } from './inputBox'
1313
import { findPythonBinForInstall } from './autoInstall'
1414
import { run, runWithRecheck, runWorkspace } from './runner'
1515
import { isStudioAccessToken } from './token'
16-
import { pickFocusedProjects } from './quickPick'
16+
import {
17+
PYTHON_EXTENSION_ACTION,
18+
pickFocusedProjects,
19+
pickPythonExtensionAction
20+
} from './quickPick'
1721
import { ViewKey } from '../webview/constants'
1822
import { BaseRepository } from '../webview/repository'
1923
import { Resource } from '../resourceLocator'
@@ -56,6 +60,7 @@ import { Title } from '../vscode/title'
5660
import { getDVCAppDir } from '../util/appdirs'
5761
import { getOptions } from '../cli/dvc/options'
5862
import { isAboveLatestTestedVersion } from '../cli/dvc/version'
63+
import { createPythonEnv, selectPythonInterpreter } from '../extensions/python'
5964

6065
export class Setup
6166
extends BaseRepository<TSetupData>
@@ -414,7 +419,8 @@ export class Setup
414419
const webviewMessages = new WebviewMessages(
415420
() => this.getWebview(),
416421
() => this.initializeGit(),
417-
(offline: boolean) => this.updateStudioOffline(offline)
422+
(offline: boolean) => this.updateStudioOffline(offline),
423+
() => this.updatePythonEnvironment()
418424
)
419425
this.dispose.track(
420426
this.onDidReceivedWebviewMessage(message =>
@@ -506,6 +512,18 @@ export class Setup
506512
}
507513
}
508514

515+
private async updatePythonEnvironment() {
516+
const value = await pickPythonExtensionAction()
517+
518+
if (!value) {
519+
return
520+
}
521+
522+
return value === PYTHON_EXTENSION_ACTION.CREATE_ENV
523+
? createPythonEnv()
524+
: selectPythonInterpreter()
525+
}
526+
509527
private needsGitCommit(needsGitInit: boolean) {
510528
if (needsGitInit) {
511529
return true

extension/src/setup/quickPick.test.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { join } from 'path'
2-
import { pickFocusedProjects } from './quickPick'
3-
import { quickPickManyValues } from '../vscode/quickPick'
2+
import {
3+
PYTHON_EXTENSION_ACTION,
4+
pickFocusedProjects,
5+
pickPythonExtensionAction
6+
} from './quickPick'
7+
import { quickPickManyValues, quickPickValue } from '../vscode/quickPick'
48
import { Toast } from '../vscode/toast'
59
import { Title } from '../vscode/title'
610

711
jest.mock('../vscode/quickPick')
812

913
const mockedQuickPickManyValues = jest.mocked(quickPickManyValues)
14+
const mockedQuickValue = jest.mocked(quickPickValue)
1015

1116
const mockedToast = jest.mocked(Toast)
1217
const mockedShowError = jest.fn()
@@ -55,3 +60,28 @@ describe('pickFocusedProjects', () => {
5560
)
5661
})
5762
})
63+
64+
describe('pickPythonExtensionAction', () => {
65+
it('should call a quick pick with the correct values', () => {
66+
void pickPythonExtensionAction()
67+
68+
expect(mockedQuickValue).toHaveBeenCalledWith(
69+
[
70+
{
71+
description: 'Create an environment',
72+
label: 'Create',
73+
value: PYTHON_EXTENSION_ACTION.CREATE_ENV
74+
},
75+
{
76+
description: 'Choose from already created environments',
77+
label: 'Select',
78+
value: PYTHON_EXTENSION_ACTION.SET_INTERPRETER
79+
}
80+
],
81+
{
82+
placeHolder: 'Select or Create a Python Environment',
83+
title: Title.UPDATE_PYTHON_ENVIRONMENT
84+
}
85+
)
86+
})
87+
})

extension/src/setup/quickPick.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { sortCollectedArray } from '../util/array'
2-
import { quickPickManyValues } from '../vscode/quickPick'
2+
import { quickPickManyValues, quickPickValue } from '../vscode/quickPick'
33
import { Title } from '../vscode/title'
44
import { Toast } from '../vscode/toast'
55

6+
export enum PYTHON_EXTENSION_ACTION {
7+
CREATE_ENV = 1,
8+
SET_INTERPRETER = 2
9+
}
10+
611
export const pickFocusedProjects = async (
712
projects: string[],
813
currentProjects: string[]
@@ -26,3 +31,24 @@ export const pickFocusedProjects = async (
2631

2732
return sortCollectedArray(values)
2833
}
34+
35+
export const pickPythonExtensionAction = (): Thenable<
36+
PYTHON_EXTENSION_ACTION | undefined
37+
> => {
38+
const options = [
39+
{
40+
description: 'Create an environment',
41+
label: 'Create',
42+
value: PYTHON_EXTENSION_ACTION.CREATE_ENV
43+
},
44+
{
45+
description: 'Choose from already created environments',
46+
label: 'Select',
47+
value: PYTHON_EXTENSION_ACTION.SET_INTERPRETER
48+
}
49+
]
50+
return quickPickValue<PYTHON_EXTENSION_ACTION>(options, {
51+
placeHolder: 'Select or Create a Python Environment',
52+
title: Title.UPDATE_PYTHON_ENVIRONMENT
53+
})
54+
}

extension/src/setup/webview/messages.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import { BaseWebview } from '../../webview'
99
import { sendTelemetryEvent } from '../../telemetry'
1010
import { EventName } from '../../telemetry/constants'
11-
import { selectPythonInterpreter } from '../../extensions/python'
1211
import { autoInstallDvc, autoUpgradeDvc } from '../autoInstall'
1312
import {
1413
RegisteredCliCommands,
@@ -20,15 +19,18 @@ export class WebviewMessages {
2019
private readonly getWebview: () => BaseWebview<TSetupData> | undefined
2120
private readonly initializeGit: () => void
2221
private readonly updateStudioOffline: (offline: boolean) => Promise<void>
22+
private readonly updatePythonEnv: () => Promise<void>
2323

2424
constructor(
2525
getWebview: () => BaseWebview<TSetupData> | undefined,
2626
initializeGit: () => void,
27-
updateStudioOffline: (shareLive: boolean) => Promise<void>
27+
updateStudioOffline: (shareLive: boolean) => Promise<void>,
28+
updatePythonEnv: () => Promise<void>
2829
) {
2930
this.getWebview = getWebview
3031
this.initializeGit = initializeGit
3132
this.updateStudioOffline = updateStudioOffline
33+
this.updatePythonEnv = updatePythonEnv
3234
}
3335

3436
public sendWebviewMessage(data: SetupData) {
@@ -49,8 +51,8 @@ export class WebviewMessages {
4951
return commands.executeCommand(RegisteredCommands.EXTENSION_GET_STARTED)
5052
case MessageFromWebviewType.SHOW_SCM_PANEL:
5153
return this.showScmForCommit()
52-
case MessageFromWebviewType.SELECT_PYTHON_INTERPRETER:
53-
return this.selectPythonInterpreter()
54+
case MessageFromWebviewType.UPDATE_PYTHON_ENVIRONMENT:
55+
return this.updatePythonEnvironment()
5456
case MessageFromWebviewType.INSTALL_DVC:
5557
return this.installDvc()
5658
case MessageFromWebviewType.UPGRADE_DVC:
@@ -101,13 +103,13 @@ export class WebviewMessages {
101103
return commands.executeCommand('workbench.view.scm')
102104
}
103105

104-
private selectPythonInterpreter() {
106+
private updatePythonEnvironment() {
105107
sendTelemetryEvent(
106-
EventName.VIEWS_SETUP_SELECT_PYTHON_INTERPRETER,
108+
EventName.VIEWS_SETUP_UPDATE_PYTHON_ENVIRONMENT,
107109
undefined,
108110
undefined
109111
)
110-
return selectPythonInterpreter()
112+
return this.updatePythonEnv()
111113
}
112114

113115
private upgradeDvc() {

extension/src/telemetry/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ export const EventName = Object.assign(
8686
VIEWS_SETUP_FOCUS_CHANGED: 'views.setup.focusChanged',
8787
VIEWS_SETUP_INIT_GIT: 'views.setup.initializeGit',
8888
VIEWS_SETUP_INSTALL_DVC: 'views.setup.installDvc',
89-
VIEWS_SETUP_SELECT_PYTHON_INTERPRETER:
90-
'views.setup.selectPythonInterpreter',
9189
VIEWS_SETUP_SHOW_SCM_FOR_COMMIT: 'views.setup.showScmForCommit',
90+
VIEWS_SETUP_UPDATE_PYTHON_ENVIRONMENT:
91+
'views.setup.updatePythonEnvironment',
9292
VIEWS_SETUP_UPGRADE_DVC: 'view.setup.upgradeDvc',
9393

9494
VIEWS_TERMINAL_CLOSED: 'views.terminal.closed',
@@ -279,7 +279,7 @@ export interface IEventNamePropertyMapping {
279279
[EventName.VIEWS_SETUP_CLOSE]: undefined
280280
[EventName.VIEWS_SETUP_CREATED]: undefined
281281
[EventName.VIEWS_SETUP_FOCUS_CHANGED]: undefined
282-
[EventName.VIEWS_SETUP_SELECT_PYTHON_INTERPRETER]: undefined
282+
[EventName.VIEWS_SETUP_UPDATE_PYTHON_ENVIRONMENT]: undefined
283283
[EventName.VIEWS_SETUP_SHOW_SCM_FOR_COMMIT]: undefined
284284
[EventName.VIEWS_SETUP_INIT_GIT]: undefined
285285
[EventName.VIEWS_SETUP_INSTALL_DVC]: undefined

extension/src/test/cli/util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { DOT_DVC } from '../../cli/dvc/constants'
1111

1212
const config = {
1313
getCliPath: () => '',
14+
getPYTHONPATH: () => undefined,
1415
getPythonBinPath: () => getVenvBinPath(TEMP_DIR, ENV_DIR, 'python')
1516
} as Config
1617

0 commit comments

Comments
 (0)