mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
GenerateToNotebook and Deploy buttons for Notebook Wizards (#12656)
* enable userChooses how to run notebook * arc ext changes * nb fixes * working version * revert unneeded changes * fix comments * Update interfaces.ts * fix comments * fix comments * fix comments * runAllCells instead of background execute * pr feedback * PR feedback * pr feedback * arc ext changes for new WizardInfo syntax * fix doc comments * pr feedback
This commit is contained in:
@@ -33,9 +33,9 @@ export interface NotebookExecutionResult {
|
||||
}
|
||||
|
||||
export interface INotebookService {
|
||||
launchNotebook(notebook: string | NotebookPathInfo): Promise<azdata.nb.NotebookEditor>;
|
||||
launchNotebookWithEdits(notebook: string | NotebookPathInfo, cellStatements: string[], insertionPosition?: number): Promise<void>;
|
||||
launchNotebookWithContent(title: string, content: string): Promise<azdata.nb.NotebookEditor>;
|
||||
openNotebook(notebook: string | NotebookPathInfo): Promise<azdata.nb.NotebookEditor>;
|
||||
openNotebookWithEdits(notebook: string | NotebookPathInfo, cellStatements: string[], insertionPosition?: number): Promise<azdata.nb.NotebookEditor>;
|
||||
openNotebookWithContent(title: string, content: string): Promise<azdata.nb.NotebookEditor>;
|
||||
getNotebook(notebook: string | NotebookPathInfo): Promise<Notebook>;
|
||||
getNotebookPath(notebook: string | NotebookPathInfo): string;
|
||||
executeNotebook(notebook: any, env?: NodeJS.ProcessEnv): Promise<NotebookExecutionResult>;
|
||||
@@ -47,38 +47,39 @@ export class NotebookService implements INotebookService {
|
||||
constructor(private platformService: IPlatformService, private extensionPath: string) { }
|
||||
|
||||
/**
|
||||
* Launch notebook with file path
|
||||
* Open notebook with file path
|
||||
* @param notebook the path of the notebook
|
||||
*/
|
||||
async launchNotebook(notebook: string | NotebookPathInfo): Promise<azdata.nb.NotebookEditor> {
|
||||
async openNotebook(notebook: string | NotebookPathInfo): Promise<azdata.nb.NotebookEditor> {
|
||||
const notebookPath = await this.getNotebookFullPath(notebook);
|
||||
return await this.showNotebookAsUntitled(notebookPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts cell code given by {@param cellStatements} in an existing notebook given by {@param notebook} file path at the location
|
||||
* {@param insertionPosition} and then launches the edited notebook.
|
||||
* {@param insertionPosition} and then opens the edited notebook.
|
||||
*
|
||||
* @param notebook - the path to notebook that needs to be launched
|
||||
* @param notebook - the path to notebook that needs to be opened
|
||||
* @param cellStatements - array of statements to be inserted in a cell
|
||||
* @param insertionPosition - the position at which cells are inserted. Default is a new cell at the beginning of the notebook.
|
||||
*/
|
||||
async launchNotebookWithEdits(notebook: string, cellStatements: string[], insertionPosition: number = 0): Promise<void> {
|
||||
const openedNotebook = await this.launchNotebook(notebook);
|
||||
async openNotebookWithEdits(notebook: string, cellStatements: string[], insertionPosition: number = 0): Promise<azdata.nb.NotebookEditor> {
|
||||
const openedNotebook = await this.openNotebook(notebook);
|
||||
await openedNotebook.edit((editBuilder: azdata.nb.NotebookEditorEdit) => {
|
||||
editBuilder.insertCell({
|
||||
cell_type: 'code',
|
||||
source: cellStatements
|
||||
}, insertionPosition);
|
||||
});
|
||||
return openedNotebook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch notebook with file path
|
||||
* Open notebook with given contents
|
||||
* @param title the title of the notebook
|
||||
* @param content the notebook content
|
||||
*/
|
||||
async launchNotebookWithContent(title: string, content: string): Promise<azdata.nb.NotebookEditor> {
|
||||
async openNotebookWithContent(title: string, content: string): Promise<azdata.nb.NotebookEditor> {
|
||||
const uri: vscode.Uri = vscode.Uri.parse(`untitled:${this.findNextUntitledEditorName(title)}`);
|
||||
return await azdata.nb.showNotebookDocument(uri, {
|
||||
connectionProfile: undefined,
|
||||
@@ -150,11 +151,11 @@ export class NotebookService implements INotebookService {
|
||||
platformService.logToOutputChannel(taskFailedMessage);
|
||||
if (selectedOption === viewErrorDetail) {
|
||||
try {
|
||||
await this.launchNotebookWithContent(`${tempNotebookPrefix}-${getDateTimeString()}`, result.outputNotebook);
|
||||
await this.openNotebookWithContent(`${tempNotebookPrefix}-${getDateTimeString()}`, result.outputNotebook);
|
||||
} catch (error) {
|
||||
const launchNotebookError = localize('resourceDeployment.FailedToOpenNotebook', "An error occurred launching the output notebook. {1}{2}.", EOL, getErrorMessage(error));
|
||||
platformService.logToOutputChannel(launchNotebookError);
|
||||
vscode.window.showErrorMessage(launchNotebookError);
|
||||
const openNotebookError = localize('resourceDeployment.FailedToOpenNotebook', "An error occurred opening the output notebook. {1}{2}.", EOL, getErrorMessage(error));
|
||||
platformService.logToOutputChannel(openNotebookError);
|
||||
vscode.window.showErrorMessage(openNotebookError);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -10,17 +10,17 @@ import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { DeploymentProvider, instanceOfAzureSQLVMDeploymentProvider, instanceOfCommandDeploymentProvider, instanceOfDialogDeploymentProvider, instanceOfDownloadDeploymentProvider, instanceOfNotebookBasedDialogInfo, instanceOfNotebookDeploymentProvider, instanceOfNotebookWizardDeploymentProvider, instanceOfWebPageDeploymentProvider, instanceOfWizardDeploymentProvider, NotebookInfo, NotebookPathInfo, ResourceType, ResourceTypeOption } from '../interfaces';
|
||||
import { DeployAzureSQLVMWizard } from '../ui/deployAzureSQLVMWizard/deployAzureSQLVMWizard';
|
||||
import { DeployClusterWizard } from '../ui/deployClusterWizard/deployClusterWizard';
|
||||
import { DeploymentInputDialog } from '../ui/deploymentInputDialog';
|
||||
import { NotebookWizard } from '../ui/notebookWizard/notebookWizard';
|
||||
import { AzdataService } from './azdataService';
|
||||
import { KubeService } from './kubeService';
|
||||
import { INotebookService } from './notebookService';
|
||||
import { IPlatformService } from './platformService';
|
||||
import { IToolsService } from './toolsService';
|
||||
import { ResourceType, ResourceTypeOption, NotebookPathInfo, DeploymentProvider, instanceOfWizardDeploymentProvider, instanceOfDialogDeploymentProvider, instanceOfNotebookDeploymentProvider, instanceOfDownloadDeploymentProvider, instanceOfWebPageDeploymentProvider, instanceOfCommandDeploymentProvider, instanceOfNotebookBasedDialogInfo, instanceOfNotebookWizardDeploymentProvider, NotebookInfo, instanceOfAzureSQLVMDeploymentProvider } from '../interfaces';
|
||||
import { DeployClusterWizard } from '../ui/deployClusterWizard/deployClusterWizard';
|
||||
import { DeploymentInputDialog } from '../ui/deploymentInputDialog';
|
||||
|
||||
import { KubeService } from './kubeService';
|
||||
import { AzdataService } from './azdataService';
|
||||
import { NotebookWizard } from '../ui/notebookWizard/notebookWizard';
|
||||
import { DeployAzureSQLVMWizard } from '../ui/deployAzureSQLVMWizard/deployAzureSQLVMWizard';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export interface IResourceTypeService {
|
||||
@@ -257,7 +257,7 @@ export class ResourceTypeService implements IResourceTypeService {
|
||||
const dialog = new DeploymentInputDialog(this.notebookService, this.platformService, this.toolsService, provider.dialog);
|
||||
dialog.open();
|
||||
} else if (instanceOfNotebookDeploymentProvider(provider)) {
|
||||
this.notebookService.launchNotebook(provider.notebook);
|
||||
this.notebookService.openNotebook(provider.notebook);
|
||||
} else if (instanceOfDownloadDeploymentProvider(provider)) {
|
||||
const taskName = localize('resourceDeployment.DownloadAndLaunchTaskName', "Download and launch installer, URL: {0}", provider.downloadUrl);
|
||||
azdata.tasks.startBackgroundOperation({
|
||||
|
||||
Reference in New Issue
Block a user