support multiple flavor of notebooks (#12159)

* support multiple flavor of notebooks

* update resource

* comments
This commit is contained in:
Alan Ren
2020-09-08 16:07:55 -07:00
committed by GitHub
parent f6c63f2dcb
commit e2b5e9bd66
5 changed files with 49 additions and 20 deletions

View File

@@ -93,7 +93,7 @@
"providers": [
{
"dialog": {
"notebook": "%sql-2017-docker-notebook%",
"notebook": "./notebooks/docker/2017/deploy-sql2017-image.ipynb",
"title": "%docker-sql-2017-title%",
"name": "docker-sql-2017-dialog",
"tabs": [
@@ -144,7 +144,7 @@
},
{
"dialog": {
"notebook": "%sql-2019-docker-notebook%",
"notebook": "./notebooks/docker/2019/deploy-sql2019-image.ipynb",
"title": "%docker-sql-2019-title%",
"name": "docker-sql-2019-dialog",
"tabs": [
@@ -247,7 +247,7 @@
{
"bdcWizard": {
"type": "new-aks",
"notebook": "%bdc-2019-aks-notebook%"
"notebook": "./notebooks/bdc/2019/deploy-bdc-aks.ipynb"
},
"requiredTools": [
{
@@ -267,7 +267,7 @@
{
"bdcWizard": {
"type": "existing-aks",
"notebook": "%bdc-2019-existing-aks-notebook%"
"notebook": "./notebooks/bdc/2019/deploy-bdc-existing-aks.ipynb"
},
"requiredTools": [
{
@@ -284,7 +284,7 @@
{
"bdcWizard": {
"type": "existing-kubeadm",
"notebook": "%bdc-2019-existing-kubeadm-notebook%"
"notebook": "./notebooks/bdc/2019/deploy-bdc-existing-kubeadm.ipynb"
},
"requiredTools": [
{
@@ -301,7 +301,7 @@
{
"bdcWizard": {
"type": "existing-aro",
"notebook": "%bdc-2019-existing-aro-notebook%"
"notebook": "./notebooks/bdc/2019/deploy-bdc-existing-aro.ipynb"
},
"requiredTools": [
{
@@ -318,7 +318,7 @@
{
"bdcWizard": {
"type": "existing-openshift",
"notebook": "%bdc-2019-existing-openshift-notebook%"
"notebook": "./notebooks/bdc/2019/deploy-bdc-existing-openshift.ipynb"
},
"requiredTools": [
{

View File

@@ -10,8 +10,6 @@
"version-display-name": "Version",
"sql-2017-display-name": "SQL Server 2017",
"sql-2019-display-name": "SQL Server 2019",
"sql-2017-docker-notebook": "./notebooks/docker/2017/deploy-sql2017-image.ipynb",
"sql-2019-docker-notebook": "./notebooks/docker/2019/deploy-sql2019-image.ipynb",
"bdc-2019-display-name": "SQL Server 2019",
"bdc-deployment-target": "Deployment target",
"bdc-deployment-target-new-aks": "New Azure Kubernetes Service Cluster",
@@ -19,11 +17,6 @@
"bdc-deployment-target-existing-kubeadm": "Existing Kubernetes Cluster (kubeadm)",
"bdc-deployment-target-existing-aro": "Existing Azure Red Hat OpenShift cluster",
"bdc-deployment-target-existing-openshift": "Existing OpenShift cluster",
"bdc-2019-aks-notebook": "./notebooks/bdc/2019/deploy-bdc-aks.ipynb",
"bdc-2019-existing-aks-notebook": "./notebooks/bdc/2019/deploy-bdc-existing-aks.ipynb",
"bdc-2019-existing-kubeadm-notebook": "./notebooks/bdc/2019/deploy-bdc-existing-kubeadm.ipynb",
"bdc-2019-existing-aro-notebook": "./notebooks/bdc/2019/deploy-bdc-existing-aro.ipynb",
"bdc-2019-existing-openshift-notebook": "./notebooks/bdc/2019/deploy-bdc-existing-openshift.ipynb",
"docker-sql-2017-title": "Deploy SQL Server 2017 container images",
"docker-sql-2019-title": "Deploy SQL Server 2019 container images",
"docker-container-name-field": "Container name",

View File

@@ -125,7 +125,7 @@ export interface NotebookWizardPageInfo extends PageInfoBase {
description?: string;
}
export interface NotebookBasedDialogInfo extends DialogInfoBase {
notebook: string | NotebookPathInfo;
notebook: string | NotebookPathInfo | NotebookInfo[];
runNotebook?: boolean;
taskName?: string;
}
@@ -298,6 +298,14 @@ export interface NotebookPathInfo {
linux: string;
}
export interface NotebookInfo {
/**
* Type of the notebook, for example: powershell, python...
*/
type: string;
path: string;
}
export enum OsDistribution {
win32 = 'win32',
darwin = 'darwin',

View File

@@ -13,7 +13,7 @@ import * as nls from 'vscode-nls';
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 } from '../interfaces';
import { ResourceType, ResourceTypeOption, NotebookPathInfo, DeploymentProvider, instanceOfWizardDeploymentProvider, instanceOfDialogDeploymentProvider, instanceOfNotebookDeploymentProvider, instanceOfDownloadDeploymentProvider, instanceOfWebPageDeploymentProvider, instanceOfCommandDeploymentProvider, instanceOfNotebookBasedDialogInfo, instanceOfNotebookWizardDeploymentProvider, NotebookInfo } from '../interfaces';
import { DeployClusterWizard } from '../ui/deployClusterWizard/deployClusterWizard';
import { DeploymentInputDialog } from '../ui/deploymentInputDialog';
@@ -77,10 +77,14 @@ export class ResourceTypeService implements IResourceTypeService {
});
}
private updateNotebookPath(objWithNotebookProperty: { notebook: string | NotebookPathInfo } | undefined, extensionPath: string): void {
private updateNotebookPath(objWithNotebookProperty: { notebook: string | NotebookPathInfo | NotebookInfo[] } | undefined, extensionPath: string): void {
if (objWithNotebookProperty && objWithNotebookProperty.notebook) {
if (typeof objWithNotebookProperty.notebook === 'string') {
objWithNotebookProperty.notebook = path.join(extensionPath, objWithNotebookProperty.notebook);
} else if (Array.isArray(objWithNotebookProperty.notebook)) {
objWithNotebookProperty.notebook.forEach(nb => {
nb.path = path.join(extensionPath, nb.path);
});
} else {
if (objWithNotebookProperty.notebook.darwin) {
objWithNotebookProperty.notebook.darwin = path.join(extensionPath, objWithNotebookProperty.notebook.darwin);

View File

@@ -7,7 +7,7 @@ import * as azdata from 'azdata';
import { EOL } from 'os';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { DialogInfo, instanceOfNotebookBasedDialogInfo, NotebookBasedDialogInfo } from '../interfaces';
import { DialogInfo, instanceOfNotebookBasedDialogInfo, NotebookBasedDialogInfo, FieldType, NotebookPathInfo } from '../interfaces';
import { INotebookService } from '../services/notebookService';
import { IPlatformService } from '../services/platformService';
import { DialogBase } from './dialogBase';
@@ -17,6 +17,8 @@ import { IToolsService } from '../services/toolsService';
const localize = nls.loadMessageBundle();
const NotebookTypeVariableName: string = 'SYS_NotebookType';
export class DeploymentInputDialog extends DialogBase {
private inputComponents: InputComponents = {};
@@ -41,6 +43,25 @@ export class DeploymentInputDialog extends DialogBase {
protected initialize() {
const self = this;
const validators: Validator[] = [];
if (this.dialogInfo.tabs.length > 0
&& instanceOfNotebookBasedDialogInfo(this.dialogInfo)
&& Array.isArray(this.dialogInfo.notebook)) {
// Add the notebook type field to the dialog
this.dialogInfo.tabs[0].sections.push(
{
fields: [
{
type: FieldType.Options,
label: localize('notebookType', 'Notebook type'),
options: this.dialogInfo.notebook.map(nb => nb.type),
variableName: NotebookTypeVariableName
}
]
}
);
}
initializeDialog({
dialogInfo: this.dialogInfo,
container: this._dialogObject,
@@ -81,7 +102,10 @@ export class DeploymentInputDialog extends DialogBase {
if (this.dialogInfo.runNotebook) {
this.executeNotebook(this.dialogInfo);
} else {
this.notebookService.launchNotebook(this.dialogInfo.notebook).then(() => { }, (error) => {
const notebook = Array.isArray(this.dialogInfo.notebook) ?
this.dialogInfo.notebook.find(nb => nb.type === model.getStringValue(NotebookTypeVariableName))?.path :
this.dialogInfo.notebook;
this.notebookService.launchNotebook(notebook!).catch(error => {
vscode.window.showErrorMessage(error);
});
}
@@ -91,6 +115,6 @@ export class DeploymentInputDialog extends DialogBase {
}
private executeNotebook(notebookDialogInfo: NotebookBasedDialogInfo): void {
this.notebookService.backgroundExecuteNotebook(notebookDialogInfo.taskName, notebookDialogInfo.notebook, 'deploy', this.platformService);
this.notebookService.backgroundExecuteNotebook(notebookDialogInfo.taskName, notebookDialogInfo.notebook as string | NotebookPathInfo, 'deploy', this.platformService);
}
}