-
Notifications
You must be signed in to change notification settings - Fork 293
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
Support returning a preferred remote controller #9978
Conversation
@@ -1,7 +1,7 @@ | |||
// Place your settings in this file to overwrite default and user settings. | |||
{ | |||
"files.exclude": { | |||
"out": true, // set this to true to hide the "out" folder with the compiled JS files | |||
"out": false, // set this to true to hide the "out" folder with the compiled JS files |
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.
I think this is ok to have, i keep setting this.
"DataScience.remoteJupyterConnectionFailedWithServer": "Failed to connect to the remote Jupyter Server {0}. Verify the server is running and reachable.", | ||
"DataScience.remoteJupyterConnectionFailedWithServerWithError":"Failed to connect to the remote Jupyter Server {0}. Verify the server is running and reachable. ({1}).", | ||
"DataScience.remoteJupyterConnectionFailedWithServer": "Failed to connect to the remote Jupyter Server '{0}'. Verify the server is running and reachable.", | ||
"DataScience.remoteJupyterConnectionFailedWithServerWithError":"Failed to connect to the remote Jupyter Server '{0}'. Verify the server is running and reachable. ({1}).", |
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.
Was previously displaying the baseUrl, but in the case of somethign like Azure ML, we can display the displayName (which could contain spaces), hence quoting this string.
@@ -48,7 +48,7 @@ export class JupyterServerSelectorCommand implements IDisposable { | |||
// Find one that is the default for this remote | |||
if (notebook) { | |||
// Recompute the preferred controller | |||
await this.controllerManager.computePreferredNotebookController(notebook); | |||
await this.controllerManager.initializePreferredNotebookController(notebook); |
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.
This was not only computing the preferred controller, it was also setting it using the VS Code api.
I've renamed this to be more specific.
The method computePreferredNotebookController
is now used to return the preferred controller without changing it.
@@ -65,7 +66,7 @@ export class JupyterConnection implements IExtensionSyncActivationService { | |||
private async getUriFromServerId(serverId: string) { | |||
// Since there's one server per session, don't use a resource to figure out these settings | |||
const savedList = await this.serverUriStorage.getSavedUriList(); | |||
return savedList.find((item) => computeUriHash(item.uri) === serverId)?.uri; | |||
return savedList.find((item) => computeServerId(item.uri) === serverId)?.uri; |
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.
Renamed computeUriHash
to be computeServerId
, the implementation should not define the method name, its a server id, hence the name should reflect that.
} | ||
} catch (ex) { | ||
throw new RemoteJupyterServerUriProviderError(idAndHandle.id, idAndHandle.handle, ex); |
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.
Throw a custom error so we can handle this, e.g. possible the jupyter server is down and user can now choose to ignore this connection completely.
@@ -53,14 +61,35 @@ export class JupyterUriProviderRegistration implements IJupyterUriProviderRegist | |||
} | |||
|
|||
private async loadOtherExtensions(): Promise<void> { | |||
const extensionIds = new Set<string>(); | |||
this.globalMemento |
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.
In the case of github extensions
, they can register the lazy proxy controller when a notebook opens and they register the provider with us.
When we reload vscode, we try to get the provider information, however its possible github or other extensions haven't activated yet, for such extensions we don'e need an entry in package.json for pythonRemoteServerProvider
, instead we can just keep track of the extensions that own a specific provider and load and activate those extensions.
@@ -14,6 +14,9 @@ export class JupyterUriProviderWrapper implements IJupyterUriProvider { | |||
return this.provider.id; | |||
} | |||
public getQuickPickEntryItems(): vscode.QuickPickItem[] { | |||
if (!this.provider.getQuickPickEntryItems) { |
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.
Extensions such as github or others won't need to implement getQuickPickEntryItems
(see type definition)
|
||
@captureTelemetry(Telemetry.EnterJupyterURI) | ||
@traceDecoratorError('Failed to enter Jupyter Uri') | ||
public async enterJupyterURI(): Promise<string | undefined> { |
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.
Wrote this code for server picker for our own lazy controller, don't see any harm keeping this here.
Not used for now, as i didn't want to checkin the layzy proxy controller as that API could change.
Requries a bit more work to remove this hence left it, hope its ok (the plan is to make use of this in the future)
@@ -234,7 +235,7 @@ export class JupyterSession extends BaseJupyterSession { | |||
|
|||
// Create our session options using this temporary notebook and our connection info | |||
const sessionOptions: Session.ISessionOptions = { | |||
path: backingFile?.filePath || `${uuid()}.ipynb`, // Name has to be unique | |||
path: backingFile?.filePath || generateBackingIPyNbFileName(this.resource), // Name has to be unique |
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.
Now all paths generate have a predictable name & we can strip out the unnecessary guff and have a meaningful and prettier display name in the kernel picker, previously we'd just display a guid.
readonly id: string; | ||
onDidChangeHandlers?: Event<void>; | ||
getQuickPickEntryItems?(): QuickPickItem[]; | ||
handleQuickPick?(item: QuickPickItem, backEnabled: boolean): Promise<JupyterServerUriHandle | 'back' | undefined>; |
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.
Extensions such as github or others won't need to implement getQuickPickEntryItems
Haven't hooked up the code to make use of this API just yet, but added this nevertheless, basically as defined here microsoft/vscode#146942
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.
The code that uses this has a few more changes, figured i'd submit this PR without those changes as its pretty large as is.
cancelToken?: CancellationToken, | ||
useCache?: 'useCache' | 'ignoreCache' | ||
useCache?: 'useCache' | 'ignoreCache', | ||
serverId?: string |
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.
Added a new argument serverId
so that we can filter out the kernels that apply to a specific remote jupyter server.
Applies to the lazy controller that spins up jupyter and then asks us to get the prefered controller (surely at that point we need to return the preferred controller specific to that jupyter server)
const isPythonNbOrInteractiveWindow = isPythonNotebook(notebookMetadata) || resourceType === 'interactive'; | ||
|
||
// Always include the interpreter in the search if we can | ||
const preferredInterpreter = |
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.
Removed this code from the base method, the exact same code preferredInterpreter
is calculated in the calling code, hence might as well pass that into this method instead of computing this here, also remove a few dependencies.
Codecov Report
@@ Coverage Diff @@
## main #9978 +/- ##
====================================
- Coverage 63% 63% -1%
====================================
Files 208 209 +1
Lines 9912 9948 +36
Branches 1574 1591 +17
====================================
+ Hits 6314 6323 +9
- Misses 3090 3113 +23
- Partials 508 512 +4
|
} | ||
if (item.connection.kernelSpec.name === kernelName) { | ||
matchingKernelNameController = item; | ||
} else if (item.connection.kernelSpec.language === language) { |
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.
When I moved over the exact match code I ran into one existing error case where the kernelspec language didn't match up with the notebook language_info languages due to capitalization, so maybe need a toLower check here? Pretty sure it was for a C# file.
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.
Oh shoot, I thought I had a translation code, will use that.
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.
The function that you can use to translate from kenel to monaco language is translateKernelLanguageToMonaco
Here it doesn't apply as we're only dealing with languages of kernelspecs & no language components from VS Code (monaco).
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.
Two small comments, but looks good to me.
Part of #9683
Part of this PR:
selectJuptyerUri
(but renamed togetSuggestedController
)pythonRemoteServerProvider
into their package.jsoncomputeUri
tocomputeServerId
, that seems more meaningful as that's exactly what it is.Note:
The api method
selectJuptyerUri
described here microsoft/vscode#146942 has been renamed togetSuggestedController
, as the Jupyter API doesn't select any controller, it merely returns the suggested controller for a given remote Jupyter server.(discussed with Peng), and will update the upstream issue once this work has been completed.