From f003e615e76534188344cca2dd85d0eaaae8f1eb Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Thu, 24 Sep 2020 15:18:27 -0700 Subject: [PATCH 01/17] enable userChooses how to run notebook --- .../resource-deployment/src/interfaces.ts | 55 +++++++++++++++++-- .../src/localizedConstants.ts | 4 +- .../src/ui/notebookWizard/notebookWizard.ts | 27 +++++++-- .../resource-deployment/src/ui/wizardBase.ts | 9 ++- 4 files changed, 80 insertions(+), 15 deletions(-) diff --git a/extensions/resource-deployment/src/interfaces.ts b/extensions/resource-deployment/src/interfaces.ts index 8c1e4501c4cf..e49c8e538b8d 100644 --- a/extensions/resource-deployment/src/interfaces.ts +++ b/extensions/resource-deployment/src/interfaces.ts @@ -115,20 +115,67 @@ export interface BdcWizardInfo { type: BdcDeploymentType; } +/** + * if true - the python notebook is run as a background task at the end of the wizard, all input values are set as + * environment variables prior to notebook execution. @see actionText is used to configure the label of the done button. + * if false - the notebook is opened up in a new editor, all input values are transferred into a cell of the notebook as + * python variables. Except password variables which are set as environment variables into the jupyter kernel process that + * is used to execute the notebook. @see actionText is used to configure the label of the done button. + * if 'userChooses' - an additional button @see loc.scriptToNotebook is shown to the user at the end of the wizard. + * The default done button allows the user to execute the notebook as background task. @see actionText is used to configure the label of the done button, otherwise the behavior is same as when runNotebook was set to true. + * and scriptToNotebook button opens up the notebook in a new editor window. @see scriptToNotebookActionText is used to configure the label of the done button, otherwise the behavior is same asa when runNotebook was set to false. + * + */ +type RunNotebookType = false | true | 'userChooses'; + +/** + * This object defines the shape, form and behavior of a Notebook Wizard. + */ export interface NotebookWizardInfo extends WizardInfoBase { + /** + * path to python notebook that loaded/executed at the end of the wizard + */ notebook: string | NotebookPathInfo; - runNotebook?: boolean; + /** + * specifies the behavior at the end of the wizard. @see RunNotebookType for details. + */ + runNotebook?: RunNotebookType; + /** + * The label of additional scriptToNotebook button used when runNotebook is set to @see userChooses. + */ + scriptToNotebookActionText?: string; + /** + * 0 based position number where the variables values are inserted into the notebook as python statements. + */ codeCellInsertionPosition?: number; + /** + * This array defines the json for the pages of this wizard. + */ pages: NotebookWizardPageInfo[] } export interface WizardInfoBase extends FieldInfoBase { + /** + * the taskName to use when running the notebook as a background task. The default value is the @see title of the wizard. + */ taskName?: string; type?: DeploymentType; + /** + * The done button label to end the wizard. + */ actionText?: string; + /** + * title displayed on every page of the wizard + */ title: string; name?: string; + /** + * This array defines the json for the pages of this wizard. + */ pages: PageInfoBase[]; + /** + * if true an auto generated summary page is inserted at the end of the wizard + */ isSummaryPageAutoGenerated?: boolean } @@ -401,11 +448,7 @@ export const enum BdcDeploymentType { ExistingOpenShift = 'existing-openshift' } -export const enum ArcDeploymentType { - NewControlPlane = 'new-control-plane' -} - -export type DeploymentType = ArcDeploymentType | BdcDeploymentType; +export type DeploymentType = BdcDeploymentType; export interface Command { command: string; diff --git a/extensions/resource-deployment/src/localizedConstants.ts b/extensions/resource-deployment/src/localizedConstants.ts index af6d852a0e8f..39733473d3fe 100644 --- a/extensions/resource-deployment/src/localizedConstants.ts +++ b/extensions/resource-deployment/src/localizedConstants.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vscode-nls'; -import { FieldType, OptionsType } from './interfaces'; import { OptionsSourceType } from './helpers/optionSources'; +import { FieldType, OptionsType } from './interfaces'; const localize = nls.loadMessageBundle(); @@ -37,3 +37,5 @@ export const optionsTypeRadioOrDropdown = localize('optionsTypeRadioOrDropdown', export const azdataEulaNotAccepted = localize('azdataEulaNotAccepted', "Deployment cannot continue. Azure Data CLI license terms have not yet been accepted. Please accept the EULA to enable the features that requires Azure Data CLI."); export const azdataEulaDeclined = localize('azdataEulaDeclined', "Deployment cannot continue. Azure Data CLI license terms were declined.You can either Accept EULA to continue or Cancel this operation"); export const acceptEulaAndSelect = localize('deploymentDialog.RecheckEulaButton', "Accept EULA & Select"); +export const scriptToNotebook = localize('ui.ScriptToNotebookButton', "Script to notebook"); +export const deployNotebook = localize('ui.DeployButton', "Deploy"); diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts index e3b7800ba6ad..0aad9cc7ce17 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts @@ -2,8 +2,9 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import * as azdata from 'azdata'; import * as vscode from 'vscode'; -import * as nls from 'vscode-nls'; +import * as loc from '../../localizedConstants'; import { INotebookService, Notebook } from '../../services/notebookService'; import { IToolsService } from '../../services/toolsService'; import { Model } from '../model'; @@ -14,8 +15,6 @@ import { IPlatformService } from './../../services/platformService'; import { NotebookWizardAutoSummaryPage } from './notebookWizardAutoSummaryPage'; import { NotebookWizardPage } from './notebookWizardPage'; -const localize = nls.loadMessageBundle(); - export class NotebookWizard extends WizardBase { private _inputComponents: InputComponents = {}; @@ -41,6 +40,12 @@ export class NotebookWizard extends WizardBase this.onScriptToNotebook() + ); + } } public get deploymentType(): DeploymentType | undefined { @@ -50,14 +55,26 @@ export class NotebookWizard extends WizardBase { + this.wizardInfo.runNotebook = false; + return this.finishWizard(); + } + protected async onOk(): Promise { + if (this.wizardInfo.runNotebook === 'userChooses') { + this.wizardInfo.runNotebook = true; + } + await this.finishWizard(); + } + + private async finishWizard() { await setModelValues(this.inputComponents, this.model); const env: NodeJS.ProcessEnv = {}; this.model.setEnvironmentVariables(env, (varName) => { @@ -87,7 +104,7 @@ export class NotebookWizard extends WizardBase, M extends Model> { @@ -54,8 +54,11 @@ export abstract class WizardBase, M extends Model protected abstract async onOk(): Promise; protected abstract onCancel(): void; - public addButton(button: azdata.window.Button) { + public addButton(button: azdata.window.Button, onClick?: () => void | Promise) { this.customButtons.push(button); + if (onClick) { + this.registerDisposable(button.onClick(onClick)); + } } protected setPages(pages: P[]) { From 602049bc5a2765207b11fca5cef554d4dca256c3 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Fri, 25 Sep 2020 00:53:39 -0700 Subject: [PATCH 02/17] arc ext changes --- .../deploy.arc.data.controller.ipynb | 33 ++++++++++++++++- .../deploy.postgres.existing.arc.ipynb | 36 +++++++++++++++++++ .../deploy.sql.existing.arc.ipynb | 29 +++++++++++++++ extensions/arc/package.json | 9 ++--- 4 files changed, 100 insertions(+), 7 deletions(-) diff --git a/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb index e61198cd277b..c0fa99e9f298 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb @@ -56,7 +56,7 @@ { "cell_type": "markdown", "source": [ - "### **Setup and Check Prerequisites**" + "### **Setup**" ], "metadata": { "azdata_cell_guid": "e3dd8e75-e15f-44b4-81fc-1f54d6f0b1e2" @@ -96,6 +96,37 @@ "azdata_cell_guid": "4b266b2d-bd1b-4565-92c9-3fc146cdce6d" } }, + { + "cell_type": "markdown", + "source": [ + "### **Set variable values from environment variables**" + ], + "metadata": { + "azdata_cell_guid": "4a19f4d4-1fd5-4898-b38e-3a3901754de9" + } + }, + { + "cell_type": "code", + "source": [ + "arc_config_file = arc_config_file or os.environ[\"ADATA_NB_VAR_ARC_CONFIG_FILE\"]\n", + "arc_cluster_context = arc_cluster_context or os.environ[\"ADATA_NB_VAR_ARC_CLUSTER_CONTEXT\"]\n", + "arc_profile = arc_profile or os.environ[\"ADATA_NB_VAR_ARC_PROFILE\"]\n", + "arc_admin_username = arc_admin_username or os.environ[\"ADATA_NB_VAR_ARC_ADMIN_USERNAME\"]\n", + "arc_subscription = arc_subscription or os.environ[\"ADATA_NB_VAR_ARC_SUBSCRIPTION\"]\n", + "arc_display_subscription = arc_display_subscription or os.environ[\"ADATA_NB_VAR_ARC_DISPLAY_SUBSCRIPTION\"]\n", + "arc_resource_group = arc_resource_group or os.environ[\"ADATA_NB_VAR_ARC_RESOURCE_GROUP\"]\n", + "arc_data_controller_namespace = arc_data_controller_namespace or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_NAMESPACE\"]\n", + "arc_data_controller_name = arc_data_controller_name or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_NAME\"]\n", + "arc_data_controller_storage_class = arc_data_controller_storage_class or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_STORAGE_CLASS\"]\n", + "arc_data_controller_location = arc_data_controller_location or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_LOCATION\"]\n", + "arc_data_controller_display_location = arc_data_controller_display_location or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_DISPLAY_LOCATION\"]" + ], + "metadata": { + "azdata_cell_guid": "e2cee548-0dcc-41e9-9807-ca8aaeb0ae1f" + }, + "outputs": [], + "execution_count": null + }, { "cell_type": "markdown", "source": [ diff --git a/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb index 1a31f4a91d35..8be376e1a872 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb @@ -99,6 +99,42 @@ "azdata_cell_guid": "68ec0760-27d1-4ded-9a9f-89077c40b8bb" } }, + { + "cell_type": "markdown", + "source": [ + "### **Set variable values from environment variables**" + ], + "metadata": { + "azdata_cell_guid": "36a1948a-4835-43e2-8d93-afbceca9222f" + } + }, + { + "cell_type": "code", + "source": [ + "postgres_server_group_cores_request = postgres_server_group_cores_request or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_CORES_REQUEST\"]\n", + "postgres_server_group_cores_limit = postgres_server_group_cores_limit or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_CORES_LIMIT\"]\n", + "postgres_server_group_memory_request = postgres_server_group_memory_request or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_MEMORY_REQUEST\"]\n", + "postgres_server_group_memory_limit = postgres_server_group_memory_limit or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_MEMORY_LIMIT\"]\n", + "postgres_server_group_name = postgres_server_group_name or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_NAME\"]\n", + "postgres_server_group_workers = postgres_server_group_workers or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_WORKERS\"]\n", + "postgres_server_group_port = postgres_server_group_port or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_PORT\"]\n", + "postgres_server_group_engine_version = postgres_server_group_engine_version or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_ENGINE_VERSION\"]\n", + "postgres_server_group_extensions = postgres_server_group_extensions or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_EXTENSIONS\"]\n", + "postgres_storage_class_data = postgres_storage_class_data or os.environ[\"ADATA_NB_VAR_POSTGRES_STORAGE_CLASS_DATA\"]\n", + "postgres_server_group_volume_size_data = postgres_server_group_volume_size_data or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_VOLUME_SIZE_DATA\"]\n", + "postgres_storage_class_logs = postgres_storage_class_logs or os.environ[\"ADATA_NB_VAR_POSTGRES_STORAGE_CLASS_LOGS\"]\n", + "postgres_server_group_volume_size_logs = postgres_server_group_volume_size_logs or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_VOLUME_SIZE_LOGS\"]\n", + "postgres_storage_class_backups = postgres_storage_class_backups or os.environ[\"ADATA_NB_VAR_POSTGRES_STORAGE_CLASS_BACKUPS\"]\n", + "postgres_server_group_volume_size_backups = postgres_server_group_volume_size_backups or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_VOLUME_SIZE_BACKUPS\"]\n", + "controller_endpoint = controller_endpoint or os.environ[\"ADATA_NB_VAR_CONTROLLER_ENDPOINT\"]\n", + "controller_username = controller_username or os.environ[\"ADATA_NB_VAR_CONTROLLER_USERNAME\"]" + ], + "metadata": { + "azdata_cell_guid": "ed798542-c292-4b9e-9abc-d9bf8abf4143" + }, + "outputs": [], + "execution_count": null + }, { "cell_type": "markdown", "source": [ diff --git a/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb index c05627d0ef70..1c5e46a784c2 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb @@ -99,6 +99,35 @@ "azdata_cell_guid": "68ec0760-27d1-4ded-9a9f-89077c40b8bb" } }, + { + "cell_type": "markdown", + "source": [ + "### **Set variable values from environment variables**" + ], + "metadata": { + "azdata_cell_guid": "c48a794b-8c31-48b7-904f-31aead666eae" + } + }, + { + "cell_type": "code", + "source": [ + "sql_instance_name = sql_instance_name or os.environ[\"ADATA_NB_VAR_SQL_INSTANCE_NAME\"]\n", + "sql_username = sql_username or os.environ[\"ADATA_NB_VAR_SQL_USERNAME\"]\n", + "sql_storage_class_data = sql_storage_class_data or os.environ[\"ADATA_NB_VAR_SQL_STORAGE_CLASS_DATA\"]\n", + "sql_storage_class_logs = sql_storage_class_logs or os.environ[\"ADATA_NB_VAR_SQL_STORAGE_CLASS_LOGS\"]\n", + "sql_cores_request = sql_cores_request or os.environ[\"ADATA_NB_VAR_SQL_CORES_REQUEST\"]\n", + "sql_cores_limit = sql_cores_limit or os.environ[\"ADATA_NB_VAR_SQL_CORES_LIMIT\"]\n", + "sql_memory_request = sql_memory_request or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_REQUEST\"]\n", + "sql_memory_limit = sql_memory_limit or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_LIMIT\"]\n", + "controller_endpoint = controller_endpoint or os.environ[\"ADATA_NB_VAR_CONTROLLER_ENDPOINT\"]\n", + "controller_username = controller_username or os.environ[\"ADATA_NB_VAR_CONTROLLER_USERNAME\"]" + ], + "metadata": { + "azdata_cell_guid": "69a96851-6b70-494f-8eb5-984652e88005" + }, + "outputs": [], + "execution_count": null + }, { "cell_type": "markdown", "source": [ diff --git a/extensions/arc/package.json b/extensions/arc/package.json index 6404080f931d..fea3bd3a49a5 100644 --- a/extensions/arc/package.json +++ b/extensions/arc/package.json @@ -144,9 +144,8 @@ "notebookWizard": { "notebook": "./notebooks/arcDeployment/deploy.arc.data.controller.ipynb", "type": "new-arc-control-plane", - "runNotebook": false, + "runNotebook": "userChooses", "codeCellInsertionPosition": 5, - "actionText": "%deploy.script.to.notebook.action%", "title": "%arc.data.controller.new.wizard.title%", "name": "arc.data.controller.new.wizard", "labelPosition": "left", @@ -521,9 +520,8 @@ { "notebookWizard": { "notebook": "./notebooks/arcDeployment/deploy.sql.existing.arc.ipynb", - "runNotebook": false, + "runNotebook": "userChooses", "codeCellInsertionPosition": 5, - "actionText": "%deploy.script.to.notebook.action%", "title": "%arc.sql.wizard.title%", "name": "arc.sql.wizard", "labelPosition": "left", @@ -682,9 +680,8 @@ { "notebookWizard": { "notebook": "./notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb", - "runNotebook": false, + "runNotebook": "userChooses", "codeCellInsertionPosition": 5, - "actionText": "%deploy.script.to.notebook.action%", "title": "%arc.postgres.wizard.title%", "name": "arc.postgres.wizard", "labelPosition": "left", From 505ed1a311391bd818ce789ea1e53ec9bc0f1339 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Mon, 28 Sep 2020 12:07:16 -0700 Subject: [PATCH 03/17] nb fixes --- .../arcDeployment/deploy.sql.existing.arc.ipynb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb index 1c5e46a784c2..290db1f1ecf4 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb @@ -115,10 +115,14 @@ "sql_username = sql_username or os.environ[\"ADATA_NB_VAR_SQL_USERNAME\"]\n", "sql_storage_class_data = sql_storage_class_data or os.environ[\"ADATA_NB_VAR_SQL_STORAGE_CLASS_DATA\"]\n", "sql_storage_class_logs = sql_storage_class_logs or os.environ[\"ADATA_NB_VAR_SQL_STORAGE_CLASS_LOGS\"]\n", - "sql_cores_request = sql_cores_request or os.environ[\"ADATA_NB_VAR_SQL_CORES_REQUEST\"]\n", - "sql_cores_limit = sql_cores_limit or os.environ[\"ADATA_NB_VAR_SQL_CORES_LIMIT\"]\n", - "sql_memory_request = sql_memory_request or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_REQUEST\"]\n", - "sql_memory_limit = sql_memory_limit or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_LIMIT\"]\n", + "if \"ADATA_NB_VAR_SQL_CORES_REQUEST\" in os.environ:\n", + " sql_cores_request = sql_cores_request or os.environ[\"ADATA_NB_VAR_SQL_CORES_REQUEST\"]\n", + "if \"AZDATA_NB_VAR_SQL_CORES_LIMIT\" in os.environ:\n", + " sql_cores_limit = sql_cores_limit or os.environ[\"ADATA_NB_VAR_SQL_CORES_LIMIT\"]\n", + "if \"ADATA_NB_VAR_SQL_MEMORY_REQUEST\" in os.environ:\n", + " sql_memory_request = sql_memory_request or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_REQUEST\"]\n", + "if \"ADATA_NB_VAR_SQL_MEMORY_LIMIT\" in os.environ:\n", + " sql_memory_limit = sql_memory_limit or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_LIMIT\"]\n", "controller_endpoint = controller_endpoint or os.environ[\"ADATA_NB_VAR_CONTROLLER_ENDPOINT\"]\n", "controller_username = controller_username or os.environ[\"ADATA_NB_VAR_CONTROLLER_USERNAME\"]" ], From 35ddcf1331807b747a1851d0815e38c5eed5e502 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Mon, 28 Sep 2020 23:32:31 -0700 Subject: [PATCH 04/17] working version --- .../src/ui/notebookWizard/notebookWizard.ts | 47 +++++++------------ .../ui/notebookWizard/notebookWizardPage.ts | 30 +++++++++++- .../resource-deployment/src/ui/wizardBase.ts | 42 ++++++++++++----- .../src/ui/wizardPageBase.ts | 7 ++- .../src/ui/wizardPageInfo.ts | 26 ++++++++++ 5 files changed, 109 insertions(+), 43 deletions(-) create mode 100644 extensions/resource-deployment/src/ui/wizardPageInfo.ts diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts index 0aad9cc7ce17..a0db02fc76d9 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as azdata from 'azdata'; import * as vscode from 'vscode'; import * as loc from '../../localizedConstants'; import { INotebookService, Notebook } from '../../services/notebookService'; @@ -39,13 +38,8 @@ export class NotebookWizard extends WizardBase this.onScriptToNotebook() - ); - } + this.wizardObject.doneButton.label = _wizardInfo.actionText || loc.deployNotebook; + this.wizardObject.generateScriptButton.label = _wizardInfo.scriptToNotebookActionText || loc.scriptToNotebook; } public get deploymentType(): DeploymentType | undefined { @@ -54,27 +48,32 @@ export class NotebookWizard extends WizardBase { - this.wizardInfo.runNotebook = false; - return this.finishWizard(); + protected async onGenerateScript(): Promise { + const { notebook, env } = await this.prepareNotebookAndEnvironment(); + try { + Object.assign(process.env, env); + const notebookPath = this.notebookService.getNotebookPath(this.wizardInfo.notebook); + await this.notebookService.launchNotebookWithContent(notebookPath, JSON.stringify(notebook, undefined, 4)); + } catch (error) { + vscode.window.showErrorMessage(error); + } } protected async onOk(): Promise { - if (this.wizardInfo.runNotebook === 'userChooses') { - this.wizardInfo.runNotebook = true; + const { notebook, env } = await this.prepareNotebookAndEnvironment(); + try { + this.notebookService.backgroundExecuteNotebook(this.wizardInfo.taskName || this.wizardInfo.title, notebook, 'deploy', this.platformService, env); + } catch (error) { + vscode.window.showErrorMessage(error); } - await this.finishWizard(); } - private async finishWizard() { + private async prepareNotebookAndEnvironment() { await setModelValues(this.inputComponents, this.model); const env: NodeJS.ProcessEnv = {}; this.model.setEnvironmentVariables(env, (varName) => { @@ -102,17 +101,7 @@ export class NotebookWizard extends WizardBase { ); } + /** + * If the return value is true then done button should be visible to the user + */ + private get isDoneButtonVisible(): boolean { + // done button is visible when runNotebook is 'true' or when it is 'userChooses' + return this.wizard.wizardInfo.runNotebook === true || this.wizard.wizardInfo.runNotebook === 'userChooses'; + } + + /** + * If the return value is true then generateScript button should be visible to the user + */ + private get isGenerateScriptButtonVisible(): boolean { + // generateScript button is visible when runNotebook is 'false' or when it is 'userChooses' + return this.wizard.wizardInfo.runNotebook === false || this.wizard.wizardInfo.runNotebook === 'userChooses'; + } + public initialize(): void { initializeWizardPage({ container: this.wizard.wizardObject, @@ -64,7 +81,18 @@ export class NotebookWizardPage extends WizardPageBase { }); } - public async onEnter(): Promise { + public async onEnter(pageInfo: WizardPageInfo): Promise { + if (pageInfo.isLastPage) { + //on last page doneButton is visible + this.wizard.wizardObject.doneButton.hidden = !this.isDoneButtonVisible; + // on last page generateScriptButton is visible when runNotebook is 'userChooses' + this.wizard.wizardObject.generateScriptButton.hidden = !this.isGenerateScriptButtonVisible; + } else { + //on any page but the last page doneButton and generateScriptButton are hidden + this.wizard.wizardObject.doneButton.hidden = true; + this.wizard.wizardObject.generateScriptButton.hidden = true; + } + if (this.pageInfo.isSummaryPage) { await setModelValues(this.wizard.inputComponents, this.wizard.model); } diff --git a/extensions/resource-deployment/src/ui/wizardBase.ts b/extensions/resource-deployment/src/ui/wizardBase.ts index 045d3ae75300..1116801045df 100644 --- a/extensions/resource-deployment/src/ui/wizardBase.ts +++ b/extensions/resource-deployment/src/ui/wizardBase.ts @@ -9,6 +9,7 @@ import * as nls from 'vscode-nls'; import { IToolsService } from '../services/toolsService'; import { Model } from './model'; import { WizardPageBase } from './wizardPageBase'; +import { WizardPageInfo } from './wizardPageInfo'; const localize = nls.loadMessageBundle(); export abstract class WizardBase, M extends Model> { @@ -21,55 +22,74 @@ export abstract class WizardBase, M extends Model return this._model; } - constructor(private title: string, name: string, private _model: M, public toolsService: IToolsService) { + protected get useGenerateScriptButton(): boolean { + return this._useGenerateScriptButton; + } + + constructor(private title: string, name: string, private _model: M, public toolsService: IToolsService, private _useGenerateScriptButton: boolean = false) { this.wizardObject = azdata.window.createWizard(title, name); } public async open(): Promise { this.initialize(); + this.wizardObject.generateScriptButton.hidden = true; // by default generateScriptButton stays hidden. this.wizardObject.customButtons = this.customButtons; this.toDispose.push(this.wizardObject.onPageChanged(async (e) => { let previousPage = this.pages[e.lastPage]; let newPage = this.pages[e.newPage]; - await previousPage.onLeave(); - await newPage.onEnter(); + //if we are changing to the first page from no page before, essentially when we load the wizard for the first time, e.lastPage is -1 and previousPage is undefined. + await previousPage?.onLeave(new WizardPageInfo(e.lastPage, this.pages.length)); + if (this.useGenerateScriptButton) { + if (newPage === this.pages.slice(-1)[0]) { + // if newPage is the last page + this.wizardObject.generateScriptButton.hidden = false; //un-hide generateScriptButton on last page + } else { + // if newPage is not the last page + this.wizardObject.generateScriptButton.hidden = true; //hide generateScriptButton if it is not the last page + } + } + await newPage.onEnter(new WizardPageInfo(e.newPage, this.pages.length)); })); this.toDispose.push(this.wizardObject.doneButton.onClick(async () => { await this.onOk(); this.dispose(); })); + this.toDispose.push(this.wizardObject.generateScriptButton.onClick(async () => { + await this.onGenerateScript(); + this.dispose(); + this.wizardObject.close(); // close the wizard. This is already hooked up into doneButton, so it is not needed for that button above. + })); this.toDispose.push(this.wizardObject.cancelButton.onClick(() => { this.onCancel(); this.dispose(); })); await this.wizardObject.open(); - if (this.pages && this.pages.length > 0) { - await this.pages[0].onEnter(); - } } protected abstract initialize(): void; protected abstract async onOk(): Promise; + protected async onGenerateScript(): Promise { } protected abstract onCancel(): void; - public addButton(button: azdata.window.Button, onClick?: () => void | Promise) { + public addButton(button: azdata.window.Button) { this.customButtons.push(button); - if (onClick) { - this.registerDisposable(button.onClick(onClick)); - } } protected setPages(pages: P[]) { this.wizardObject!.pages = pages.map(p => p.pageObject); this.pages = pages; this.pages.forEach((page) => { + page.pageObject.onValidityChanged((isValid: boolean) => { + // generateScriptButton is enabled only when the page isValid. + this.wizardObject.generateScriptButton.enabled = isValid; + }); page.initialize(); }); } - private dispose() { + protected dispose() { let errorOccurred = false; this.toDispose.forEach((disposable: vscode.Disposable) => { try { diff --git a/extensions/resource-deployment/src/ui/wizardPageBase.ts b/extensions/resource-deployment/src/ui/wizardPageBase.ts index 2a317b78dc4a..05c6f745d0b4 100644 --- a/extensions/resource-deployment/src/ui/wizardPageBase.ts +++ b/extensions/resource-deployment/src/ui/wizardPageBase.ts @@ -5,8 +5,10 @@ import * as azdata from 'azdata'; import { Validator } from './modelViewUtils'; +import { WizardPageInfo } from './wizardPageInfo'; export abstract class WizardPageBase { + private _page: azdata.window.WizardPage; private _validators: Validator[] = []; @@ -23,9 +25,10 @@ export abstract class WizardPageBase { return this._wizard; } - public async onEnter(): Promise { } + public async onEnter(_pageInfo?: WizardPageInfo): Promise { + } - public async onLeave(): Promise { } + public async onLeave(_pageInfo?: WizardPageInfo): Promise { } public abstract initialize(): void; diff --git a/extensions/resource-deployment/src/ui/wizardPageInfo.ts b/extensions/resource-deployment/src/ui/wizardPageInfo.ts new file mode 100644 index 000000000000..f0992091e9e6 --- /dev/null +++ b/extensions/resource-deployment/src/ui/wizardPageInfo.ts @@ -0,0 +1,26 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +export class WizardPageInfo { + public get pageCount(): number { + return this._pageCount; + } + + public get currentPageId(): number { + return this._currentPageId; + } + + public get isFirstPage(): boolean { + return this._currentPageId === 0; + } + + public get isLastPage(): boolean { + return this._currentPageId === this._pageCount - 1; + } + + constructor(private _currentPageId: number, private _pageCount: number) { + } + +} From d1ba0796861b9006b506b9d78a53d3ca7dabf00b Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 00:00:21 -0700 Subject: [PATCH 05/17] revert unneeded changes --- .../deploy.arc.data.controller.ipynb | 31 ---------------- .../deploy.postgres.existing.arc.ipynb | 36 ------------------- .../deploy.sql.existing.arc.ipynb | 33 ----------------- 3 files changed, 100 deletions(-) diff --git a/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb index c0fa99e9f298..a87aac91238d 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb @@ -96,37 +96,6 @@ "azdata_cell_guid": "4b266b2d-bd1b-4565-92c9-3fc146cdce6d" } }, - { - "cell_type": "markdown", - "source": [ - "### **Set variable values from environment variables**" - ], - "metadata": { - "azdata_cell_guid": "4a19f4d4-1fd5-4898-b38e-3a3901754de9" - } - }, - { - "cell_type": "code", - "source": [ - "arc_config_file = arc_config_file or os.environ[\"ADATA_NB_VAR_ARC_CONFIG_FILE\"]\n", - "arc_cluster_context = arc_cluster_context or os.environ[\"ADATA_NB_VAR_ARC_CLUSTER_CONTEXT\"]\n", - "arc_profile = arc_profile or os.environ[\"ADATA_NB_VAR_ARC_PROFILE\"]\n", - "arc_admin_username = arc_admin_username or os.environ[\"ADATA_NB_VAR_ARC_ADMIN_USERNAME\"]\n", - "arc_subscription = arc_subscription or os.environ[\"ADATA_NB_VAR_ARC_SUBSCRIPTION\"]\n", - "arc_display_subscription = arc_display_subscription or os.environ[\"ADATA_NB_VAR_ARC_DISPLAY_SUBSCRIPTION\"]\n", - "arc_resource_group = arc_resource_group or os.environ[\"ADATA_NB_VAR_ARC_RESOURCE_GROUP\"]\n", - "arc_data_controller_namespace = arc_data_controller_namespace or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_NAMESPACE\"]\n", - "arc_data_controller_name = arc_data_controller_name or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_NAME\"]\n", - "arc_data_controller_storage_class = arc_data_controller_storage_class or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_STORAGE_CLASS\"]\n", - "arc_data_controller_location = arc_data_controller_location or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_LOCATION\"]\n", - "arc_data_controller_display_location = arc_data_controller_display_location or os.environ[\"ADATA_NB_VAR_ARC_DATA_CONTROLLER_DISPLAY_LOCATION\"]" - ], - "metadata": { - "azdata_cell_guid": "e2cee548-0dcc-41e9-9807-ca8aaeb0ae1f" - }, - "outputs": [], - "execution_count": null - }, { "cell_type": "markdown", "source": [ diff --git a/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb index 8be376e1a872..1a31f4a91d35 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb @@ -99,42 +99,6 @@ "azdata_cell_guid": "68ec0760-27d1-4ded-9a9f-89077c40b8bb" } }, - { - "cell_type": "markdown", - "source": [ - "### **Set variable values from environment variables**" - ], - "metadata": { - "azdata_cell_guid": "36a1948a-4835-43e2-8d93-afbceca9222f" - } - }, - { - "cell_type": "code", - "source": [ - "postgres_server_group_cores_request = postgres_server_group_cores_request or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_CORES_REQUEST\"]\n", - "postgres_server_group_cores_limit = postgres_server_group_cores_limit or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_CORES_LIMIT\"]\n", - "postgres_server_group_memory_request = postgres_server_group_memory_request or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_MEMORY_REQUEST\"]\n", - "postgres_server_group_memory_limit = postgres_server_group_memory_limit or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_MEMORY_LIMIT\"]\n", - "postgres_server_group_name = postgres_server_group_name or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_NAME\"]\n", - "postgres_server_group_workers = postgres_server_group_workers or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_WORKERS\"]\n", - "postgres_server_group_port = postgres_server_group_port or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_PORT\"]\n", - "postgres_server_group_engine_version = postgres_server_group_engine_version or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_ENGINE_VERSION\"]\n", - "postgres_server_group_extensions = postgres_server_group_extensions or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_EXTENSIONS\"]\n", - "postgres_storage_class_data = postgres_storage_class_data or os.environ[\"ADATA_NB_VAR_POSTGRES_STORAGE_CLASS_DATA\"]\n", - "postgres_server_group_volume_size_data = postgres_server_group_volume_size_data or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_VOLUME_SIZE_DATA\"]\n", - "postgres_storage_class_logs = postgres_storage_class_logs or os.environ[\"ADATA_NB_VAR_POSTGRES_STORAGE_CLASS_LOGS\"]\n", - "postgres_server_group_volume_size_logs = postgres_server_group_volume_size_logs or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_VOLUME_SIZE_LOGS\"]\n", - "postgres_storage_class_backups = postgres_storage_class_backups or os.environ[\"ADATA_NB_VAR_POSTGRES_STORAGE_CLASS_BACKUPS\"]\n", - "postgres_server_group_volume_size_backups = postgres_server_group_volume_size_backups or os.environ[\"ADATA_NB_VAR_POSTGRES_SERVER_GROUP_VOLUME_SIZE_BACKUPS\"]\n", - "controller_endpoint = controller_endpoint or os.environ[\"ADATA_NB_VAR_CONTROLLER_ENDPOINT\"]\n", - "controller_username = controller_username or os.environ[\"ADATA_NB_VAR_CONTROLLER_USERNAME\"]" - ], - "metadata": { - "azdata_cell_guid": "ed798542-c292-4b9e-9abc-d9bf8abf4143" - }, - "outputs": [], - "execution_count": null - }, { "cell_type": "markdown", "source": [ diff --git a/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb index 290db1f1ecf4..c05627d0ef70 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.sql.existing.arc.ipynb @@ -99,39 +99,6 @@ "azdata_cell_guid": "68ec0760-27d1-4ded-9a9f-89077c40b8bb" } }, - { - "cell_type": "markdown", - "source": [ - "### **Set variable values from environment variables**" - ], - "metadata": { - "azdata_cell_guid": "c48a794b-8c31-48b7-904f-31aead666eae" - } - }, - { - "cell_type": "code", - "source": [ - "sql_instance_name = sql_instance_name or os.environ[\"ADATA_NB_VAR_SQL_INSTANCE_NAME\"]\n", - "sql_username = sql_username or os.environ[\"ADATA_NB_VAR_SQL_USERNAME\"]\n", - "sql_storage_class_data = sql_storage_class_data or os.environ[\"ADATA_NB_VAR_SQL_STORAGE_CLASS_DATA\"]\n", - "sql_storage_class_logs = sql_storage_class_logs or os.environ[\"ADATA_NB_VAR_SQL_STORAGE_CLASS_LOGS\"]\n", - "if \"ADATA_NB_VAR_SQL_CORES_REQUEST\" in os.environ:\n", - " sql_cores_request = sql_cores_request or os.environ[\"ADATA_NB_VAR_SQL_CORES_REQUEST\"]\n", - "if \"AZDATA_NB_VAR_SQL_CORES_LIMIT\" in os.environ:\n", - " sql_cores_limit = sql_cores_limit or os.environ[\"ADATA_NB_VAR_SQL_CORES_LIMIT\"]\n", - "if \"ADATA_NB_VAR_SQL_MEMORY_REQUEST\" in os.environ:\n", - " sql_memory_request = sql_memory_request or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_REQUEST\"]\n", - "if \"ADATA_NB_VAR_SQL_MEMORY_LIMIT\" in os.environ:\n", - " sql_memory_limit = sql_memory_limit or os.environ[\"ADATA_NB_VAR_SQL_MEMORY_LIMIT\"]\n", - "controller_endpoint = controller_endpoint or os.environ[\"ADATA_NB_VAR_CONTROLLER_ENDPOINT\"]\n", - "controller_username = controller_username or os.environ[\"ADATA_NB_VAR_CONTROLLER_USERNAME\"]" - ], - "metadata": { - "azdata_cell_guid": "69a96851-6b70-494f-8eb5-984652e88005" - }, - "outputs": [], - "execution_count": null - }, { "cell_type": "markdown", "source": [ From 15ceacf2d204ab4aa1363571ddd3acf1a5526066 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 00:43:23 -0700 Subject: [PATCH 06/17] fix comments --- extensions/resource-deployment/src/interfaces.ts | 9 +++------ extensions/resource-deployment/src/ui/wizardPageBase.ts | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/extensions/resource-deployment/src/interfaces.ts b/extensions/resource-deployment/src/interfaces.ts index e49c8e538b8d..0b7bfc5b64d6 100644 --- a/extensions/resource-deployment/src/interfaces.ts +++ b/extensions/resource-deployment/src/interfaces.ts @@ -116,15 +116,12 @@ export interface BdcWizardInfo { } /** - * if true - the python notebook is run as a background task at the end of the wizard, all input values are set as - * environment variables prior to notebook execution. @see actionText is used to configure the label of the done button. - * if false - the notebook is opened up in a new editor, all input values are transferred into a cell of the notebook as - * python variables. Except password variables which are set as environment variables into the jupyter kernel process that - * is used to execute the notebook. @see actionText is used to configure the label of the done button. + * if true - the python notebook is run as a background task at the end of the wizard. @see actionText is used to configure the label of the done button. + * if false - the notebook is opened up in a new editor. @see actionText is used to configure the label of the done button. * if 'userChooses' - an additional button @see loc.scriptToNotebook is shown to the user at the end of the wizard. * The default done button allows the user to execute the notebook as background task. @see actionText is used to configure the label of the done button, otherwise the behavior is same as when runNotebook was set to true. * and scriptToNotebook button opens up the notebook in a new editor window. @see scriptToNotebookActionText is used to configure the label of the done button, otherwise the behavior is same asa when runNotebook was set to false. - * + * Remarks: For all cases, all input values are transferred into a cell of the notebook as python variables except password variables which are set as environment variables into the jupyter kernel process that is used to execute the notebook. */ type RunNotebookType = false | true | 'userChooses'; diff --git a/extensions/resource-deployment/src/ui/wizardPageBase.ts b/extensions/resource-deployment/src/ui/wizardPageBase.ts index 05c6f745d0b4..d959ab2b8405 100644 --- a/extensions/resource-deployment/src/ui/wizardPageBase.ts +++ b/extensions/resource-deployment/src/ui/wizardPageBase.ts @@ -25,8 +25,7 @@ export abstract class WizardPageBase { return this._wizard; } - public async onEnter(_pageInfo?: WizardPageInfo): Promise { - } + public async onEnter(_pageInfo?: WizardPageInfo): Promise { } public async onLeave(_pageInfo?: WizardPageInfo): Promise { } From 6808d60377138aec40544f666fdda820edf2d131 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 09:41:21 -0700 Subject: [PATCH 07/17] Update interfaces.ts --- extensions/resource-deployment/src/interfaces.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/resource-deployment/src/interfaces.ts b/extensions/resource-deployment/src/interfaces.ts index 0b7bfc5b64d6..8f85a244635e 100644 --- a/extensions/resource-deployment/src/interfaces.ts +++ b/extensions/resource-deployment/src/interfaces.ts @@ -118,9 +118,9 @@ export interface BdcWizardInfo { /** * if true - the python notebook is run as a background task at the end of the wizard. @see actionText is used to configure the label of the done button. * if false - the notebook is opened up in a new editor. @see actionText is used to configure the label of the done button. - * if 'userChooses' - an additional button @see loc.scriptToNotebook is shown to the user at the end of the wizard. - * The default done button allows the user to execute the notebook as background task. @see actionText is used to configure the label of the done button, otherwise the behavior is same as when runNotebook was set to true. - * and scriptToNotebook button opens up the notebook in a new editor window. @see scriptToNotebookActionText is used to configure the label of the done button, otherwise the behavior is same asa when runNotebook was set to false. + * if 'userChooses' - an additional button @see loc.scriptToNotebook is shown to the user at the end of the wizard. + * The default done button allows the user to execute the notebook as background task. @see actionText is used to configure the label of the done button. + * and scriptToNotebook button opens up the notebook in a new editor window. @see scriptToNotebookActionText is used to configure the label of the done button. * Remarks: For all cases, all input values are transferred into a cell of the notebook as python variables except password variables which are set as environment variables into the jupyter kernel process that is used to execute the notebook. */ type RunNotebookType = false | true | 'userChooses'; @@ -130,7 +130,7 @@ type RunNotebookType = false | true | 'userChooses'; */ export interface NotebookWizardInfo extends WizardInfoBase { /** - * path to python notebook that loaded/executed at the end of the wizard + * path to the template python notebook that is modified with variables collected in the wizard. A copy of this modified notebook is executed at the end of the wizard either from commonadline of from notebook editor in ADS. */ notebook: string | NotebookPathInfo; /** From b7e4f011f99141e0b362fac2e1f02d7a4627e6f7 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 09:51:32 -0700 Subject: [PATCH 08/17] fix comments --- .../src/ui/notebookWizard/notebookWizardPage.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts index 0239dd7a3e3c..b51d50c2cb21 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts @@ -83,9 +83,8 @@ export class NotebookWizardPage extends WizardPageBase { public async onEnter(pageInfo: WizardPageInfo): Promise { if (pageInfo.isLastPage) { - //on last page doneButton is visible + // on the last page either one or both of done button and generateScript button are visisble depending on configuration of 'runNotebook' wizard info this.wizard.wizardObject.doneButton.hidden = !this.isDoneButtonVisible; - // on last page generateScriptButton is visible when runNotebook is 'userChooses' this.wizard.wizardObject.generateScriptButton.hidden = !this.isGenerateScriptButtonVisible; } else { //on any page but the last page doneButton and generateScriptButton are hidden From e3446bfeefc140e2b8df395c0c47cd2c9e93eb1f Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 09:57:30 -0700 Subject: [PATCH 09/17] fix comments --- extensions/resource-deployment/src/ui/wizardBase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/resource-deployment/src/ui/wizardBase.ts b/extensions/resource-deployment/src/ui/wizardBase.ts index 1116801045df..c4eeb67016aa 100644 --- a/extensions/resource-deployment/src/ui/wizardBase.ts +++ b/extensions/resource-deployment/src/ui/wizardBase.ts @@ -82,7 +82,7 @@ export abstract class WizardBase, M extends Model this.pages = pages; this.pages.forEach((page) => { page.pageObject.onValidityChanged((isValid: boolean) => { - // generateScriptButton is enabled only when the page isValid. + // generateScriptButton is enabled only when the page is valid. this.wizardObject.generateScriptButton.enabled = isValid; }); page.initialize(); From 70948e764ae3eea9daf5540044f9d9b5f32b485b Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 09:59:22 -0700 Subject: [PATCH 10/17] fix comments --- .../src/ui/notebookWizard/notebookWizardPage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts index b51d50c2cb21..32a216244000 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts @@ -83,7 +83,7 @@ export class NotebookWizardPage extends WizardPageBase { public async onEnter(pageInfo: WizardPageInfo): Promise { if (pageInfo.isLastPage) { - // on the last page either one or both of done button and generateScript button are visisble depending on configuration of 'runNotebook' wizard info + // on the last page either one or both of done button and generateScript button are visisble depending on configuration of 'runNotebook' in wizard info this.wizard.wizardObject.doneButton.hidden = !this.isDoneButtonVisible; this.wizard.wizardObject.generateScriptButton.hidden = !this.isGenerateScriptButtonVisible; } else { From 82d6b15628f5e04319477d5891cd0543a5debd5d Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 12:09:25 -0700 Subject: [PATCH 11/17] runAllCells instead of background execute --- .../src/services/notebookService.ts | 16 +++++++------- .../src/services/resourceTypeService.ts | 16 +++++++------- .../deployAzureSQLVMWizard.ts | 2 +- .../deployClusterWizard.ts | 2 +- .../src/ui/deploymentInputDialog.ts | 2 +- .../src/ui/notebookWizard/notebookWizard.ts | 21 +++++++++++-------- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/extensions/resource-deployment/src/services/notebookService.ts b/extensions/resource-deployment/src/services/notebookService.ts index 9d32ceac2e65..c6cf1fc758d9 100644 --- a/extensions/resource-deployment/src/services/notebookService.ts +++ b/extensions/resource-deployment/src/services/notebookService.ts @@ -33,9 +33,9 @@ export interface NotebookExecutionResult { } export interface INotebookService { - launchNotebook(notebook: string | NotebookPathInfo): Promise; - launchNotebookWithEdits(notebook: string | NotebookPathInfo, cellStatements: string[], insertionPosition?: number): Promise; - launchNotebookWithContent(title: string, content: string): Promise; + openNotebook(notebook: string | NotebookPathInfo): Promise; + openNotebookWithEdits(notebook: string | NotebookPathInfo, cellStatements: string[], insertionPosition?: number): Promise; + openNotebookWithContent(title: string, content: string): Promise; getNotebook(notebook: string | NotebookPathInfo): Promise; getNotebookPath(notebook: string | NotebookPathInfo): string; executeNotebook(notebook: any, env?: NodeJS.ProcessEnv): Promise; @@ -50,7 +50,7 @@ export class NotebookService implements INotebookService { * Launch notebook with file path * @param notebook the path of the notebook */ - async launchNotebook(notebook: string | NotebookPathInfo): Promise { + async openNotebook(notebook: string | NotebookPathInfo): Promise { const notebookPath = await this.getNotebookFullPath(notebook); return await this.showNotebookAsUntitled(notebookPath); } @@ -63,8 +63,8 @@ export class NotebookService implements INotebookService { * @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 { - const openedNotebook = await this.launchNotebook(notebook); + async openNotebookWithEdits(notebook: string, cellStatements: string[], insertionPosition: number = 0): Promise { + const openedNotebook = await this.openNotebook(notebook); await openedNotebook.edit((editBuilder: azdata.nb.NotebookEditorEdit) => { editBuilder.insertCell({ cell_type: 'code', @@ -78,7 +78,7 @@ export class NotebookService implements INotebookService { * @param title the title of the notebook * @param content the notebook content */ - async launchNotebookWithContent(title: string, content: string): Promise { + async openNotebookWithContent(title: string, content: string): Promise { const uri: vscode.Uri = vscode.Uri.parse(`untitled:${this.findNextUntitledEditorName(title)}`); return await azdata.nb.showNotebookDocument(uri, { connectionProfile: undefined, @@ -150,7 +150,7 @@ 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); diff --git a/extensions/resource-deployment/src/services/resourceTypeService.ts b/extensions/resource-deployment/src/services/resourceTypeService.ts index f6be8dca6d36..0230f9a1aeac 100644 --- a/extensions/resource-deployment/src/services/resourceTypeService.ts +++ b/extensions/resource-deployment/src/services/resourceTypeService.ts @@ -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({ diff --git a/extensions/resource-deployment/src/ui/deployAzureSQLVMWizard/deployAzureSQLVMWizard.ts b/extensions/resource-deployment/src/ui/deployAzureSQLVMWizard/deployAzureSQLVMWizard.ts index ba8db2433620..af25019a5019 100644 --- a/extensions/resource-deployment/src/ui/deployAzureSQLVMWizard/deployAzureSQLVMWizard.ts +++ b/extensions/resource-deployment/src/ui/deployAzureSQLVMWizard/deployAzureSQLVMWizard.ts @@ -73,7 +73,7 @@ export class DeployAzureSQLVMWizard extends WizardBase nb.type === model.getStringValue(NotebookTypeVariableName))?.path : this.dialogInfo.notebook; - this.notebookService.launchNotebook(notebook!).catch(error => { + this.notebookService.openNotebook(notebook!).catch(error => { vscode.window.showErrorMessage(error); }); } diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts index a0db02fc76d9..c0b10e1395d4 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts @@ -54,28 +54,31 @@ export class NotebookWizard extends WizardBase { - const { notebook, env } = await this.prepareNotebookAndEnvironment(); try { - Object.assign(process.env, env); - const notebookPath = this.notebookService.getNotebookPath(this.wizardInfo.notebook); - await this.notebookService.launchNotebookWithContent(notebookPath, JSON.stringify(notebook, undefined, 4)); + const notebook = await this.prepareNotebookAndEnvironment(); + await this.openNotebook(notebook); } catch (error) { vscode.window.showErrorMessage(error); } } - protected async onOk(): Promise { - const { notebook, env } = await this.prepareNotebookAndEnvironment(); try { - this.notebookService.backgroundExecuteNotebook(this.wizardInfo.taskName || this.wizardInfo.title, notebook, 'deploy', this.platformService, env); + const notebook = await this.prepareNotebookAndEnvironment(); + const openedNotebook = await this.openNotebook(notebook); + openedNotebook.runAllCells(); } catch (error) { vscode.window.showErrorMessage(error); } } + private async openNotebook(notebook: Notebook) { + const notebookPath = this.notebookService.getNotebookPath(this.wizardInfo.notebook); + return await this.notebookService.openNotebookWithContent(notebookPath, JSON.stringify(notebook, undefined, 4)); + } + private async prepareNotebookAndEnvironment() { await setModelValues(this.inputComponents, this.model); - const env: NodeJS.ProcessEnv = {}; + const env: NodeJS.ProcessEnv = process.env; this.model.setEnvironmentVariables(env, (varName) => { const isPassword = !!this.inputComponents[varName]?.isPassword; return isPassword; @@ -101,7 +104,7 @@ export class NotebookWizard extends WizardBase Date: Tue, 29 Sep 2020 13:11:40 -0700 Subject: [PATCH 12/17] pr feedback --- .../resource-deployment/src/interfaces.ts | 32 ++++++++----------- .../src/ui/notebookWizard/notebookWizard.ts | 4 +-- .../ui/notebookWizard/notebookWizardPage.ts | 6 ++-- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/extensions/resource-deployment/src/interfaces.ts b/extensions/resource-deployment/src/interfaces.ts index 8f85a244635e..b50649a4daea 100644 --- a/extensions/resource-deployment/src/interfaces.ts +++ b/extensions/resource-deployment/src/interfaces.ts @@ -114,16 +114,16 @@ export interface BdcWizardInfo { notebook: string | NotebookPathInfo; type: BdcDeploymentType; } - /** - * if true - the python notebook is run as a background task at the end of the wizard. @see actionText is used to configure the label of the done button. - * if false - the notebook is opened up in a new editor. @see actionText is used to configure the label of the done button. - * if 'userChooses' - an additional button @see loc.scriptToNotebook is shown to the user at the end of the wizard. - * The default done button allows the user to execute the notebook as background task. @see actionText is used to configure the label of the done button. - * and scriptToNotebook button opens up the notebook in a new editor window. @see scriptToNotebookActionText is used to configure the label of the done button. - * Remarks: For all cases, all input values are transferred into a cell of the notebook as python variables except password variables which are set as environment variables into the jupyter kernel process that is used to execute the notebook. + * An object that configures Script and Done buttons of the wizard. */ -type RunNotebookType = false | true | 'userChooses'; +export interface WizardButton { + /** + * + */ + visible: boolean, + label?: string +} /** * This object defines the shape, form and behavior of a Notebook Wizard. @@ -133,14 +133,6 @@ export interface NotebookWizardInfo extends WizardInfoBase { * path to the template python notebook that is modified with variables collected in the wizard. A copy of this modified notebook is executed at the end of the wizard either from commonadline of from notebook editor in ADS. */ notebook: string | NotebookPathInfo; - /** - * specifies the behavior at the end of the wizard. @see RunNotebookType for details. - */ - runNotebook?: RunNotebookType; - /** - * The label of additional scriptToNotebook button used when runNotebook is set to @see userChooses. - */ - scriptToNotebookActionText?: string; /** * 0 based position number where the variables values are inserted into the notebook as python statements. */ @@ -158,9 +150,13 @@ export interface WizardInfoBase extends FieldInfoBase { taskName?: string; type?: DeploymentType; /** - * The done button label to end the wizard. + * done button attributes. */ - actionText?: string; + doneButton?: WizardButton; + /** + * script button attributes. + */ + scriptButton?: WizardButton; /** * title displayed on every page of the wizard */ diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts index c0b10e1395d4..eebc1f11a419 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts @@ -38,8 +38,8 @@ export class NotebookWizard extends WizardBase { * If the return value is true then done button should be visible to the user */ private get isDoneButtonVisible(): boolean { - // done button is visible when runNotebook is 'true' or when it is 'userChooses' - return this.wizard.wizardInfo.runNotebook === true || this.wizard.wizardInfo.runNotebook === 'userChooses'; + return this.wizard.wizardInfo.doneButton?.visible ?? false; } /** * If the return value is true then generateScript button should be visible to the user */ private get isGenerateScriptButtonVisible(): boolean { - // generateScript button is visible when runNotebook is 'false' or when it is 'userChooses' - return this.wizard.wizardInfo.runNotebook === false || this.wizard.wizardInfo.runNotebook === 'userChooses'; + return this.wizard.wizardInfo.scriptButton?.visible ?? false; } public initialize(): void { From ce949f48ecf4d7363eba6daf554d2b9fb8ffd510 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 14:21:42 -0700 Subject: [PATCH 13/17] PR feedback --- .../src/localizedConstants.ts | 4 ++-- .../src/services/notebookService.ts | 19 ++++++++++--------- .../ui/notebookWizard/notebookWizardPage.ts | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/extensions/resource-deployment/src/localizedConstants.ts b/extensions/resource-deployment/src/localizedConstants.ts index 39733473d3fe..33bf67a1da54 100644 --- a/extensions/resource-deployment/src/localizedConstants.ts +++ b/extensions/resource-deployment/src/localizedConstants.ts @@ -37,5 +37,5 @@ export const optionsTypeRadioOrDropdown = localize('optionsTypeRadioOrDropdown', export const azdataEulaNotAccepted = localize('azdataEulaNotAccepted', "Deployment cannot continue. Azure Data CLI license terms have not yet been accepted. Please accept the EULA to enable the features that requires Azure Data CLI."); export const azdataEulaDeclined = localize('azdataEulaDeclined', "Deployment cannot continue. Azure Data CLI license terms were declined.You can either Accept EULA to continue or Cancel this operation"); export const acceptEulaAndSelect = localize('deploymentDialog.RecheckEulaButton', "Accept EULA & Select"); -export const scriptToNotebook = localize('ui.ScriptToNotebookButton', "Script to notebook"); -export const deployNotebook = localize('ui.DeployButton', "Deploy"); +export const scriptToNotebook = localize('ui.ScriptToNotebookButton', "Script"); +export const deployNotebook = localize('ui.DeployButton', "Run"); diff --git a/extensions/resource-deployment/src/services/notebookService.ts b/extensions/resource-deployment/src/services/notebookService.ts index c6cf1fc758d9..e4fc8afa8aa3 100644 --- a/extensions/resource-deployment/src/services/notebookService.ts +++ b/extensions/resource-deployment/src/services/notebookService.ts @@ -34,7 +34,7 @@ export interface NotebookExecutionResult { export interface INotebookService { openNotebook(notebook: string | NotebookPathInfo): Promise; - openNotebookWithEdits(notebook: string | NotebookPathInfo, cellStatements: string[], insertionPosition?: number): Promise; + openNotebookWithEdits(notebook: string | NotebookPathInfo, cellStatements: string[], insertionPosition?: number): Promise; openNotebookWithContent(title: string, content: string): Promise; getNotebook(notebook: string | NotebookPathInfo): Promise; getNotebookPath(notebook: string | NotebookPathInfo): string; @@ -47,7 +47,7 @@ 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 openNotebook(notebook: string | NotebookPathInfo): Promise { @@ -57,13 +57,13 @@ export class NotebookService implements INotebookService { /** * 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 openNotebookWithEdits(notebook: string, cellStatements: string[], insertionPosition: number = 0): Promise { + async openNotebookWithEdits(notebook: string, cellStatements: string[], insertionPosition: number = 0): Promise { const openedNotebook = await this.openNotebook(notebook); await openedNotebook.edit((editBuilder: azdata.nb.NotebookEditorEdit) => { editBuilder.insertCell({ @@ -71,10 +71,11 @@ export class NotebookService implements INotebookService { source: cellStatements }, insertionPosition); }); + return openedNotebook; } /** - * Launch notebook with file path + * Open notebook with file path * @param title the title of the notebook * @param content the notebook content */ @@ -152,9 +153,9 @@ export class NotebookService implements INotebookService { try { 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 { diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts index 1b4241132737..3ada5e59e3a1 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizardPage.ts @@ -81,7 +81,7 @@ export class NotebookWizardPage extends WizardPageBase { public async onEnter(pageInfo: WizardPageInfo): Promise { if (pageInfo.isLastPage) { - // on the last page either one or both of done button and generateScript button are visisble depending on configuration of 'runNotebook' in wizard info + // on the last page either one or both of done button and generateScript button are visible depending on configuration of 'runNotebook' in wizard info this.wizard.wizardObject.doneButton.hidden = !this.isDoneButtonVisible; this.wizard.wizardObject.generateScriptButton.hidden = !this.isGenerateScriptButtonVisible; } else { From 53765df44edede883252acdbff09fd9f4304fe67 Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 14:46:21 -0700 Subject: [PATCH 14/17] pr feedback --- extensions/resource-deployment/src/interfaces.ts | 10 +++------- .../src/ui/notebookWizard/notebookWizard.ts | 4 ++-- .../src/ui/notebookWizard/notebookWizardPage.ts | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/extensions/resource-deployment/src/interfaces.ts b/extensions/resource-deployment/src/interfaces.ts index b50649a4daea..3988eb3c8965 100644 --- a/extensions/resource-deployment/src/interfaces.ts +++ b/extensions/resource-deployment/src/interfaces.ts @@ -117,11 +117,7 @@ export interface BdcWizardInfo { /** * An object that configures Script and Done buttons of the wizard. */ -export interface WizardButton { - /** - * - */ - visible: boolean, +export interface WizardAction { label?: string } @@ -152,11 +148,11 @@ export interface WizardInfoBase extends FieldInfoBase { /** * done button attributes. */ - doneButton?: WizardButton; + doneAction: WizardAction; /** * script button attributes. */ - scriptButton?: WizardButton; + scriptAction?: WizardAction; /** * title displayed on every page of the wizard */ diff --git a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts index eebc1f11a419..5f096dde9bae 100644 --- a/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts +++ b/extensions/resource-deployment/src/ui/notebookWizard/notebookWizard.ts @@ -38,8 +38,8 @@ export class NotebookWizard extends WizardBase { * If the return value is true then done button should be visible to the user */ private get isDoneButtonVisible(): boolean { - return this.wizard.wizardInfo.doneButton?.visible ?? false; + return !!this.wizard.wizardInfo.doneAction; } /** * If the return value is true then generateScript button should be visible to the user */ private get isGenerateScriptButtonVisible(): boolean { - return this.wizard.wizardInfo.scriptButton?.visible ?? false; + return !!this.wizard.wizardInfo.scriptAction; } public initialize(): void { From 47f14a0f2358385273ef18e89538b82c952bbfec Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 14:57:43 -0700 Subject: [PATCH 15/17] arc ext changes for new WizardInfo syntax --- extensions/arc/package.json | 21 ++++++++++++++++++--- extensions/arc/package.nls.json | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/extensions/arc/package.json b/extensions/arc/package.json index fea3bd3a49a5..82816b83847d 100644 --- a/extensions/arc/package.json +++ b/extensions/arc/package.json @@ -144,7 +144,12 @@ "notebookWizard": { "notebook": "./notebooks/arcDeployment/deploy.arc.data.controller.ipynb", "type": "new-arc-control-plane", - "runNotebook": "userChooses", + "doneAction": { + "label": "%deploy.done.action%" + }, + "scriptAction": { + "label": "%deploy.script.action%" + }, "codeCellInsertionPosition": 5, "title": "%arc.data.controller.new.wizard.title%", "name": "arc.data.controller.new.wizard", @@ -520,7 +525,12 @@ { "notebookWizard": { "notebook": "./notebooks/arcDeployment/deploy.sql.existing.arc.ipynb", - "runNotebook": "userChooses", + "doneAction": { + "label": "%deploy.done.action%" + }, + "scriptAction": { + "label": "%deploy.script.action%" + }, "codeCellInsertionPosition": 5, "title": "%arc.sql.wizard.title%", "name": "arc.sql.wizard", @@ -680,7 +690,12 @@ { "notebookWizard": { "notebook": "./notebooks/arcDeployment/deploy.postgres.existing.arc.ipynb", - "runNotebook": "userChooses", + "doneAction": { + "label": "%deploy.done.action%" + }, + "scriptAction": { + "label": "%deploy.script.action%" + }, "codeCellInsertionPosition": 5, "title": "%arc.postgres.wizard.title%", "name": "arc.postgres.wizard", diff --git a/extensions/arc/package.nls.json b/extensions/arc/package.nls.json index 56c02801664b..7cb1a9b52724 100644 --- a/extensions/arc/package.nls.json +++ b/extensions/arc/package.nls.json @@ -58,8 +58,8 @@ "arc.data.controller.summary.location": "Location", "arc.data.controller.arc.data.controller.agreement": "I accept {0} and {1}.", "microsoft.agreement.privacy.statement":"Microsoft Privacy Statement", - "deploy.script.to.notebook.action":"Script to notebook", - + "deploy.script.action":"Script to notebook", + "deploy.done.action":"Deploy", "resource.type.arc.sql.display.name": "Azure SQL managed instance - Azure Arc (preview)", "resource.type.arc.postgres.display.name": "PostgreSQL Hyperscale server groups - Azure Arc (preview)", From f06dff792a6971c180a7d549d51340cf1382463c Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 15:26:27 -0700 Subject: [PATCH 16/17] fix doc comments --- extensions/resource-deployment/src/services/notebookService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/resource-deployment/src/services/notebookService.ts b/extensions/resource-deployment/src/services/notebookService.ts index e4fc8afa8aa3..3e26069671f9 100644 --- a/extensions/resource-deployment/src/services/notebookService.ts +++ b/extensions/resource-deployment/src/services/notebookService.ts @@ -75,7 +75,7 @@ export class NotebookService implements INotebookService { } /** - * Open notebook with file path + * Open notebook with given contents * @param title the title of the notebook * @param content the notebook content */ From 66b1103d29f709ff37a8f706b303412fddc0b5cb Mon Sep 17 00:00:00 2001 From: Arvind Ranasaria Date: Tue, 29 Sep 2020 17:22:51 -0700 Subject: [PATCH 17/17] pr feedback --- extensions/resource-deployment/src/interfaces.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/extensions/resource-deployment/src/interfaces.ts b/extensions/resource-deployment/src/interfaces.ts index 3988eb3c8965..56a58acbf879 100644 --- a/extensions/resource-deployment/src/interfaces.ts +++ b/extensions/resource-deployment/src/interfaces.ts @@ -140,10 +140,6 @@ export interface NotebookWizardInfo extends WizardInfoBase { } export interface WizardInfoBase extends FieldInfoBase { - /** - * the taskName to use when running the notebook as a background task. The default value is the @see title of the wizard. - */ - taskName?: string; type?: DeploymentType; /** * done button attributes.