mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 09:35:39 -05:00
Mitigate (but not fully fix) Run Cell from disconnected notebook (#4960)
This is a partial fix that lays groundwork for full "Prompt to connect" if a kernel needs a connection. I am waiting on Yurong's refactoring of connection handling before doing any of the prompt work. - Adds kernel metadata about whether a connection is required. - For Jupyter, only Spark kernels are listed as requiring a connection - If this is true and there's no active connection, will show notification and not call execute In the future, this path will still be used if user is prompted to connect and cancels out. The future change will be to inject a "connect" handler from notebook.component to the cell callback and use to set connection context
This commit is contained in:
@@ -465,6 +465,7 @@ export interface INotebookKernelDetails {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly supportsIntellisense: boolean;
|
||||
readonly requiresConnection: boolean;
|
||||
readonly info?: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,8 @@ export class ExtHostNotebook implements ExtHostNotebookShape {
|
||||
id: kernel.id,
|
||||
info: kernel.info,
|
||||
name: kernel.name,
|
||||
supportsIntellisense: kernel.supportsIntellisense
|
||||
supportsIntellisense: kernel.supportsIntellisense,
|
||||
requiresConnection: kernel.requiresConnection
|
||||
};
|
||||
return kernelDetails;
|
||||
}
|
||||
|
||||
@@ -352,6 +352,10 @@ class KernelWrapper implements azdata.nb.IKernel {
|
||||
return this.kernelDetails.supportsIntellisense;
|
||||
}
|
||||
|
||||
get requiresConnection(): boolean {
|
||||
return this.kernelDetails.requiresConnection;
|
||||
}
|
||||
|
||||
get info(): azdata.nb.IInfoReply {
|
||||
return this._info;
|
||||
}
|
||||
|
||||
@@ -210,6 +210,10 @@ export class CellModel implements ICellModel {
|
||||
await kernel.interrupt();
|
||||
} else {
|
||||
// TODO update source based on editor component contents
|
||||
if (kernel.requiresConnection && !this.notebookModel.activeConnection) {
|
||||
this.sendNotification(notificationService, Severity.Error, localize('kernelRequiresConnection', "Please select a connection to run cells for this kernel"));
|
||||
return false;
|
||||
}
|
||||
let content = this.source;
|
||||
if (content) {
|
||||
let future = await kernel.requestExecute({
|
||||
|
||||
@@ -116,6 +116,10 @@ class EmptyKernel implements nb.IKernel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public get requiresConnection(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public get isReady(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -179,6 +179,10 @@ class SqlKernel extends Disposable implements nb.IKernel {
|
||||
return true;
|
||||
}
|
||||
|
||||
public get requiresConnection(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
public get isReady(): boolean {
|
||||
// should we be checking on the tools service status here?
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user