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

use python api for checking ipykernel version and cache kernels #6607

Merged
merged 7 commits into from
Jul 13, 2021

Conversation

DavidKutu
Copy link

@DavidKutu DavidKutu commented Jul 9, 2021

For #6391

  • cache valid kernels so the button enables faster
  • use python api for checking ipykernel version
  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).

@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2021

Codecov Report

Merging #6607 (c7b3f8d) into main (14e37e5) will decrease coverage by 0%.
The diff coverage is 79%.

❗ Current head c7b3f8d differs from pull request most recent head ab997d4. Consider uploading reports for the commit ab997d4 to get more accurate results

@@          Coverage Diff           @@
##            main   #6607    +/-   ##
======================================
- Coverage     69%     69%    -1%     
======================================
  Files        410     411     +1     
  Lines      28282   28336    +54     
  Branches    4205    4212     +7     
======================================
- Hits       19752   19643   -109     
- Misses      6877    7035   +158     
- Partials    1653    1658     +5     
Impacted Files Coverage Δ
src/client/api/types.ts 100% <ø> (ø)
src/client/common/installer/productInstaller.ts 47% <ø> (-3%) ⬇️
...science/jupyter/kernels/kernelDependencyService.ts 86% <62%> (+<1%) ⬆️
...client/datascience/commands/activeEditorContext.ts 90% <77%> (-3%) ⬇️
src/client/api/pythonApi.ts 59% <100%> (+<1%) ⬆️
src/client/common/types.ts 100% <100%> (ø)
...ience/variablesView/variableViewMessageListener.ts 22% <0%> (-78%) ⬇️
...ent/common/application/webviewViews/webviewView.ts 14% <0%> (-72%) ⬇️
...c/client/datascience/variablesView/variableView.ts 18% <0%> (-62%) ⬇️
src/client/datascience/webviews/webviewViewHost.ts 19% <0%> (-53%) ⬇️
... and 27 more

): Promise<ProductInstallStatus> {
try {
const api = await this.apiProvider.getApi();
return await api.isProductVersionCompatible(product, semVerRequirement, resource);
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need the await

Suggested change
return await api.isProductVersionCompatible(product, semVerRequirement, resource);
return api.isProductVersionCompatible(product, semVerRequirement, resource);

try {
const api = await this.apiProvider.getApi();
return await api.isProductVersionCompatible(product, semVerRequirement, resource);
} catch (ex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're not doing anything with the exception, then ther'es no need to capture this.

isProductVersionCompatible(
product: Product,
semVerRequirement: string,
resource?: InterpreterUri
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change this to PythonEnvironment instead of InterpreterUri, thats an old approach, and very vague that has caused a lot of issues, We should be more specific about the target interpreter.

return mainVersionNumber >= 6;
const result = await this.pythonInstaller.isProductVersionCompatible(
Product.ipykernel,
'>=6.0.0',
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a valid semver.
We should ideally just pass 6.0.0 and then on the other end use the necessary API to check the minimum version by prefixing wqith >= or the like.

Copy link
Author

Choose a reason for hiding this comment

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

It is valid and it works.
There's an example here: https://docs.npmjs.com/cli/v6/using-npm/semver#ranges

@DavidKutu DavidKutu requested a review from DonJayamanne July 13, 2021 00:08
const mainVersionNumber = Number(versionSplit[0]);
return mainVersionNumber >= 6;
const installer = await this.serviceContainer.get<IPythonInstaller>(IPythonInstaller);
const result = await installer.isProductVersionCompatible(Product.ipykernel, '>=6.0.0', interpreter);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change this to 6.0.0 and change the code at the other end to add the >= else its incorrect to pass >=6.0.0, i.e. if you are saying that minimum is 6.0.0, then why do we need >=.

Copy link
Contributor

Choose a reason for hiding this comment

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

The text >= is actually part of the code used to check for the version compatiblity. (its very specific to the tool & mechanism used to check the version).

Copy link
Author

Choose a reason for hiding this comment

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

What other end? The python extension? That doesn't make sense, the function exposed asks for the semVerRequirement. It doesn't make sense to give it half the string in one place and the rest in another.

Passing 6.0.0 is wrong, that means 'be exactly 6.0.0', that's not what we want. From their documentation, the parameter should be >=6.0.0 which means, 6.0.0 or above.

Copy link
Author

Choose a reason for hiding this comment

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

passing just 6.0.0 doesn't work, it returns 'needs upgrade'

Copy link
Contributor

@DonJayamanne DonJayamanne Jul 13, 2021

Choose a reason for hiding this comment

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

The parameter should be minimum version, and it should be passed as a semver value.
Again, the requirement is what is the minimum version, not, what is the query that needs to be run to check the minimum version.

Copy link
Contributor

@DonJayamanne DonJayamanne Jul 13, 2021

Choose a reason for hiding this comment

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

I.e. in Python I would change the following if (semver.satisfies(version, semVerRequirement)) { as follows:
if (semver.satisfies(version, ${>=${semVerRequirement})) {

and change the argument name semVerRequirement to be mimimumVersion: Semver (this way its not just any arbitrary string, but a proper version.
Else someone looking at this might pass 6.0.0 and assume that works. (that's exactly how i interpreted this).

Copy link
Author

@DavidKutu DavidKutu Jul 13, 2021

Choose a reason for hiding this comment

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

I understand your comment, but I don't think its confusing. The parameter clearly reads semVerRequirement and not semVer or minimumVersion.

Also, doing what you're asking means losing functionality of isProductVersionCompatible. It would only be able to check for a minimum version, and the time might come when we need to check a maximum version, an exact version, or a range. We can do all that with the function as it is right now.

@DavidKutu DavidKutu merged commit 95014cd into main Jul 13, 2021
@DavidKutu DavidKutu deleted the david/debugging3 branch July 13, 2021 20:02
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.

4 participants