-
Notifications
You must be signed in to change notification settings - Fork 274
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
Changes from 1 commit
ba1abb9
b2351e2
5bfa8c9
a0474f1
be4713c
8d886fa
59c1753
8cc9891
48eacd6
d1a707a
ad6d29f
b5a49b3
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Use the appropriate directory for a notebook if remoting to 'localhost' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Support intellisense after connecting to a remote server (defaults to active python interpreter) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import type { | |
KernelSocketInformation | ||
} from '../../types'; | ||
import type * as nbformat from '@jupyterlab/nbformat'; | ||
import * as url from 'url'; | ||
|
||
export type LiveKernelModel = IJupyterKernel & | ||
Partial<IJupyterKernelSpec> & { model: Session.IModel | undefined; notebook?: { path?: string } }; | ||
|
@@ -63,7 +64,7 @@ export type LocalKernelSpecConnectionMetadata = Readonly<{ | |
*/ | ||
export type RemoteKernelSpecConnectionMetadata = Readonly<{ | ||
kernelModel?: undefined; | ||
interpreter?: undefined; | ||
interpreter?: PythonEnvironment; // Can be set if URL is localhost | ||
kernelSpec: IJupyterKernelSpec; | ||
kind: 'startUsingRemoteKernelSpec'; | ||
baseUrl: string; | ||
|
@@ -112,6 +113,14 @@ export function isLocalConnection( | |
); | ||
} | ||
|
||
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'; | ||
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. 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. 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. 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. |
||
} | ||
return false; | ||
} | ||
|
||
export interface IKernel extends IAsyncDisposable { | ||
readonly connection: INotebookProviderConnection | undefined; | ||
readonly notebookDocument: NotebookDocument; | ||
|
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.
missing =?
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.
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.