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

Notebooks: Fix pip installation not working #14506

Merged
merged 6 commits into from
Mar 4, 2021
Merged

Conversation

lucyzhang929
Copy link
Contributor

@lucyzhang929 lucyzhang929 commented Mar 2, 2021

This PR fixes #14192

@coveralls
Copy link

coveralls commented Mar 2, 2021

Pull Request Test Coverage Report for Build 619335460

  • 0 of 5 (0.0%) changed or added relevant lines in 1 file are covered.
  • 335 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.01%) to 43.123%

Changes Missing Coverage Covered Lines Changed/Added Lines %
extensions/notebook/src/jupyter/jupyterServerInstallation.ts 0 5 0.0%
Files with Coverage Reduction New Missed Lines %
extensions/sql-database-projects/src/tools/newProjectTool.ts 1 95.24%
extensions/sql-database-projects/src/common/utils.ts 2 88.37%
src/sql/workbench/contrib/notebook/browser/cellViews/codeCell.component.ts 26 14.52%
extensions/sql-database-projects/src/dialogs/createProjectFromDatabaseDialog.ts 33 62.96%
extensions/notebook/src/book/bookTocManager.ts 40 71.05%
src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts 110 3.3%
extensions/arc/src/ui/dashboards/postgres/postgresComputeAndStoragePage.ts 123 1.26%
Totals Coverage Status
Change from base Build 615521359: -0.01%
Covered Lines: 25093
Relevant Lines: 53228

💛 - Coveralls

@chlafreniere
Copy link
Contributor

@corivera what are your thoughts here? My concerns are that a potential pip upgrade in the future could potentially break us and leave our users broken. Maybe we should make this as a setting?

@lucyzhang929
Copy link
Contributor Author

I found this old issue #8204 (comment) that is somewhat related. @corivera you mentioned in your comment that we already reconfigure pip at the end of our python install process. Where in the code do we do that? Or was that changed at some point?

@corivera
Copy link
Member

corivera commented Mar 3, 2021

I looked around in the install code and I couldn't find where we do a pip reinstall. We might have cleaned that up when we got rid of forced package reinstalls, since that could disrupt a user's locally installed pip packages

@corivera
Copy link
Member

corivera commented Mar 3, 2021

We should also take a look at upgrading our provided python package. Those bits might be too out of date at this point. The latest version of pandas can't be installed on Python 3.6, for example.

@chlafreniere
Copy link
Contributor

We should also take a look at upgrading our provided python package. Those bits might be too out of date at this point. The latest version of pandas can't be installed on Python 3.6, for example.

Yes please 😻

@@ -166,6 +166,9 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
if (!pythonExists || forceInstall) {
await this.installPythonPackage(backgroundOperation, this._usingExistingPython, this._pythonInstallationPath, this.outputChannel);
}
// upgrade pip to make sure the right version is installed
let cmd = `"${this._pythonExecutable}" -m pip install --upgrade pip`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this only affects the New Install option, should we skip this upgrade when _usingExistingPython is true? We wouldn't want to force upgrade a user's pip packages as a side effect of another install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense.

if (!this._usingExistingPython) {
let versionCmd = `"${this._pythonExecutable}" -m pip --version`;
let versionCmdResult = await this.executeBufferedCommand(versionCmd);
let version = versionCmdResult.substring(4, 10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version numbers aren't guaranteed to all have the same length. If the version was something like "20.2" then by the 10th index you've already started pulling in other characters from the version message. Given a message that looks like this: "pip 20.2 from ...", substring(4,10) would give us "20.2 f". Then you can get the opposite problem if the version number is too long, like if it includes some kind of pre-release tag.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the pip release history, we have version "21.0" which hits the too short issue, and "10.0.0b2" which hits the too long issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the installed list of packages using the getInstalledPipPackages() method, which has all the versions listed. Frustratingly, "pip show" doesn't have a json output format like "pip list", so you'd have to get the list of all the packages.

if (!this._usingExistingPython) {
let versionCmd = `"${this._pythonExecutable}" -m pip --version`;
let versionCmdResult = await this.executeBufferedCommand(versionCmd);
let version = versionCmdResult.substring(4, 10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the pip release history, we have version "21.0" which hits the too short issue, and "10.0.0b2" which hits the too long issue.

if (!this._usingExistingPython) {
let versionCmd = `"${this._pythonExecutable}" -m pip --version`;
let versionCmdResult = await this.executeBufferedCommand(versionCmd);
let version = versionCmdResult.substring(4, 10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the installed list of packages using the getInstalledPipPackages() method, which has all the versions listed. Frustratingly, "pip show" doesn't have a json output format like "pip list", so you'd have to get the list of all the packages.

@lucyzhang929 lucyzhang929 merged commit 74629c9 into main Mar 4, 2021
@lucyzhang929 lucyzhang929 deleted the luczhan/fixpip branch March 4, 2021 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

non-functional pip after using "New Python Installation" option, even after switching to another version
4 participants