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

Show DVC Cli Details in DVC Setup #3688

Merged
merged 25 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
83bd304
Pass dvc cli details the front end
julieg18 Apr 14, 2023
c9a0811
Fix vscode tests
julieg18 Apr 14, 2023
395ac9b
wip for front end
julieg18 Apr 17, 2023
c680243
Add WIP frontend design
julieg18 Apr 17, 2023
c8431f4
Add details as a constand and TODO LIST
julieg18 Apr 18, 2023
f55ad95
Resolve comments and clean up
julieg18 Apr 18, 2023
c2afb03
Add frontend tests
julieg18 Apr 18, 2023
8326528
Fix error being thrown in vscode tests
julieg18 Apr 18, 2023
ddb69c4
cleanup
julieg18 Apr 18, 2023
489a372
Merge branch 'main' into show-dvc-cli-details-in-setup
julieg18 Apr 20, 2023
3aba346
new design
julieg18 Apr 20, 2023
6a4f092
Adjust based off feedback
julieg18 Apr 21, 2023
0c7a6eb
Merge branch 'main' into show-dvc-cli-details-in-setup
julieg18 Apr 21, 2023
38764a5
Clean up and add jest tests
julieg18 Apr 24, 2023
48eb1ea
Fix vscode tests
julieg18 Apr 25, 2023
1fdda0e
Cleanup after reviewing code
julieg18 Apr 25, 2023
a372d10
Merge branch 'main' into show-dvc-cli-details-in-setup
julieg18 Apr 25, 2023
5e9ef87
Merge branch 'main' into show-dvc-cli-details-in-setup
julieg18 Apr 26, 2023
12f8500
Break up components and use PropsWithChildren
julieg18 Apr 26, 2023
074d796
Fix typo and bugs
julieg18 Apr 26, 2023
165f3e9
Fix bug
julieg18 Apr 26, 2023
212c8a4
Commit missed file
julieg18 Apr 26, 2023
a05091b
Renaming stuff
julieg18 Apr 26, 2023
d9662cc
Add back "Select Python Interpreter"
julieg18 Apr 27, 2023
a303201
Merge branch 'main' into show-dvc-cli-details-in-setup
julieg18 Apr 27, 2023
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
38 changes: 35 additions & 3 deletions extension/src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
} from 'vscode'
import { Disposable, Disposer } from '@hediet/std/disposable'
import isEmpty from 'lodash.isempty'
import { SetupSection, SetupData as TSetupData } from './webview/contract'
import {
DvcCliDetails,
SetupSection,
SetupData as TSetupData
} from './webview/contract'
import { collectSectionCollapsed } from './collect'
import { WebviewMessages } from './webview/messages'
import { validateTokenInput } from './inputBox'
Expand All @@ -20,7 +24,6 @@ import { BaseWebview } from '../webview'
import { ViewKey } from '../webview/constants'
import { BaseRepository } from '../webview/repository'
import { Resource } from '../resourceLocator'
import { isPythonExtensionInstalled } from '../extensions/python'
import {
findAbsoluteDvcRootPath,
findDvcRootPaths,
Expand Down Expand Up @@ -52,6 +55,7 @@ import { GLOBAL_WEBVIEW_DVCROOT } from '../webview/factory'
import { ConfigKey, getConfigValue } from '../vscode/config'
import { getValidInput } from '../vscode/inputBox'
import { Title } from '../vscode/title'
import { getOptions } from '../cli/dvc/options'

export type SetupWebviewWebview = BaseWebview<TSetupData>

Expand Down Expand Up @@ -334,10 +338,34 @@ export class Setup
return this.sendDataToWebview()
}

public async getDvcCliDetails(): Promise<DvcCliDetails> {
const dvcPath = this.config.getCliPath()
const pythonBinPath = this.config.getPythonBinPath()
const cwd = getFirstWorkspaceFolder()

const { args, executable } = getOptions(pythonBinPath, dvcPath, cwd || '')
const commandArgs = args.length === 0 ? '' : ` ${args.join(' ')}`
const command = executable + commandArgs

return {
command,
version: cwd ? await this.getCliVersion(cwd) : undefined
}
}

private isDVCBeingUsedGlobally() {
const dvcPath = this.config.getCliPath()
const pythonBinPath = this.config.getPythonBinPath()

return dvcPath || !pythonBinPath
}

