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

When the remote server is actually 'localhost' we can behave better ... #8527

Merged
merged 12 commits into from
Dec 13, 2021

Conversation

rchiodo
Copy link
Contributor

@rchiodo rchiodo commented Dec 10, 2021

Fixes #8285
Fixes #1551

Special case some scenarios to act like local when the server is 'localhost' or '127.0.0.1'

Also fix remote intellisense to work in those scenarios or in true remote.

@rchiodo rchiodo requested a review from a team as a code owner December 10, 2021 23:23
if (kernel.kind !== 'connectToLiveKernel' && kernel.kernelSpec && kernel.interpreter) {
if (
kernel.kind !== 'connectToLiveKernel' &&
kernel.kind != 'startUsingRemoteKernelSpec' &&
Copy link
Member

Choose a reason for hiding this comment

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

missing =?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Thanks. Which also prompted me to lookup the difference. === does not do any type manipulation and just compares the values. == will convert the values to the same types. So I guess === is faster.

export function isLocalHostConnection(kernelConnection: KernelConnectionMetadata): boolean {
if (kernelConnection.kind === 'connectToLiveKernel' || kernelConnection.kind === 'startUsingRemoteKernelSpec') {
const parsed = new url.URL(kernelConnection.baseUrl);
return parsed.hostname.toLocaleLowerCase() === 'localhost' || parsed.host === '127.0.0.1';
Copy link
Member

Choose a reason for hiding this comment

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

I was going to ask if localhost is more configurable, and I believe it is. But I think that we only have to worry about how Jupyter starts it, so this is fine I believe.

Copy link
Member

Choose a reason for hiding this comment

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

Was going to ask if we needed to check for an npm module or something for a more comprehensive loopback check, but I don't think we need to.

@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2021

Codecov Report

Merging #8527 (ad6d29f) into main (ea6a20d) will decrease coverage by 15%.
The diff coverage is 69%.

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

@@           Coverage Diff           @@
##            main   #8527     +/-   ##
=======================================
- Coverage     71%     56%    -16%     
=======================================
  Files        378     378             
  Lines      23985   24008     +23     
  Branches    3692    3701      +9     
=======================================
- Hits       17266   13477   -3789     
- Misses      5227    9370   +4143     
+ Partials    1492    1161    -331     
Impacted Files Coverage Δ
src/client/datascience/errors/errorHandler.ts 50% <0%> (-8%) ⬇️
...ient/datascience/kernel-launcher/kernelLauncher.ts 41% <ø> (-42%) ⬇️
...ence/notebook/intellisense/intellisenseProvider.ts 65% <0%> (-19%) ⬇️
.../datascience/notebook/notebookControllerManager.ts 64% <0%> (-15%) ⬇️
src/client/datascience/types.ts 100% <ø> (ø)
src/client/datascience/jupyter/kernels/types.ts 76% <50%> (-24%) ⬇️
...science/jupyter/kernels/kernelDependencyService.ts 78% <64%> (-4%) ⬇️
src/client/datascience/jupyter/kernels/kernel.ts 45% <75%> (-31%) ⬇️
...t/datascience/errors/ipyKernelNotInstalledError.ts 100% <100%> (ø)
...atascience/jupyter/kernels/jupyterKernelService.ts 76% <100%> (-2%) ⬇️
... and 181 more

kernelConnection.kind === 'connectToLiveKernel' ||
kernelConnection.kind === 'startUsingRemoteKernelSpec' ||
!kernelConnection.interpreter
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops,

kernel.kind !== 'connectToLiveKernel' &&
kernel.interpreter &&
kernel.kind !== 'startUsingRemoteKernelSpec'
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shoot even more, yup, i think i know what would have happened...
Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No these are my fault. A remote kernel couldn't have an interpreter until my change. So your old if statement would have worked.

@@ -344,7 +344,7 @@ export async function waitForKernelToGetAutoSelected(expectedLanguage?: string,
);
return preferred != undefined;
},
3_000,
30_000,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This timeout was failing because now remote connections try to match interpreters. Getting intepreter details was taking longer than 3 seconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what was causing my test failures AFAIK. Hopefully next run completes fully.

@rchiodo rchiodo merged commit 0baa9e3 into main Dec 13, 2021
@rchiodo rchiodo deleted the rchiodo/localhost_is_local branch December 13, 2021 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants