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

Refactor Jupyter URI storage #13516

Merged
merged 4 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/extension.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import { IInterpreterPackages } from './platform/interpreter/types';
import { homedir, platform, arch, userInfo } from 'os';
import { getUserHomeDir } from './platform/common/utils/platform.node';
import { homePath } from './platform/common/platform/fs-paths.node';
import { removeOldCachedItems } from './platform/common/cache';

durations.codeLoadingTime = stopWatch.elapsedTime;

Expand All @@ -110,6 +111,7 @@ let activatedServiceContainer: IServiceContainer | undefined;
export async function activate(context: IExtensionContext): Promise<IExtensionApi> {
context.subscriptions.push({ dispose: () => (Exiting.isExiting = true) });
try {
removeOldCachedItems(context.globalState).then(noop, noop);
let api: IExtensionApi;
let ready: Promise<void>;
let serviceContainer: IServiceContainer;
Expand Down
2 changes: 2 additions & 0 deletions src/extension.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import { ServiceManager } from './platform/ioc/serviceManager';
import { OutputChannelLogger } from './platform/logging/outputChannelLogger';
import { ConsoleLogger } from './platform/logging/consoleLogger';
import { initializeGlobals as initializeTelemetryGlobals } from './platform/telemetry/telemetry';
import { removeOldCachedItems } from './platform/common/cache';

durations.codeLoadingTime = stopWatch.elapsedTime;

Expand All @@ -115,6 +116,7 @@ let activatedServiceContainer: IServiceContainer | undefined;
export async function activate(context: IExtensionContext): Promise<IExtensionApi> {
context.subscriptions.push({ dispose: () => (Exiting.isExiting = true) });
try {
removeOldCachedItems(context.globalState).then(noop, noop);
let api: IExtensionApi;
let ready: Promise<void>;
let serviceContainer: IServiceContainer;
Expand Down
9 changes: 0 additions & 9 deletions src/gdpr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -945,15 +945,6 @@
"${include}": [
"${F1}"

]
}
*/
//Telemetry.SetJupyterURIToLocal
/* __GDPR__
"DATASCIENCE.SET_JUPYTER_URI_LOCAL" : {
"${include}": [
"${F1}"

]
}
*/
Expand Down
24 changes: 0 additions & 24 deletions src/kernels/common/commonFinder.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { Memento } from 'vscode';
import { noop } from '../../platform/common/utils/misc';

// Two cache keys so we can get local and remote separately
export const RemoteKernelSpecsCacheKey = 'JUPYTER_REMOTE_KERNELSPECS_V4';

export async function removeOldCachedItems(globalState: Memento): Promise<void> {
await Promise.all(
[
'JUPYTER_LOCAL_KERNELSPECS',
'JUPYTER_LOCAL_KERNELSPECS_V1',
'JUPYTER_LOCAL_KERNELSPECS_V2',
'JUPYTER_LOCAL_KERNELSPECS_V3',
'JUPYTER_REMOTE_KERNELSPECS',
'JUPYTER_REMOTE_KERNELSPECS_V1',
'JUPYTER_REMOTE_KERNELSPECS_V2',
'JUPYTER_REMOTE_KERNELSPECS_V3',
'JUPYTER_LOCAL_KERNELSPECS_V4',
'LOCAL_KERNEL_SPECS_CACHE_KEY_V_2022_10',
'LOCAL_KERNEL_PYTHON_AND_RELATED_SPECS_CACHE_KEY_V_2022_10'
]
.filter((key) => RemoteKernelSpecsCacheKey !== key) // Exclude latest cache key
.filter((key) => globalState.get(key, undefined) !== undefined)
.map((key) => globalState.update(key, undefined).then(noop, noop))
);
}
2 changes: 1 addition & 1 deletion src/kernels/jupyter/connection/jupyterConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class JupyterConnection implements IExtensionSyncActivationService {
disposables.push(this);
}
public activate() {
this.serverUriStorage.onDidChangeConnectionType(
this.serverUriStorage.onDidChangeUri(
() =>
// When server URI changes, clear our pending URI timeouts
this.clearTimeouts(),
Expand Down
4 changes: 2 additions & 2 deletions src/kernels/jupyter/connection/jupyterConnection.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ suite('Jupyter Connection', async () => {
const serverConnectionChangeEvent = new EventEmitter<void>();
disposables.push(serverConnectionChangeEvent);

when(serverUriStorage.onDidChangeConnectionType).thenReturn(serverConnectionChangeEvent.event);
when(serverUriStorage.onDidChangeUri).thenReturn(serverConnectionChangeEvent.event);

jupyterConnection.activate();
});
Expand All @@ -65,7 +65,7 @@ suite('Jupyter Connection', async () => {
});

test('Ensure event handler is added', () => {
verify(serverUriStorage.onDidChangeConnectionType).once();
verify(serverUriStorage.onDidChangeUri).once();
});
test('Validation will result in fetching kernels and kernelspecs', async () => {
const uri = 'http://localhost:8888/?token=1234';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class JupyterRemoteCachedKernelValidator implements IJupyterRemoteCachedK
return true;
} else {
traceWarning(
`Hiding remote kernel ${kernel.id} as the remote Jupyter Server ${item.uri} is no longer available`
`Hiding remote kernel ${kernel.id} for ${provider.id} as the remote Jupyter Server ${item.serverId} is no longer available`
);
// 3rd party extensions own these kernels, if these are no longer
// available, then just don't display them.
Expand Down
Loading