Skip to content

Commit a633856

Browse files
IanMatthewHuffIan Huff
and
Ian Huff
authored
Port raw auto start fix to release (#12288)
* don't return a connection from the raw provider for getOnly (#12277) Co-authored-by: Ian Huff <[email protected]> * update changelog and remove news entry Co-authored-by: Ian Huff <[email protected]>
1 parent 4d26061 commit a633856

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
([#12225](https://github.com/Microsoft/vscode-python/issues/12225))
9393
1. Make stop during run by line interrupt the kernel.
9494
([#12249](https://github.com/Microsoft/vscode-python/issues/12249))
95+
1. Have raw kernel respect the jupyter server disable auto start setting.
96+
([#12246](https://github.com/Microsoft/vscode-python/issues/12246))
9597

9698
### Code Health
9799

src/client/datascience/interactive-common/notebookProvider.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
import { inject, injectable } from 'inversify';
7-
import { CancellationToken, EventEmitter, Uri } from 'vscode';
7+
import { EventEmitter, Uri } from 'vscode';
88
import { IWorkspaceService } from '../../common/application/types';
99
import { IFileSystem } from '../../common/platform/types';
1010
import { IDisposableRegistry, Resource } from '../../common/types';
@@ -69,13 +69,10 @@ export class NotebookProvider implements INotebookProvider {
6969
}
7070

7171
// Attempt to connect to our server provider, and if we do, return the connection info
72-
public async connect(
73-
options: ConnectNotebookProviderOptions,
74-
token?: CancellationToken
75-
): Promise<INotebookProviderConnection | undefined> {
72+
public async connect(options: ConnectNotebookProviderOptions): Promise<INotebookProviderConnection | undefined> {
7673
// Connect to either a jupyter server or a stubbed out raw notebook "connection"
7774
if (await this.rawNotebookProvider.supported()) {
78-
return this.rawNotebookProvider.connect(token);
75+
return this.rawNotebookProvider.connect(options);
7976
} else {
8077
return this.jupyterNotebookProvider.connect(options);
8178
}

src/client/datascience/raw-kernel/rawNotebookProvider.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import * as localize from '../../common/utils/localize';
1313
import { noop } from '../../common/utils/misc';
1414
import { captureTelemetry } from '../../telemetry';
1515
import { Telemetry } from '../constants';
16-
import { INotebook, IRawConnection, IRawNotebookProvider, IRawNotebookSupportedService } from '../types';
16+
import {
17+
ConnectNotebookProviderOptions,
18+
INotebook,
19+
IRawConnection,
20+
IRawNotebookProvider,
21+
IRawNotebookSupportedService
22+
} from '../types';
1723

1824
export class RawConnection implements IRawConnection {
1925
public readonly type = 'raw';
@@ -36,7 +42,7 @@ export class RawNotebookProviderBase implements IRawNotebookProvider {
3642
}
3743
// Keep track of the notebooks that we have provided
3844
private notebooks = new Map<string, Promise<INotebook>>();
39-
private rawConnection = new RawConnection();
45+
private rawConnection: IRawConnection | undefined;
4046
private _id = uuid();
4147

4248
constructor(
@@ -47,7 +53,17 @@ export class RawNotebookProviderBase implements IRawNotebookProvider {
4753
this.asyncRegistry.push(this);
4854
}
4955

50-
public connect(): Promise<IRawConnection> {
56+
public connect(options: ConnectNotebookProviderOptions): Promise<IRawConnection | undefined> {
57+
// For getOnly, we don't want to create a connection, even though we don't have a server
58+
// here we only want to be "connected" when requested to mimic jupyter server function
59+
if (options.getOnly) {
60+
return Promise.resolve(this.rawConnection);
61+
}
62+
63+
// If not get only, create if needed and return
64+
if (!this.rawConnection) {
65+
this.rawConnection = new RawConnection();
66+
}
5167
return Promise.resolve(this.rawConnection);
5268
}
5369

@@ -87,6 +103,11 @@ export class RawNotebookProviderBase implements IRawNotebookProvider {
87103
}
88104

89105
protected getConnection(): IRawConnection {
106+
// At the time of getConnection force a connection if not created already
107+
// should always have happened already, but the check here lets us avoid returning undefined option
108+
if (!this.rawConnection) {
109+
this.rawConnection = new RawConnection();
110+
}
90111
return this.rawConnection;
91112
}
92113

src/client/datascience/raw-kernel/rawNotebookProviderWrapper.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ import { IRoleBasedObject, RoleBasedFactory } from '../jupyter/liveshare/roleBas
2323
import { ILiveShareHasRole } from '../jupyter/liveshare/types';
2424
import { IKernelLauncher } from '../kernel-launcher/types';
2525
import { ProgressReporter } from '../progress/progressReporter';
26-
import { IDataScience, INotebook, IRawConnection, IRawNotebookProvider, IRawNotebookSupportedService } from '../types';
26+
import {
27+
ConnectNotebookProviderOptions,
28+
IDataScience,
29+
INotebook,
30+
IRawConnection,
31+
IRawNotebookProvider,
32+
IRawNotebookSupportedService
33+
} from '../types';
2734
import { GuestRawNotebookProvider } from './liveshare/guestRawNotebookProvider';
2835
import { HostRawNotebookProvider } from './liveshare/hostRawNotebookProvider';
2936

@@ -104,9 +111,9 @@ export class RawNotebookProviderWrapper implements IRawNotebookProvider, ILiveSh
104111
return notebookProvider.supported();
105112
}
106113

107-
public async connect(): Promise<IRawConnection> {
114+
public async connect(options: ConnectNotebookProviderOptions): Promise<IRawConnection | undefined> {
108115
const notebookProvider = await this.serverFactory.get();
109-
return notebookProvider.connect();
116+
return notebookProvider.connect(options);
110117
}
111118

112119
public async createNotebook(

src/client/datascience/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export interface IRawNotebookSupportedService {
152152
export const IRawNotebookProvider = Symbol('IRawNotebookProvider');
153153
export interface IRawNotebookProvider extends IAsyncDisposable {
154154
supported(): Promise<boolean>;
155-
connect(token?: CancellationToken): Promise<IRawConnection>;
155+
connect(connect: ConnectNotebookProviderOptions): Promise<IRawConnection | undefined>;
156156
createNotebook(
157157
identity: Uri,
158158
resource: Resource,

0 commit comments

Comments
 (0)