mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 02:48:30 -05:00
deploy BDC wizard improvement for CU1 (#7756)
* unified admin user account (#7485) * azdata changes * spaces * error message * comments * support AD authentication for bdc deployment (#7518) * enable ad authentication * remove export for internal interface * add comments * more changes after testing * update notebooks * escape slash * more comments * Update deploy-bdc-aks.ipynb * Update deploy-bdc-existing-aks.ipynb * Update deploy-bdc-existing-kubeadm.ipynb * AD changes and review feedback (#7618) * enable ad authentication * remove export for internal interface * add comments * more changes after testing * update notebooks * escape slash * more comments * Update deploy-bdc-aks.ipynb * Update deploy-bdc-existing-aks.ipynb * Update deploy-bdc-existing-kubeadm.ipynb * address comments from scenario review (#7546) * support AD authentication for bdc deployment (#7518) * enable ad authentication * remove export for internal interface * add comments * more changes after testing * update notebooks * escape slash * more comments * Update deploy-bdc-aks.ipynb * Update deploy-bdc-existing-aks.ipynb * Update deploy-bdc-existing-kubeadm.ipynb * scenario review feedbacks * more fixes * adjust the display order of resource types * different way to implement left side buttons * revert unwanted changes * rename variable * more fixes for the scenario review feedback (#7589) * fix more issues * add help links * model view readonly text with links * fix size string * address comments * update notebooks * text update * address the feedback of 2nd round of deploy BDC wizard review (#7646) * 2nd review meeting comments * fix the unit test failure * recent changes in azdata * notebook background execution with azdata (#7741) * notebook background execution with azdata * prompt to open notebook in case of failure * fix path quote issue * better temp file handling * expose docker settings (#7751) * add docker settings * new icon for container image
This commit is contained in:
@@ -10,10 +10,32 @@ import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { IPlatformService } from './platformService';
|
||||
import { NotebookInfo } from '../interfaces';
|
||||
import { getErrorMessage, getDateTimeString } from '../utils';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export interface Notebook {
|
||||
cells: NotebookCell[];
|
||||
}
|
||||
|
||||
export interface NotebookCell {
|
||||
cell_type: 'code';
|
||||
source: string[];
|
||||
metadata: {};
|
||||
outputs: string[];
|
||||
execution_count: number;
|
||||
}
|
||||
|
||||
export interface NotebookExecutionResult {
|
||||
succeeded: boolean;
|
||||
outputNotebook?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
export interface INotebookService {
|
||||
launchNotebook(notebook: string | NotebookInfo): Thenable<azdata.nb.NotebookEditor>;
|
||||
launchNotebookWithContent(title: string, content: string): Thenable<azdata.nb.NotebookEditor>;
|
||||
getNotebook(notebook: string | NotebookInfo): Promise<Notebook>;
|
||||
executeNotebook(notebook: any, env: NodeJS.ProcessEnv): Promise<NotebookExecutionResult>;
|
||||
}
|
||||
|
||||
export class NotebookService implements INotebookService {
|
||||
@@ -21,32 +43,89 @@ export class NotebookService implements INotebookService {
|
||||
constructor(private platformService: IPlatformService, private extensionPath: string) { }
|
||||
|
||||
/**
|
||||
* Copy the notebook to the user's home directory and launch the notebook from there.
|
||||
* Launch notebook with file path
|
||||
* @param notebook the path of the notebook
|
||||
*/
|
||||
launchNotebook(notebook: string | NotebookInfo): Thenable<azdata.nb.NotebookEditor> {
|
||||
const notebookPath = this.getNotebook(notebook);
|
||||
const notebookFullPath = path.join(this.extensionPath, notebookPath);
|
||||
return this.platformService.fileExists(notebookPath).then((notebookPathExists) => {
|
||||
if (notebookPathExists) {
|
||||
return this.showNotebookAsUntitled(notebookPath);
|
||||
} else {
|
||||
return this.platformService.fileExists(notebookFullPath).then(notebookFullPathExists => {
|
||||
if (notebookFullPathExists) {
|
||||
return this.showNotebookAsUntitled(notebookFullPath);
|
||||
} else {
|
||||
throw localize('resourceDeployment.notebookNotFound', "The notebook {0} does not exist", notebookPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this.getNotebookFullPath(notebook).then(notebookPath => {
|
||||
return this.showNotebookAsUntitled(notebookPath);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch notebook with file path
|
||||
* @param title the title of the notebook
|
||||
* @param content the notebook content
|
||||
*/
|
||||
launchNotebookWithContent(title: string, content: string): Thenable<azdata.nb.NotebookEditor> {
|
||||
const uri: vscode.Uri = vscode.Uri.parse(`untitled:${title}`);
|
||||
return azdata.nb.showNotebookDocument(uri, {
|
||||
connectionProfile: undefined,
|
||||
preview: false,
|
||||
initialContent: content,
|
||||
initialDirtyState: false
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async getNotebook(notebook: string | NotebookInfo): Promise<Notebook> {
|
||||
const notebookPath = await this.getNotebookFullPath(notebook);
|
||||
return <Notebook>JSON.parse(await this.platformService.readTextFile(notebookPath));
|
||||
}
|
||||
|
||||
async executeNotebook(notebook: Notebook, env: NodeJS.ProcessEnv): Promise<NotebookExecutionResult> {
|
||||
const content = JSON.stringify(notebook, undefined, 4);
|
||||
const fileName = `nb-${getDateTimeString()}.ipynb`;
|
||||
const workingDirectory = this.platformService.storagePath();
|
||||
const notebookFullPath = path.join(workingDirectory, fileName);
|
||||
const outputFullPath = path.join(workingDirectory, `output-${fileName}`);
|
||||
try {
|
||||
await this.platformService.saveTextFile(content, notebookFullPath);
|
||||
await this.platformService.runCommand(`azdata notebook run --path "${notebookFullPath}" --output-path "${workingDirectory}" --timeout -1`,
|
||||
{
|
||||
additionalEnvironmentVariables: env,
|
||||
workingDirectory: workingDirectory
|
||||
});
|
||||
return {
|
||||
succeeded: true
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
const outputExists = await this.platformService.fileExists(outputFullPath);
|
||||
return {
|
||||
succeeded: false,
|
||||
outputNotebook: outputExists ? await this.platformService.readTextFile(outputFullPath) : undefined,
|
||||
errorMessage: getErrorMessage(error)
|
||||
};
|
||||
} finally {
|
||||
this.platformService.deleteFile(notebookFullPath);
|
||||
this.platformService.deleteFile(outputFullPath);
|
||||
}
|
||||
}
|
||||
|
||||
async getNotebookFullPath(notebook: string | NotebookInfo): Promise<string> {
|
||||
const notebookPath = this.getNotebookPath(notebook);
|
||||
let notebookExists = await this.platformService.fileExists(notebookPath);
|
||||
if (notebookExists) {
|
||||
// this is for the scenarios when the provider is in a different extension, the full path will be passed in.
|
||||
return notebookPath;
|
||||
}
|
||||
|
||||
// this is for the scenarios in this extension, the notebook paths are relative path.
|
||||
const absolutePath = path.join(this.extensionPath, notebookPath);
|
||||
notebookExists = await this.platformService.fileExists(absolutePath);
|
||||
if (notebookExists) {
|
||||
return absolutePath;
|
||||
} else {
|
||||
throw new Error(localize('resourceDeployment.notebookNotFound', "The notebook {0} does not exist", notebookPath));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the notebook path for current platform
|
||||
* @param notebook the notebook path
|
||||
*/
|
||||
getNotebook(notebook: string | NotebookInfo): string {
|
||||
getNotebookPath(notebook: string | NotebookInfo): string {
|
||||
let notebookPath;
|
||||
if (notebook && !isString(notebook)) {
|
||||
const platform = this.platformService.platform();
|
||||
|
||||
Reference in New Issue
Block a user