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

Python Ext not relevant when finding remote kernel #14079

Merged
merged 1 commit into from
Aug 8, 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
18 changes: 1 addition & 17 deletions src/kernels/jupyter/finder/remoteKernelFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
RemoteKernelConnectionMetadata,
RemoteKernelSpecConnectionMetadata
} from '../../types';
import { IAsyncDisposable, IDisposable, IExtensionContext, IExtensions } from '../../../platform/common/types';
import { IAsyncDisposable, IDisposable, IExtensionContext } from '../../../platform/common/types';
import {
IOldJupyterSessionManagerFactory,
IJupyterRemoteCachedKernelValidator,
Expand All @@ -22,7 +22,6 @@ import {
} from '../types';
import { sendKernelSpecTelemetry } from '../../raw/finder/helper';
import { traceError, traceWarning, traceInfoIfCI, traceVerbose } from '../../../platform/logging';
import { IPythonExtensionChecker } from '../../../platform/api/types';
import { raceCancellation } from '../../../platform/common/cancellation';
import { areObjectsWithUrisTheSame, noop } from '../../../platform/common/utils/misc';
import { IApplicationEnvironment } from '../../../platform/common/application/types';
Expand Down Expand Up @@ -86,19 +85,16 @@ export class RemoteKernelFinder implements IRemoteKernelFinder, IDisposable {
// Track our delay timer for when we update on kernel dispose
private kernelDisposeDelayTimer: NodeJS.Timeout | number | undefined;

private wasPythonInstalledWhenFetchingKernels = false;
private readonly cacheKey: string;
private readonly cacheFile: Uri;
constructor(
readonly id: string,
readonly displayName: string,
private jupyterSessionManagerFactory: IOldJupyterSessionManagerFactory,
private extensionChecker: IPythonExtensionChecker,
private readonly env: IApplicationEnvironment,
private readonly cachedRemoteKernelValidator: IJupyterRemoteCachedKernelValidator,
kernelFinder: KernelFinder,
private readonly kernelProvider: IKernelProvider,
private readonly extensions: IExtensions,
readonly serverUri: IJupyterServerUriEntry,
private readonly jupyterConnection: JupyterConnection,
private readonly fs: IFileSystem,
Expand Down Expand Up @@ -168,18 +164,6 @@ export class RemoteKernelFinder implements IRemoteKernelFinder, IDisposable {
this,
this.disposables
);

this.extensions.onDidChange(
() => {
// If we just installed the Python extension and we fetched the controllers, then fetch it again.
if (!this.wasPythonInstalledWhenFetchingKernels && this.extensionChecker.isPythonExtensionInstalled) {
this.updateCache().then(noop, noop);
}
},
this,
this.disposables
);
this.wasPythonInstalledWhenFetchingKernels = this.extensionChecker.isPythonExtensionInstalled;
}

public async refresh(): Promise<void> {
Expand Down
8 changes: 1 addition & 7 deletions src/kernels/jupyter/finder/remoteKernelFinder.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import { JupyterSessionManager } from '../session/jupyterSessionManager';
import { JupyterSessionManagerFactory } from '../session/jupyterSessionManagerFactory';
import { IJupyterKernel, IJupyterRemoteCachedKernelValidator, IJupyterSessionManager } from '../types';
import { KernelFinder } from '../../kernelFinder';
import { PythonExtensionChecker } from '../../../platform/api/pythonApi';
import { IApplicationEnvironment } from '../../../platform/common/application/types';
import { IExtensionContext, IExtensions } from '../../../platform/common/types';
import { IExtensionContext } from '../../../platform/common/types';
import { createEventHandler, TestEventHandler } from '../../../test/common';
import { CacheDataFormat, RemoteKernelFinder } from './remoteKernelFinder';
import { JupyterConnection } from '../connection/jupyterConnection';
Expand Down Expand Up @@ -128,8 +127,6 @@ suite(`Remote Kernel Finder`, () => {
when(jupyterSessionManager.dispose()).thenResolve();
const jupyterSessionManagerFactory = mock(JupyterSessionManagerFactory);
when(jupyterSessionManagerFactory.create(anything())).thenResolve(instance(jupyterSessionManager));
const extensionChecker = mock(PythonExtensionChecker);
when(extensionChecker.isPythonExtensionInstalled).thenReturn(true);
when(fs.delete(anything())).thenResolve();
when(fs.createDirectory(uriEquals(globalStorageUri))).thenResolve();
when(fs.exists(anything())).thenResolve(true);
Expand All @@ -148,7 +145,6 @@ suite(`Remote Kernel Finder`, () => {
const env = mock<IApplicationEnvironment>();
when(env.extensionVersion).thenReturn('');
const kernelProvider = mock<IKernelProvider>();
const extensions = mock<IExtensions>();
kernelFinder = new KernelFinder(disposables);
kernelsChanged = createEventHandler(kernelFinder, 'onDidChangeKernels');
disposables.push(kernelsChanged);
Expand All @@ -158,12 +154,10 @@ suite(`Remote Kernel Finder`, () => {
'currentremote',
'Local Kernels',
instance(jupyterSessionManagerFactory),
instance(extensionChecker),
instance(env),
instance(cachedRemoteKernelValidator),
kernelFinder,
instance(kernelProvider),
instance(extensions),
serverEntry,
instance(jupyterConnection),
instance(fs),
Expand Down
7 changes: 1 addition & 6 deletions src/kernels/jupyter/finder/remoteKernelFinderController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

import { injectable, inject } from 'inversify';
import { IKernelFinder, IKernelProvider } from '../../types';
import { IDisposableRegistry, IExtensionContext, IExtensions } from '../../../platform/common/types';
import { IDisposableRegistry, IExtensionContext } from '../../../platform/common/types';
import {
IOldJupyterSessionManagerFactory,
IJupyterServerUriStorage,
IJupyterRemoteCachedKernelValidator,
IJupyterServerUriEntry
} from '../types';
import { IPythonExtensionChecker } from '../../../platform/api/types';
import { noop } from '../../../platform/common/utils/misc';
import { IApplicationEnvironment } from '../../../platform/common/application/types';
import { KernelFinder } from '../../kernelFinder';
Expand All @@ -28,14 +27,12 @@ export class RemoteKernelFinderController implements IExtensionSyncActivationSer
constructor(
@inject(IOldJupyterSessionManagerFactory)
private readonly jupyterSessionManagerFactory: IOldJupyterSessionManagerFactory,
@inject(IPythonExtensionChecker) private readonly extensionChecker: IPythonExtensionChecker,
@inject(IJupyterServerUriStorage) private readonly serverUriStorage: IJupyterServerUriStorage,
@inject(IApplicationEnvironment) private readonly env: IApplicationEnvironment,
@inject(IJupyterRemoteCachedKernelValidator)
private readonly cachedRemoteKernelValidator: IJupyterRemoteCachedKernelValidator,
@inject(IKernelFinder) private readonly kernelFinder: KernelFinder,
@inject(IKernelProvider) private readonly kernelProvider: IKernelProvider,
@inject(IExtensions) private readonly extensions: IExtensions,
@inject(JupyterConnection) private readonly jupyterConnection: JupyterConnection,
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
@inject(IFileSystem) private readonly fs: IFileSystem,
Expand Down Expand Up @@ -65,12 +62,10 @@ export class RemoteKernelFinderController implements IExtensionSyncActivationSer
`${ContributedKernelFinderKind.Remote}-${serverId}`,
serverUri.displayName || generateIdFromRemoteProvider(serverUri.provider),
this.jupyterSessionManagerFactory,
this.extensionChecker,
this.env,
this.cachedRemoteKernelValidator,
this.kernelFinder,
this.kernelProvider,
this.extensions,
serverUri,
this.jupyterConnection,
this.fs,
Expand Down
Loading