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

Enable an experimental setting for the new kernel picker UI #10807

Merged
merged 8 commits into from
Jul 14, 2022

Conversation

rchiodo
Copy link
Contributor

@rchiodo rchiodo commented Jul 14, 2022

Fixes #10782

For the most part I left a copy of the code for the UI parts. This was simpler than trying to make the new code handle the old UI and the new.

@rchiodo rchiodo requested a review from a team as a code owner July 14, 2022 17:48
"description": "%jupyter.configuration.jupyter.showOnlyOneTypeOfKernel.markdownDescription%",
"scope": "machine",
"tags": [
"experimental"
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 tag enables the changing of this setting through an experiment service.

this.showingRemoteNotWebContext.set(!isLocal && !this.isWeb).ignoreErrors();
this.showingRemoteContext.set(!isLocal && this.controllerRegistration.values.length > 0).ignoreErrors();
} else {
this.showingLocalOrWebEmptyContext.set(false).ignoreErrors();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commands are always hidden if the setting is turned off

@@ -228,6 +239,13 @@ export class ControllerRegistration implements IControllerRegistration {
this.onDidChangeFilter();
}

private onDidChangeConfiguration(e: ConfigurationChangeEvent) {
if (e.affectsConfiguration('jupyter.showOnlyOneTypeOfKernel')) {
this.inKernelExperiment = this.workspace.getConfiguration('jupyter')?.get('showOnlyOneTypeOfKernel', false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When onDidChangeConfiguration fires, the config service doesn't necessarily have the update yet (it's listening to the same event), so had to use the workspace.getConfiguration call here instead.

@@ -139,3 +144,10 @@ type InterpreterFiter = {
*/
path: string;
};
type RemoteSpecFilter = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added support for remote filtering. Made testing this easier.

await selector.selectJupyterURI();
let value = await storage.getUri();
assert.equal(value, Settings.JupyterServerLocalLaunch, 'Default should pick local launch');
suite('Experimental', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two copies of the tests.

One for new way the server selector works
One for the old way.

@@ -183,6 +183,13 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
this.controller.supportedLanguages = this.languageService.getSupportedLanguages(kernelConnection);
// Hook up to see when this NotebookController is selected by the UI
this.controller.onDidChangeSelectedNotebooks(this.onDidChangeSelectedNotebooks, this, this.disposables);
this.notebookApi.onDidCloseNotebookDocument(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Associated documents were surviving tests closing notebooks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which could also potentially happen in the real product.

User opens notebook
Connects to remote
User closes notebook
User opens another notebook
Connects to local
Kernel list still includes remote connection from notebook that isn't open anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New test I added is verifying this isn't the case

Copy link
Contributor

Choose a reason for hiding this comment

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

This might improve performance and potentially fix other unnoticed bugs! I think? This looks really promising to me


return items;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Cleanly done! I like it

@@ -65,7 +71,7 @@ export class KernelFilterUI implements IExtensionSyncActivationService, IDisposa
})
.map((item) => {
return <QuickPickType>{
label: getDisplayNameOrNameOfKernelConnection(item),
label: getKernelLabel(item),
picked: !this.kernelFilter.isKernelHidden(item),
description: getKernelConnectionPath(item, this.workspace),
detail:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -183,7 +189,12 @@ export class ControllerRegistration implements IControllerRegistration {
const userFiltered = this.kernelFilter.isKernelHidden(metadata);
const connectionTypeFiltered = isLocalConnection(metadata) !== this.isLocalLaunch;
const urlFiltered = isRemoteConnection(metadata) && this.serverUriStorage.currentServerId !== metadata.serverId;
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed the additoin of this new function,
Can we change the code in isRemoteConnection to just call isLocalConnection and negate the value.
This way we don't have the logic in two functions.
I.e. isRemoteConnection would be the opposite of the return value of isLocalConnection this would allow us to keep the logic in one place.

Copy link
Contributor

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

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

looks ok, except for a problem with the all & registeredMetadatas properties

Copy link
Contributor

@sadasant sadasant left a comment

Choose a reason for hiding this comment

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

LGTM

@rchiodo
Copy link
Contributor Author

rchiodo commented Jul 14, 2022

Please see my reply to the 'values' and 'all' conversation. Maybe I should rename 'values' to 'filtered'. It is the filtered list, which when you're local it only has local values, but not remote and vice versa. The 'all' property is every kernel connection every registered.

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2022

Codecov Report

Merging #10807 (3320ec0) into main (4d1a5c7) will increase coverage by 0%.
The diff coverage is 68%.

@@           Coverage Diff           @@
##            main   #10807    +/-   ##
=======================================
  Coverage     63%      63%            
=======================================
  Files        481      481            
  Lines      33427    33628   +201     
  Branches    5447     5488    +41     
=======================================
+ Hits       21119    21276   +157     
- Misses     10267    10311    +44     
  Partials    2041     2041            
Impacted Files Coverage Δ
src/notebooks/controllers/liveKernelSwitcher.ts 60% <0%> (ø)
src/notebooks/controllers/types.ts 100% <ø> (ø)
src/platform/common/types.ts 100% <ø> (ø)
...ks/controllers/kernelFilter/kernelFilterService.ts 45% <16%> (-3%) ⬇️
...tebooks/controllers/kernelFilter/kernelFilterUI.ts 32% <16%> (-1%) ⬇️
...ers/commands/serverConnectionControllerCommands.ts 32% <66%> (+1%) ⬆️
src/kernels/jupyter/serverSelector.ts 63% <68%> (+3%) ⬆️
...rc/notebooks/controllers/controllerRegistration.ts 86% <80%> (-3%) ⬇️
src/kernels/types.ts 100% <100%> (ø)
...ollers/commands/installPythonControllerCommands.ts 57% <100%> (-1%) ⬇️
... and 39 more

@DonJayamanne
Copy link
Contributor

he 'values' and 'all' conversation. Maybe I should rename 'values' to 'filtered'.

Or just reigsteredControllers, I'd avoid using the word filter if possible, as thats just a way of deciding what's registered and what's not. At the end of the day, we're only interested in whats been registered with vs code.
Just a thought.

@rchiodo rchiodo merged commit a5f8fe4 into main Jul 14, 2022
@rchiodo rchiodo deleted the rchiodo/kernel_remote_experiment branch July 14, 2022 20:38
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.

Experiment setting to control new kernel UI
4 participants