From 370e0f55401c89164992b94095a2b57d27c29df8 Mon Sep 17 00:00:00 2001 From: Ilia Babanov Date: Wed, 24 Apr 2024 13:56:46 +0200 Subject: [PATCH] Improve auto-migration template (#1200) Should help avoid confusion on why this file was created and how to avoid it if neccessary --- packages/databricks-vscode/package.json | 8 ++++---- .../migration-template/databricks_template_schema.json | 5 +++++ .../migration-template/template/databricks.yml.tmpl | 6 ++++++ .../databricks-vscode/src/bundle/BundleProjectManager.ts | 7 +++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/databricks-vscode/package.json b/packages/databricks-vscode/package.json index 042df614a..985cfa61d 100644 --- a/packages/databricks-vscode/package.json +++ b/packages/databricks-vscode/package.json @@ -373,13 +373,13 @@ }, { "view": "configurationView", - "contents": "[Create a new Databricks Project](command:databricks.bundle.initNewProject)", - "when": "workspaceFolderCount > 0 && databricks.context.initialized" + "contents": "Migrate current workspace to a Databricks Project: \n[Migrate to a Databricks Project](command:databricks.bundle.startManualMigration)", + "when": "workspaceFolderCount > 0 && databricks.context.initialized && databricks.context.pendingManualMigration" }, { "view": "configurationView", - "contents": "Migrate current workspace to a Databricks Project: \n[Migrate to Databricks Project](command:databricks.bundle.startManualMigration)", - "when": "workspaceFolderCount > 0 && databricks.context.initialized && databricks.context.pendingManualMigration" + "contents": "[Create a new Databricks Project](command:databricks.bundle.initNewProject)", + "when": "workspaceFolderCount > 0 && databricks.context.initialized" }, { "view": "configurationView", diff --git a/packages/databricks-vscode/resources/migration-template/databricks_template_schema.json b/packages/databricks-vscode/resources/migration-template/databricks_template_schema.json index 0b28dd5a1..87afe0234 100644 --- a/packages/databricks-vscode/resources/migration-template/databricks_template_schema.json +++ b/packages/databricks-vscode/resources/migration-template/databricks_template_schema.json @@ -1,5 +1,10 @@ { "properties": { + "auto_migration": { + "type": "boolean", + "description": "Auto migration", + "order": 1 + }, "project_name": { "type": "string", "description": "Project name", diff --git a/packages/databricks-vscode/resources/migration-template/template/databricks.yml.tmpl b/packages/databricks-vscode/resources/migration-template/template/databricks.yml.tmpl index 99f3e6f8f..efa55e805 100644 --- a/packages/databricks-vscode/resources/migration-template/template/databricks.yml.tmpl +++ b/packages/databricks-vscode/resources/migration-template/template/databricks.yml.tmpl @@ -1,5 +1,11 @@ # This is a Databricks asset bundle definition for {{.project_name}}. +{{- if .auto_migration}} +# The file was generated automatically by the Databricks extension. +# It's based on the configuration located in `.databricks/project.json`. +# If you don't want this file to be created automatically, remove the `.databricks/project.json`. +{{- else}} # The Databricks extension requires databricks.yml configuration file. +{{- end}} # See https://docs.databricks.com/dev-tools/bundles/index.html for documentation. bundle: diff --git a/packages/databricks-vscode/src/bundle/BundleProjectManager.ts b/packages/databricks-vscode/src/bundle/BundleProjectManager.ts index ffc72445a..c4e5ba5ff 100644 --- a/packages/databricks-vscode/src/bundle/BundleProjectManager.ts +++ b/packages/databricks-vscode/src/bundle/BundleProjectManager.ts @@ -223,7 +223,8 @@ export class BundleProjectManager { } await this.migrateProjectJsonToBundle( authProvider as ProfileAuthProvider, - legacyProjectConfig + legacyProjectConfig, + true ); recordEvent({success: true}); } @@ -260,11 +261,13 @@ export class BundleProjectManager { private async migrateProjectJsonToBundle( authProvider: ProfileAuthProvider, - legacyProjectConfig?: ProjectConfigFile + legacyProjectConfig?: ProjectConfigFile, + autoMigration: boolean = false ) { const configVars = { /* eslint-disable @typescript-eslint/naming-convention */ project_name: path.basename(this.workspaceUri.fsPath), + auto_migration: autoMigration, compute_id: legacyProjectConfig?.clusterId, root_path: legacyProjectConfig?.workspacePath?.path, /* eslint-enable @typescript-eslint/naming-convention */