Skip to content

Commit

Permalink
Merge branch 'main' into rename-share-command
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed May 1, 2023
2 parents 4a5f1e0 + 03019fb commit 82ea04a
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 46 deletions.
42 changes: 25 additions & 17 deletions extension/src/setup/autoInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,33 @@ const showInstallProgress = (
Toast.showProgress('Installing packages', async progress => {
progress.report({ increment: 0 })

await Toast.runCommandAndIncrementProgress(
async () => {
await installPackages(root, pythonBinPath, 'dvclive')
return 'DVCLive Installed'
},
progress,
25
)
try {
await Toast.runCommandAndIncrementProgress(
async () => {
await installPackages(root, pythonBinPath, 'dvclive')
return 'DVCLive Installed'
},
progress,
25
)
} catch (error: unknown) {
return Toast.reportProgressError(error, progress)
}

await Toast.runCommandAndIncrementProgress(
async () => {
await installPackages(root, pythonBinPath, 'dvc')
return 'DVC Installed'
},
progress,
75
)
try {
await Toast.runCommandAndIncrementProgress(
async () => {
await installPackages(root, pythonBinPath, 'dvc')
return 'DVC Installed'
},
progress,
75
)

return Toast.delayProgressClosing()
return Toast.delayProgressClosing()
} catch (error: unknown) {
return Toast.reportProgressError(error, progress)
}
})

export const autoInstallDvc = async (): Promise<unknown> => {
Expand Down
60 changes: 60 additions & 0 deletions extension/src/test/suite/setup/autoInstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Python from '../../../python'
import { autoInstallDvc } from '../../../setup/autoInstall'
import * as WorkspaceFolders from '../../../vscode/workspaceFolders'
import { bypassProgressCloseDelay } from '../util'
import { Toast } from '../../../vscode/toast'

const { getDefaultPython } = Python

Expand Down Expand Up @@ -89,5 +90,64 @@ suite('Auto Install Test Suite', () => {
'dvclive'
)
})

it('should show an error message and exit early if DVCLive fails to install', async () => {
bypassProgressCloseDelay()
const cwd = __dirname
stub(PythonExtension, 'getPythonExecutionDetails').resolves(undefined)
stub(Python, 'findPythonBin').resolves(defaultPython)
const mockInstallPackages = stub(Python, 'installPackages').rejects(
new Error('Failed to install DVCLive')
)
stub(WorkspaceFolders, 'getFirstWorkspaceFolder').returns(cwd)

const showProgressSpy = spy(window, 'withProgress')
const showErrorSpy = spy(window, 'showErrorMessage')

await autoInstallDvc()

expect(showProgressSpy).to.be.called
expect(showErrorSpy).not.to.be.called
expect(mockInstallPackages).to.be.calledOnce
expect(mockInstallPackages).to.be.calledWithExactly(
cwd,
defaultPython,
'dvclive'
)
})

it('should show an error message if DVC fails to install', async () => {
bypassProgressCloseDelay()
const cwd = __dirname
stub(PythonExtension, 'getPythonExecutionDetails').resolves(undefined)
stub(Python, 'findPythonBin').resolves(defaultPython)
const mockInstallPackages = stub(Python, 'installPackages')
.onFirstCall()
.resolves(undefined)
.onSecondCall()
.rejects(new Error('Network error'))
stub(WorkspaceFolders, 'getFirstWorkspaceFolder').returns(cwd)

const showProgressSpy = spy(window, 'withProgress')
const showErrorSpy = spy(window, 'showErrorMessage')
const reportProgressErrorSpy = spy(Toast, 'reportProgressError')

await autoInstallDvc()

expect(showProgressSpy).to.be.called
expect(showErrorSpy).not.to.be.called
expect(reportProgressErrorSpy).to.be.calledOnce
expect(mockInstallPackages).to.be.calledTwice
expect(mockInstallPackages).to.be.calledWithExactly(
cwd,
defaultPython,
'dvclive'
)
expect(mockInstallPackages).to.be.calledWithExactly(
cwd,
defaultPython,
'dvc'
)
})
})
})
16 changes: 16 additions & 0 deletions extension/src/vscode/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ export class Toast {
})
}

static reportProgressError(
error: unknown,
progress: Progress<{
message?: string | undefined
increment?: number | undefined
}>
) {
const message = (error as Error)?.message || 'an unexpected error occurred'

progress.report({
increment: 0,
message
})
return Toast.delayProgressClosing(60000)
}

