mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
* Fix #4356 New Notebook from connection doesn't connect Fix new notebook error by passing profile instead of ID. - I could've just sent the ID over, but this fix sets the stage for disconnected connections to work (since we have enough info to properly connect). - There's a bug in NotebookModel blocking the disconnected connection part working, but Yurong's in progress fixes will unblock this. Hence checking in as-is and working to properly unblock once that's in. * Support connection profile in commandline service - Added new context API for things that want to work on commandline and object explorer - Refactored commandlineservice slightly to be async & have a simpler execution flow (far fewer if/else statements) * Fix unit tests - Fixed 2 issues raised by tests (sholdn't do new query if no profile passed, shouldn't error on new query failing) - Updated unit tests to pass as expected given changes to the APIs.
This commit is contained in:
@@ -25,8 +25,12 @@ let counter = 0;
|
||||
export let controller: JupyterController;
|
||||
|
||||
export function activate(extensionContext: vscode.ExtensionContext) {
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', (connectionId?: string) => {
|
||||
newNotebook(connectionId);
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', (context?: azdata.ConnectedContext) => {
|
||||
let connectionProfile: azdata.IConnectionProfile = undefined;
|
||||
if (context && context.connectionProfile) {
|
||||
connectionProfile = context.connectionProfile;
|
||||
}
|
||||
newNotebook(connectionProfile);
|
||||
}));
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.open', () => {
|
||||
openNotebook();
|
||||
@@ -49,15 +53,15 @@ export function activate(extensionContext: vscode.ExtensionContext) {
|
||||
controller.activate();
|
||||
}
|
||||
|
||||
function newNotebook(connectionId: string) {
|
||||
function newNotebook(connectionProfile: azdata.IConnectionProfile) {
|
||||
let title = `Untitled-${counter++}`;
|
||||
let untitledUri = vscode.Uri.parse(`untitled:${title}`);
|
||||
let options: azdata.nb.NotebookShowOptions = connectionId ? {
|
||||
let options: azdata.nb.NotebookShowOptions = connectionProfile ? {
|
||||
viewColumn: null,
|
||||
preserveFocus: true,
|
||||
preview: null,
|
||||
providerId: null,
|
||||
connectionId: connectionId,
|
||||
connectionProfile: connectionProfile,
|
||||
defaultKernel: null
|
||||
} : null;
|
||||
azdata.nb.showNotebookDocument(untitledUri, options).then(success => {
|
||||
@@ -122,7 +126,7 @@ async function analyzeNotebook(oeContext?: azdata.ObjectExplorerContext): Promis
|
||||
let untitledUri = vscode.Uri.parse(`untitled:Notebook-${counter++}`);
|
||||
|
||||
let editor = await azdata.nb.showNotebookDocument(untitledUri, {
|
||||
connectionId: oeContext ? oeContext.connectionProfile.id : '',
|
||||
connectionProfile: oeContext ? oeContext.connectionProfile : undefined,
|
||||
providerId: JUPYTER_NOTEBOOK_PROVIDER,
|
||||
preview: false,
|
||||
defaultKernel: {
|
||||
|
||||
@@ -65,11 +65,11 @@ describe('Notebook Integration Test', function (): void {
|
||||
await ensureJupyterInstalled();
|
||||
|
||||
// Given a connection to a server exists
|
||||
let connectionId = await connectToSparkIntegrationServer();
|
||||
let connectionProfile = await connectToSparkIntegrationServer();
|
||||
|
||||
// When I open a Spark notebook and run the cell
|
||||
let notebook = await azdata.nb.showNotebookDocument(uri, {
|
||||
connectionId: connectionId
|
||||
connectionProfile: connectionProfile
|
||||
});
|
||||
should(notebook.document.cells).have.length(1);
|
||||
let ran = await notebook.runCell(notebook.document.cells[0]);
|
||||
@@ -90,7 +90,7 @@ describe('Notebook Integration Test', function (): void {
|
||||
});
|
||||
});
|
||||
|
||||
async function connectToSparkIntegrationServer(): Promise<string> {
|
||||
async function connectToSparkIntegrationServer(): Promise<azdata.IConnectionProfile> {
|
||||
assert.ok(process.env.BACKEND_HOSTNAME, 'BACKEND_HOSTNAME, BACKEND_USERNAME, BACKEND_PWD must be set using ./tasks/setbackenvariables.sh or .\\tasks\\setbackendvaraibles.bat');
|
||||
let connInfo: azdata.connection.Connection = {
|
||||
options: {
|
||||
@@ -114,7 +114,7 @@ async function connectToSparkIntegrationServer(): Promise<string> {
|
||||
let activeConnections = await azdata.connection.getActiveConnections();
|
||||
should(activeConnections).have.length(1);
|
||||
|
||||
return result.connectionId;
|
||||
return <azdata.IConnectionProfile><any>connInfo;
|
||||
}
|
||||
|
||||
function writeNotebookToFile(pythonNotebook: INotebook): vscode.Uri {
|
||||
|
||||
@@ -152,7 +152,7 @@ export class JupyterController implements vscode.Disposable {
|
||||
this.apiWrapper.showErrorMessage(localize('unsupportedFileType', 'Only .ipynb Notebooks are supported'));
|
||||
} else {
|
||||
await azdata.nb.showNotebookDocument(fileUri, {
|
||||
connectionId: profile.id,
|
||||
connectionProfile: profile,
|
||||
providerId: constants.jupyterNotebookProviderId,
|
||||
preview: false
|
||||
});
|
||||
@@ -165,7 +165,7 @@ export class JupyterController implements vscode.Disposable {
|
||||
// to handle this. We should look into improving this in the future
|
||||
let untitledUri = vscode.Uri.parse(`untitled:Notebook-${untitledCounter++}`);
|
||||
let editor = await azdata.nb.showNotebookDocument(untitledUri, {
|
||||
connectionId: profile.id,
|
||||
connectionProfile: profile,
|
||||
providerId: constants.jupyterNotebookProviderId,
|
||||
preview: false,
|
||||
defaultKernel: {
|
||||
|
||||
Reference in New Issue
Block a user