Skip to content

Remove old jupyter session and backupfile classes #14393

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

Merged
merged 5 commits into from
Oct 2, 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
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1427,9 +1427,7 @@
"type": "array",
"default": [],
"items": {
"enum": [
"NewJupyterSession"
]
"enum": []
},
"markdownDescription": "%jupyter.configuration.jupyter.experiments.optInto.markdownDescription%",
"scope": "application"
Expand All @@ -1438,9 +1436,7 @@
"type": "array",
"default": [],
"items": {
"enum": [
"NewJupyterSession"
]
"enum": []
},
"markdownDescription": "%jupyter.configuration.jupyter.experiments.optOutFrom.markdownDescription%",
"scope": "application"
Expand Down
544 changes: 0 additions & 544 deletions src/kernels/common/baseJupyterSession.ts

Large diffs are not rendered by default.

26 changes: 1 addition & 25 deletions src/kernels/common/baseJupyterSessionConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import type { Kernel, KernelMessage, Session } from '@jupyterlab/services';
import { Signal } from '@lumino/signaling';
import { CancellationToken, Event, EventEmitter } from 'vscode';
import { CancellationToken, EventEmitter } from 'vscode';
import { Observable } from 'rxjs/Observable';
import { ReplaySubject } from 'rxjs/ReplaySubject';
import type { IChangedArgs } from '@jupyterlab/coreutils';
Expand Down Expand Up @@ -60,7 +60,6 @@ export abstract class BaseJupyterSessionConnection<
* The kernel anyMessage signal, proxied from the current kernel.
*/
anyMessage = new Signal<this, Kernel.IAnyMessageArgs>(this);
protected onStatusChangedEvent = new EventEmitter<KernelMessage.Status>();
protected readonly disposables: IDisposable[] = [];