static delayProgressClosing(ms = 5000) {
return delay(ms)
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"svgr": "yarn workspace dvc-vscode-webview svgr"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "5.59.0",
"@typescript-eslint/parser": "5.59.0",
"@typescript-eslint/eslint-plugin": "5.59.1",
"@typescript-eslint/parser": "5.59.1",
"@vscode/codicons": "0.0.32",
"eslint": "8.39.0",
"eslint-config-prettier": "8.8.0",
Expand Down
102 changes: 75 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5513,15 +5513,15 @@
dependencies:
"@types/node" "*"

"@typescript-eslint/[email protected].0":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.0.tgz#c0e10eeb936debe5d1c3433cf36206a95befefd0"
integrity sha512-p0QgrEyrxAWBecR56gyn3wkG15TJdI//eetInP3zYRewDh0XS+DhB3VUAd3QqvziFsfaQIoIuZMxZRB7vXYaYw==
"@typescript-eslint/[email protected].1":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.1.tgz#9b09ee1541bff1d2cebdcb87e7ce4a4003acde08"
integrity sha512-AVi0uazY5quFB9hlp2Xv+ogpfpk77xzsgsIEWyVS7uK/c7MZ5tw7ZPbapa0SbfkqE0fsAMkz5UwtgMLVk2BQAg==
dependencies:
"@eslint-community/regexpp" "^4.4.0"
"@typescript-eslint/scope-manager" "5.59.0"
"@typescript-eslint/type-utils" "5.59.0"
"@typescript-eslint/utils" "5.59.0"
"@typescript-eslint/scope-manager" "5.59.1"
"@typescript-eslint/type-utils" "5.59.1"
"@typescript-eslint/utils" "5.59.1"
debug "^4.3.4"
grapheme-splitter "^1.0.4"
ignore "^5.2.0"
Expand All @@ -5536,14 +5536,14 @@
dependencies:
"@typescript-eslint/utils" "5.25.0"

"@typescript-eslint/[email protected].0":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.59.0.tgz#0ad7cd019346cc5d150363f64869eca10ca9977c"
integrity sha512-qK9TZ70eJtjojSUMrrEwA9ZDQ4N0e/AuoOIgXuNBorXYcBDk397D2r5MIe1B3cok/oCtdNC5j+lUUpVB+Dpb+w==
"@typescript-eslint/[email protected].1":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.59.1.tgz#73c2c12127c5c1182d2e5b71a8fa2a85d215cbb4"
integrity sha512-nzjFAN8WEu6yPRDizIFyzAfgK7nybPodMNFGNH0M9tei2gYnYszRDqVA0xlnRjkl7Hkx2vYrEdb6fP2a21cG1g==
dependencies:
"@typescript-eslint/scope-manager" "5.59.0"
"@typescript-eslint/types" "5.59.0"
"@typescript-eslint/typescript-estree" "5.59.0"
"@typescript-eslint/scope-manager" "5.59.1"
"@typescript-eslint/types" "5.59.1"
"@typescript-eslint/typescript-estree" "5.59.1"
debug "^4.3.4"

"@typescript-eslint/[email protected]":
Expand All @@ -5570,13 +5570,21 @@
"@typescript-eslint/types" "5.59.0"
"@typescript-eslint/visitor-keys" "5.59.0"

"@typescript-eslint/type-utils@5.59.0":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.0.tgz#8e8d1420fc2265989fa3a0d897bde37f3851e8c9"
integrity sha512-d/B6VSWnZwu70kcKQSCqjcXpVH+7ABKH8P1KNn4K7j5PXXuycZTPXF44Nui0TEm6rbWGi8kc78xRgOC4n7xFgA==
"@typescript-eslint/scope-manager@5.59.1":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.1.tgz#8a20222719cebc5198618a5d44113705b51fd7fe"
integrity sha512-mau0waO5frJctPuAzcxiNWqJR5Z8V0190FTSqRw1Q4Euop6+zTwHAf8YIXNwDOT29tyUDrQ65jSg9aTU/H0omA==
dependencies:
"@typescript-eslint/typescript-estree" "5.59.0"
"@typescript-eslint/utils" "5.59.0"
"@typescript-eslint/types" "5.59.1"
"@typescript-eslint/visitor-keys" "5.59.1"

"@typescript-eslint/[email protected]":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.1.tgz#63981d61684fd24eda2f9f08c0a47ecb000a2111"
integrity sha512-ZMWQ+Oh82jWqWzvM3xU+9y5U7MEMVv6GLioM3R5NJk6uvP47kZ7YvlgSHJ7ERD6bOY7Q4uxWm25c76HKEwIjZw==
dependencies:
"@typescript-eslint/typescript-estree" "5.59.1"
"@typescript-eslint/utils" "5.59.1"
debug "^4.3.4"
tsutils "^3.21.0"

Expand All @@ -5595,6 +5603,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.0.tgz#3fcdac7dbf923ec5251545acdd9f1d42d7c4fe32"
integrity sha512-yR2h1NotF23xFFYKHZs17QJnB51J/s+ud4PYU4MqdZbzeNxpgUr05+dNeCN/bb6raslHvGdd6BFCkVhpPk/ZeA==

"@typescript-eslint/[email protected]":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.1.tgz#03f3fedd1c044cb336ebc34cc7855f121991f41d"
integrity sha512-dg0ICB+RZwHlysIy/Dh1SP+gnXNzwd/KS0JprD3Lmgmdq+dJAJnUPe1gNG34p0U19HvRlGX733d/KqscrGC1Pg==

"@typescript-eslint/[email protected]":
version "5.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.17.0.tgz#a7cba7dfc8f9cc2ac78c18584e684507df4f2488"
Expand Down Expand Up @@ -5634,6 +5647,19 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.1.tgz#4aa546d27fd0d477c618f0ca00b483f0ec84c43c"
integrity sha512-lYLBBOCsFltFy7XVqzX0Ju+Lh3WPIAWxYpmH/Q7ZoqzbscLiCW00LeYCdsUnnfnj29/s1WovXKh2gwCoinHNGA==
dependencies:
"@typescript-eslint/types" "5.59.1"
"@typescript-eslint/visitor-keys" "5.59.1"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
version "5.25.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.25.0.tgz#272751fd737733294b4ab95e16c7f2d4a75c2049"
Expand All @@ -5646,17 +5672,17 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/[email protected].0", "@typescript-eslint/utils@^5.58.0":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.0.tgz#063d066b3bc4850c18872649ed0da9ee72d833d5"
integrity sha512-GGLFd+86drlHSvPgN/el6dRQNYYGOvRSDVydsUaQluwIW3HvbXuxyuD5JETvBt/9qGYe+lOrDk6gRrWOHb/FvA==
"@typescript-eslint/[email protected].1":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.1.tgz#d89fc758ad23d2157cfae53f0b429bdf15db9473"
integrity sha512-MkTe7FE+K1/GxZkP5gRj3rCztg45bEhsd8HYjczBuYm+qFHP5vtZmjx3B0yUCDotceQ4sHgTyz60Ycl225njmA==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@types/json-schema" "^7.0.9"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.59.0"
"@typescript-eslint/types" "5.59.0"
"@typescript-eslint/typescript-estree" "5.59.0"
"@typescript-eslint/scope-manager" "5.59.1"
"@typescript-eslint/types" "5.59.1"
"@typescript-eslint/typescript-estree" "5.59.1"
eslint-scope "^5.1.1"
semver "^7.3.7"

Expand All @@ -5672,6 +5698,20 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/utils@^5.58.0":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.0.tgz#063d066b3bc4850c18872649ed0da9ee72d833d5"
integrity sha512-GGLFd+86drlHSvPgN/el6dRQNYYGOvRSDVydsUaQluwIW3HvbXuxyuD5JETvBt/9qGYe+lOrDk6gRrWOHb/FvA==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@types/json-schema" "^7.0.9"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.59.0"
"@typescript-eslint/types" "5.59.0"
"@typescript-eslint/typescript-estree" "5.59.0"
eslint-scope "^5.1.1"
semver "^7.3.7"

"@typescript-eslint/[email protected]":
version "5.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.17.0.tgz#52daae45c61b0211b4c81b53a71841911e479128"
Expand All @@ -5696,6 +5736,14 @@
"@typescript-eslint/types" "5.59.0"
eslint-visitor-keys "^3.3.0"

"@typescript-eslint/[email protected]":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.1.tgz#0d96c36efb6560d7fb8eb85de10442c10d8f6058"
integrity sha512-6waEYwBTCWryx0VJmP7JaM4FpipLsFl9CvYf2foAE8Qh/Y0s+bxWysciwOs0LTBED4JCaNxTZ5rGadB14M6dwA==
dependencies:
"@typescript-eslint/types" "5.59.1"
eslint-visitor-keys "^3.3.0"

"@ungap/[email protected]":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
Expand Down

0 comments on commit 82ea04a

Please sign in to comment.