-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add upgrade dvc button to setup when incompatible #3904
Changes from all commits
13e63af
13a75dc
46beaf6
fcd20dc
3b17f3e
3e9dcc4
3ad14eb
61ea789
649a3f4
f84d969
8c899d9
ebba807
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,31 @@ export const findPythonBinForInstall = async (): Promise< | |
) | ||
} | ||
|
||
const showUpgradeProgress = ( | ||
root: string, | ||
pythonBinPath: string | ||
): Thenable<unknown> => | ||
Toast.showProgress('Upgrading DVC', async progress => { | ||
progress.report({ increment: 0 }) | ||
|
||
progress.report({ increment: 25, message: 'Updating packages...' }) | ||
|
||
try { | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await Toast.runCommandAndIncrementProgress( | ||
async () => { | ||
await installPackages(root, pythonBinPath, 'dvc') | ||
return 'Upgraded successfully' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assumption here is that the user used pip to install DVC which isn't necessarily true. I think this is fine but we should add a quantifier to the button as an interim solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good idea! I'll be opening an issue soon detailing what can be improved with how we handle the installation of DVC and will be sure to mention this. Out of scope, but we should probably add a quantifier to our "Install" button as well. Same issue with it assuming the use of |
||
}, | ||
progress, | ||
75 | ||
) | ||
|
||
return Toast.delayProgressClosing() | ||
} catch (error: unknown) { | ||
return Toast.reportProgressError(error, progress) | ||
} | ||
}) | ||
|
||
const showInstallProgress = ( | ||
root: string, | ||
pythonBinPath: string | ||
|
@@ -52,7 +77,9 @@ const showInstallProgress = ( | |
} | ||
}) | ||
|
||
export const autoInstallDvc = async (): Promise<unknown> => { | ||
const getArgsAndRunCommand = async ( | ||
command: (root: string, pythonBinPath: string) => Thenable<unknown> | ||
): Promise<unknown> => { | ||
const pythonBinPath = await findPythonBinForInstall() | ||
const root = getFirstWorkspaceFolder() | ||
|
||
|
@@ -68,5 +95,13 @@ export const autoInstallDvc = async (): Promise<unknown> => { | |
) | ||
} | ||
|
||
return showInstallProgress(root, pythonBinPath) | ||
return command(root, pythonBinPath) | ||
} | ||
|
||
export const autoInstallDvc = (): Promise<unknown> => { | ||
return getArgsAndRunCommand(showInstallProgress) | ||
} | ||
|
||
export const autoUpgradeDvc = (): Promise<unknown> => { | ||
return getArgsAndRunCommand(showUpgradeProgress) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
import React, { PropsWithChildren } from 'react' | ||
import { useSelector } from 'react-redux' | ||
import styles from './styles.module.scss' | ||
import { EmptyState } from '../../../shared/components/emptyState/EmptyState' | ||
import { Button } from '../../../shared/components/button/Button' | ||
import { checkCompatibility } from '../messages' | ||
import { checkCompatibility, upgradeDvc } from '../messages' | ||
import { SetupState } from '../../store' | ||
|
||
export const CliIncompatible: React.FC<PropsWithChildren> = ({ children }) => ( | ||
<EmptyState isFullScreen={false}> | ||
<div> | ||
<h1>DVC is incompatible</h1> | ||
{children} | ||
export const CliIncompatible: React.FC<PropsWithChildren> = ({ children }) => { | ||
const pythonBinPath = useSelector( | ||
(state: SetupState) => state.dvc.pythonBinPath | ||
) | ||
const canUpgrade = !!pythonBinPath | ||
|
||
const conditionalContents = canUpgrade ? ( | ||
<> | ||
<div className={styles.sideBySideButtons}> | ||
<Button onClick={upgradeDvc} text="Upgrade (pip)" /> | ||
<Button text="Check Compatibility" onClick={checkCompatibility} /> | ||
</div> | ||
</> | ||
) : ( | ||
<> | ||
<p>Please update your install and try again.</p> | ||
<Button text="Check Compatibility" onClick={checkCompatibility} /> | ||
</div> | ||
</EmptyState> | ||
) | ||
</> | ||
) | ||
|
||
return ( | ||
<EmptyState isFullScreen={false}> | ||
<div> | ||
<h1>DVC is incompatible</h1> | ||
{children} | ||
{conditionalContents} | ||
</div> | ||
</EmptyState> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might not need a progress bar since's it's essentially going from 0 to 100. I kept it since it looked good when I was testing but we also could just show two toasts, "Upgrading DVC" and "Upgraded Successfully" 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at this:
vscode-dvc/extension/src/experiments/commands/index.ts
Lines 58 to 77 in e95cc0e
Can start by making a small increment and then updating again afterwards. That gives the impression to the user that something is happening. Doesn't have to be super accurate until he have a way to give discrete progress updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! Looks better, thanks :)