constructor(
Expand All @@ -79,7 +78,6 @@ export abstract class BaseJupyterSessionConnection<
dispose: () => {
this.didShutdown.dispose();
this._disposed.dispose();
this.onStatusChangedEvent.dispose();

this.session.propertyChanged.disconnect(this.onPropertyChanged, this);
this.session.kernelChanged.disconnect(this.onKernelChanged, this);
Expand Down Expand Up @@ -133,10 +131,6 @@ export abstract class BaseJupyterSessionConnection<
public get kernelSocket(): Observable<KernelSocketInformation | undefined> {
return this._kernelSocket;
}
public get onSessionStatusChanged(): Event<KernelMessage.Status> {
return this.onStatusChangedEvent.event;
}

public abstract readonly status: KernelMessage.Status;
protected previousAnyMessageHandler?: IDisposable;
private disposeInvoked?: boolean;
Expand All @@ -147,10 +141,6 @@ export abstract class BaseJupyterSessionConnection<
if (this.disposeInvoked) {
return;
}
// onStatusChangedEvent is Deprecated, use statusChanged instead.
// Until we remove onStatusChangedEvent, leave this comment so we know why we're still leaving this event around but not firing it.
// Only fired in the old session classes.
// this.onStatusChangedEvent.fire('dead');
this.statusChanged.emit('dead');
this._disposed.fire();
this.disposed.emit();
Expand Down Expand Up @@ -235,12 +225,6 @@ export abstract class BaseJupyterSessionConnection<
this.statusChanged.emit(value);
const status = this.status;
traceInfoIfCI(`Server Status = ${status}`);
if (status !== 'dead') {
// onStatusChangedEvent is Deprecated, use statusChanged instead.
// Until we remove onStatusChangedEvent, leave this comment so we know why we're still leaving this event around but not firing it.
// Only fired in the old session classes.
this.onStatusChangedEvent.fire(status);
}
}
private onConnectionStatusChanged(_: unknown, value: Kernel.ConnectionStatus) {
this.connectionStatusChanged.emit(value);
Expand Down Expand Up @@ -269,13 +253,5 @@ export abstract class BaseJupyterSessionConnection<
}
private onKernelConnectionStatusHandler(_: unknown, kernelConnection: Kernel.ConnectionStatus) {
traceInfoIfCI(`Server Kernel Status = ${kernelConnection}`);
if (kernelConnection === 'disconnected') {
if (this.status !== 'dead') {
// onStatusChangedEvent is Deprecated, use statusChanged instead.
// Until we remove onStatusChangedEvent, leave this comment so we know why we're still leaving this event around but not firing it.
// Only fired in the old session classes.
this.onStatusChangedEvent.fire(this.status);
}
}
}
}
3 changes: 0 additions & 3 deletions src/kernels/common/baseJupyterSessionConnection.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@ suite('Base Jupyter Session Connection', () => {
jupyterSession.statusChanged.connect((_, args) => statuses.push(args));
jupyterSession.disposed.connect(() => (disposedEmitted = true));
const disposed = createEventHandler(jupyterSession, 'onDidDispose', disposables);
const statusChanged = createEventHandler(jupyterSession, 'onSessionStatusChanged', disposables);

jupyterSession.dispose();

assert.deepEqual(statuses, ['dead']);
assert.strictEqual(disposedEmitted, true);
assert.strictEqual(disposed.count, 1);
// This event is deprecated and should no longer be fired.
assert.strictEqual(statusChanged.count, 0);
});
test('Restarting will restart the underlying kernel', async () => {
when(kernel.restart()).thenResolve();
Expand Down
22 changes: 4 additions & 18 deletions src/kernels/common/kernelSessionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

import { inject, injectable, optional } from 'inversify';
import { IKernelSession, IKernelSessionFactory, isLocalConnection, KernelSessionCreationOptions } from '../types';
import { IRawKernelSessionFactory, IOldRawKernelSessionFactory, IRawNotebookSupportedService } from '../raw/types';
import { IRawKernelSessionFactory, IRawNotebookSupportedService } from '../raw/types';
import { JupyterKernelSessionFactory } from '../jupyter/session/jupyterKernelSessionFactory';
import { Experiments, IExperimentService } from '../../platform/common/types';
import { OldJupyterKernelSessionFactory } from '../jupyter/session/oldJupyterKernelSessionFactory';

/**
* Generic class for connecting to a server. Probably could be renamed as it doesn't provide notebooks, but rather connections.
Expand All @@ -17,35 +15,23 @@ export class KernelSessionFactory implements IKernelSessionFactory {
@inject(IRawNotebookSupportedService)
private readonly rawKernelSupported: IRawNotebookSupportedService,

@inject(IOldRawKernelSessionFactory)
@optional()
private readonly rawKernelSessionFactory: IOldRawKernelSessionFactory | undefined,
@inject(OldJupyterKernelSessionFactory)
private readonly jupyterSessionFactory: IKernelSessionFactory,
@inject(IRawKernelSessionFactory)
@optional()
private readonly newRawKernelSessionFactory: IRawKernelSessionFactory | undefined,
@inject(JupyterKernelSessionFactory)
private readonly newJupyterSessionFactory: IKernelSessionFactory,
@inject(IExperimentService)
private readonly experiments: IExperimentService
private readonly newJupyterSessionFactory: IKernelSessionFactory
) {}

public async create(options: KernelSessionCreationOptions): Promise<IKernelSession> {
const kernelConnection = options.kernelConnection;
if (
this.rawKernelSupported.isSupported &&
isLocalConnection(kernelConnection) &&
this.rawKernelSessionFactory &&
this.newRawKernelSessionFactory
) {
return this.experiments.inExperiment(Experiments.NewJupyterSession)
? this.newRawKernelSessionFactory.create({ ...options, kernelConnection: kernelConnection })
: this.rawKernelSessionFactory.create(options);
return this.newRawKernelSessionFactory.create({ ...options, kernelConnection: kernelConnection });
} else {
return this.experiments.inExperiment(Experiments.NewJupyterSession)
? this.newJupyterSessionFactory.create(options)
: this.jupyterSessionFactory.create(options);
return this.newJupyterSessionFactory.create(options);
}
}
}
2 changes: 0 additions & 2 deletions src/kernels/jupyter/connection/jupyterConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export class JupyterConnection {
this.requestCreator,
this.requestAgentCreator,
this.configService,
false,
Uri.file('')
);
}
Expand All @@ -67,7 +66,6 @@ export class JupyterConnection {
this.requestCreator,
this.requestAgentCreator,
this.configService,
false,
Uri.file('')
);
try {
Expand Down
1 change: 0 additions & 1 deletion src/kernels/jupyter/finder/remoteKernelFinder.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ suite(`Remote Kernel Finder`, () => {
let kernelsChanged: TestEventHandler<void>;
let jupyterConnection: JupyterConnection;
const connInfo: IJupyterConnection = {
localLaunch: false,
baseUrl: 'http://foobar',
displayName: 'foobar connection',
token: '',
Expand Down
2 changes: 0 additions & 2 deletions src/kernels/jupyter/jupyterUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export function createJupyterConnectionInfo(
requestCreator: IJupyterRequestCreator,
requestAgentCreator: IJupyterRequestAgentCreator | undefined,
configService: IConfigurationService,
localLaunch: boolean,
rootDirectory: Uri,
toDispose?: IDisposable
): IJupyterConnection {
Expand Down Expand Up @@ -164,7 +163,6 @@ export function createJupyterConnectionInfo(
serverProviderHandle: jupyterHandle,
token,
hostName,
localLaunch,
displayName:
serverUri && serverUri.displayName
? serverUri.displayName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export class JupyterConnectionWaiter implements IDisposable {
requestCreator,
requestAgentCreator,
configService,
true,
this.rootDir,
new Disposable(() => this.launchResult.dispose())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ suite('Jupyter Connection Waiter', async () => {

const connection = await waiter.ready;

assert.equal(connection.localLaunch, true);
assert.equal(connection.baseUrl, expectedServerInfo.url);
assert.equal(connection.hostName, expectedServerInfo.hostname);
assert.equal(connection.token, expectedServerInfo.token);
Expand Down
14 changes: 0 additions & 14 deletions src/kernels/jupyter/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,15 @@ import { JupyterServerStarter } from './launcher/jupyterServerStarter.node';
import { JupyterServerUriStorage } from './connection/serverUriStorage';
import { LiveRemoteKernelConnectionUsageTracker } from './connection/liveRemoteKernelConnectionTracker';
import { JupyterServerSelector } from './connection/serverSelector';
import { BackingFileCreator } from './session/backingFileCreator.node';
import { JupyterRequestCreator } from './session/jupyterRequestCreator.node';
import { JupyterSessionManagerFactory } from './session/jupyterSessionManagerFactory';
import { RequestAgentCreator } from './session/requestAgentCreator.node';
import {
IOldJupyterSessionManagerFactory,
INbConvertInterpreterDependencyChecker,
INbConvertExportToPythonService,
IJupyterServerProvider,
IJupyterInterpreterDependencyManager,
IJupyterUriProviderRegistration,
IJupyterServerUriStorage,
IJupyterBackingFileCreator,
IJupyterKernelService,
INotebookStarter,
IJupyterRequestCreator,
Expand All @@ -54,7 +50,6 @@ import {
import { IJupyterCommandFactory, IJupyterSubCommandExecutionService } from './types.node';
import { RemoteKernelFinderController } from './finder/remoteKernelFinderController';
import { KernelSessionFactory } from '../common/kernelSessionFactory';
import { OldJupyterKernelSessionFactory } from './session/oldJupyterKernelSessionFactory';
import { JupyterKernelSessionFactory } from './session/jupyterKernelSessionFactory';
import { JupyterServerProviderRegistry } from './connection/jupyterServerProviderRegistry';
import { IRemoteKernelFinderController } from './finder/types';
Expand All @@ -70,10 +65,6 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
MigrateJupyterInterpreterStateService
);
serviceManager.addSingleton<IJupyterServerHelper>(IJupyterServerHelper, JupyterServerHelper);
serviceManager.addSingleton<IOldJupyterSessionManagerFactory>(
IOldJupyterSessionManagerFactory,
JupyterSessionManagerFactory
);
serviceManager.addSingleton<JupyterCommandLineSelector>(JupyterCommandLineSelector, JupyterCommandLineSelector);
serviceManager.addSingleton<JupyterInterpreterDependencyService>(
JupyterInterpreterDependencyService,
Expand Down Expand Up @@ -113,12 +104,7 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
serviceManager.addSingleton<INotebookStarter>(INotebookStarter, JupyterServerStarter);
serviceManager.addSingleton<IJupyterServerConnector>(IJupyterServerConnector, JupyterServerConnector);
serviceManager.addSingleton<IKernelSessionFactory>(IKernelSessionFactory, KernelSessionFactory);
serviceManager.addSingleton<OldJupyterKernelSessionFactory>(
OldJupyterKernelSessionFactory,
OldJupyterKernelSessionFactory
);
serviceManager.addSingleton<JupyterKernelSessionFactory>(JupyterKernelSessionFactory, JupyterKernelSessionFactory);
serviceManager.addSingleton<IJupyterBackingFileCreator>(IJupyterBackingFileCreator, BackingFileCreator);
serviceManager.addSingleton<IJupyterRequestCreator>(IJupyterRequestCreator, JupyterRequestCreator);
serviceManager.addSingleton<IJupyterRequestAgentCreator>(IJupyterRequestAgentCreator, RequestAgentCreator);
serviceManager.addSingleton<JupyterConnection>(JupyterConnection, JupyterConnection);
Expand Down
14 changes: 0 additions & 14 deletions src/kernels/jupyter/serviceRegistry.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ import { JupyterServerProvider } from './launcher/jupyterServerProvider.web';
import { JupyterServerUriStorage } from './connection/serverUriStorage';
import { LiveRemoteKernelConnectionUsageTracker } from './connection/liveRemoteKernelConnectionTracker';
import { JupyterServerSelector } from './connection/serverSelector';
import { BackingFileCreator } from './session/backingFileCreator.web';
import { JupyterRequestCreator } from './session/jupyterRequestCreator.web';
import { JupyterSessionManagerFactory } from './session/jupyterSessionManagerFactory';
import {
IOldJupyterSessionManagerFactory,
IJupyterUriProviderRegistration,
IJupyterServerUriStorage,
IJupyterBackingFileCreator,
IJupyterKernelService,
IJupyterServerProvider,
IJupyterRequestCreator,
Expand All @@ -31,16 +27,11 @@ import {
} from './types';
import { RemoteKernelFinderController } from './finder/remoteKernelFinderController';
import { KernelSessionFactory } from '../common/kernelSessionFactory';
import { OldJupyterKernelSessionFactory } from './session/oldJupyterKernelSessionFactory';
import { JupyterKernelSessionFactory } from './session/jupyterKernelSessionFactory';
import { JupyterServerProviderRegistry } from './connection/jupyterServerProviderRegistry';
import { IRemoteKernelFinderController } from './finder/types';

export function registerTypes(serviceManager: IServiceManager, _isDevMode: boolean) {
serviceManager.addSingleton<IOldJupyterSessionManagerFactory>(
IOldJupyterSessionManagerFactory,
JupyterSessionManagerFactory
);
serviceManager.addSingleton<JupyterServerSelector>(JupyterServerSelector, JupyterServerSelector);
serviceManager.addSingleton<IJupyterKernelService>(IJupyterKernelService, JupyterKernelService);
serviceManager.addSingleton<IJupyterUriProviderRegistration>(
Expand All @@ -50,12 +41,7 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
serviceManager.addBinding(IJupyterUriProviderRegistration, IExtensionSyncActivationService);
serviceManager.addSingleton<IJupyterServerUriStorage>(IJupyterServerUriStorage, JupyterServerUriStorage);
serviceManager.addSingleton<IKernelSessionFactory>(IKernelSessionFactory, KernelSessionFactory);
serviceManager.addSingleton<OldJupyterKernelSessionFactory>(
OldJupyterKernelSessionFactory,
OldJupyterKernelSessionFactory
);
serviceManager.addSingleton<JupyterKernelSessionFactory>(JupyterKernelSessionFactory, JupyterKernelSessionFactory);
serviceManager.addSingleton<IJupyterBackingFileCreator>(IJupyterBackingFileCreator, BackingFileCreator);
serviceManager.addSingleton<IJupyterServerProvider>(IJupyterServerProvider, JupyterServerProvider);
serviceManager.addSingleton<IJupyterRequestCreator>(IJupyterRequestCreator, JupyterRequestCreator);
serviceManager.addSingleton<JupyterConnection>(JupyterConnection, JupyterConnection);
Expand Down
Loading