private async sendDataToWebview() {
const projectInitialized = this.hasRoots()
const hasData = this.getHasData()

const isPythonExtensionUsed = await this.isPythonExtensionUsed()

const needsGitInitialized =
!projectInitialized && !!(await this.needsGitInit())

Expand All @@ -348,11 +376,15 @@ export class Setup

const pythonBinPath = await findPythonBinForInstall()

const dvcCliDetails = await this.getDvcCliDetails()

this.webviewMessages.sendWebviewMessage({
canGitInitialize,
cliCompatible: this.cliCompatible,
dvcCliDetails,
hasData,
isPythonExtensionInstalled: isPythonExtensionInstalled(),
isPythonExtensionUsed:
!this.isDVCBeingUsedGlobally() && isPythonExtensionUsed,
isStudioConnected: this.studioIsConnected,
needsGitCommit,
needsGitInitialized,
Expand Down
8 changes: 7 additions & 1 deletion extension/src/setup/webview/contract.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
export type DvcCliDetails = {
command: string
version: string | undefined
}

export type SetupData = {
canGitInitialize: boolean
cliCompatible: boolean | undefined
dvcCliDetails: DvcCliDetails
hasData: boolean | undefined
isPythonExtensionInstalled: boolean
isPythonExtensionUsed: boolean
isStudioConnected: boolean
needsGitCommit: boolean
needsGitInitialized: boolean | undefined
Expand Down
6 changes: 4 additions & 2 deletions extension/src/setup/webview/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export class WebviewMessages {
public sendWebviewMessage({
canGitInitialize,
cliCompatible,
dvcCliDetails,
hasData,
isPythonExtensionInstalled,
isPythonExtensionUsed,
isStudioConnected,
needsGitCommit,
needsGitInitialized,
Expand All @@ -48,8 +49,9 @@ export class WebviewMessages {
void this.getWebview()?.show({
canGitInitialize,
cliCompatible,
dvcCliDetails,
hasData,
isPythonExtensionInstalled,
isPythonExtensionUsed,
isStudioConnected,
needsGitCommit,
needsGitInitialized,
Expand Down
22 changes: 18 additions & 4 deletions extension/src/test/suite/setup/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ suite('Setup Test Suite', () => {
setup.setCliCompatible(undefined)
julieg18 marked this conversation as resolved.
Show resolved Hide resolved
setup.setAvailable(false)
await setup.setRoots()
stub(setup, 'getCliVersion').resolves(undefined)

messageSpy.restore()
const mockSendMessage = stub(BaseWebview.prototype, 'show')
Expand All @@ -238,8 +239,9 @@ suite('Setup Test Suite', () => {
expect(mockSendMessage).to.be.calledWithExactly({
canGitInitialize: true,
cliCompatible: undefined,
dvcCliDetails: { command: 'dvc', version: undefined },
hasData: false,
isPythonExtensionInstalled: false,
isPythonExtensionUsed: false,
isStudioConnected: false,
needsGitCommit: true,
needsGitInitialized: true,
Expand Down Expand Up @@ -278,8 +280,9 @@ suite('Setup Test Suite', () => {
expect(mockSendMessage).to.be.calledWithExactly({
canGitInitialize: true,
cliCompatible: true,
dvcCliDetails: { command: 'dvc', version: MIN_CLI_VERSION },
hasData: false,
isPythonExtensionInstalled: false,
isPythonExtensionUsed: false,
isStudioConnected: false,
needsGitCommit: true,
needsGitInitialized: true,
Expand Down Expand Up @@ -324,8 +327,12 @@ suite('Setup Test Suite', () => {
expect(mockSendMessage).to.be.calledWithExactly({
canGitInitialize: false,
cliCompatible: true,
dvcCliDetails: {
command: 'dvc',
version: MIN_CLI_VERSION
},
hasData: false,
isPythonExtensionInstalled: false,
isPythonExtensionUsed: false,
isStudioConnected: false,
needsGitCommit: false,
needsGitInitialized: false,
Expand Down Expand Up @@ -370,8 +377,12 @@ suite('Setup Test Suite', () => {
expect(mockSendMessage).to.be.calledWithExactly({
canGitInitialize: false,
cliCompatible: true,
dvcCliDetails: {
command: 'dvc',
version: MIN_CLI_VERSION
},
hasData: false,
isPythonExtensionInstalled: false,
isPythonExtensionUsed: false,
isStudioConnected: false,
needsGitCommit: true,
needsGitInitialized: false,
Expand Down Expand Up @@ -568,6 +579,7 @@ suite('Setup Test Suite', () => {
mockRunSetup.restore()
stub(config, 'isPythonExtensionUsed').returns(false)
stub(config, 'getPythonBinPath').resolves(join('python'))
stub(setup, 'getDvcCliDetails').resolves(undefined)

mockVersion.resetBehavior()
mockVersion
Expand Down Expand Up @@ -627,6 +639,7 @@ suite('Setup Test Suite', () => {
mockExecuteCommand.restore()
mockRunSetup.restore()
stub(config, 'isPythonExtensionUsed').returns(true)
stub(setup, 'getDvcCliDetails').resolves(undefined)

mockVersion.resetBehavior()
mockVersion.rejects(new Error('no CLI here'))
Expand Down Expand Up @@ -762,6 +775,7 @@ suite('Setup Test Suite', () => {
const mockUpdate = stub()

stub(workspace, 'getConfiguration').returns({
get: stub(),
update: mockUpdate
} as unknown as WorkspaceConfiguration)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,13 +836,9 @@ $badge-size: 0.85rem;
// below table styles

.buttonAsLink {
@extend %link;
@extend %buttonAsLink;

background: none;
border: none;
padding: 0;
font-size: 0.65rem;
cursor: pointer;
}

.addConfigButton {
Expand Down
Loading