Skip to content

Commit 370e0f5

Browse files
authored
Improve auto-migration template (#1200)
Should help avoid confusion on why this file was created and how to avoid it if neccessary
1 parent 132044e commit 370e0f5

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

packages/databricks-vscode/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@
373373
},
374374
{
375375
"view": "configurationView",
376-
"contents": "[Create a new Databricks Project](command:databricks.bundle.initNewProject)",
377-
"when": "workspaceFolderCount > 0 && databricks.context.initialized"
376+
"contents": "Migrate current workspace to a Databricks Project: \n[Migrate to a Databricks Project](command:databricks.bundle.startManualMigration)",
377+
"when": "workspaceFolderCount > 0 && databricks.context.initialized && databricks.context.pendingManualMigration"
378378
},
379379
{
380380
"view": "configurationView",
381-
"contents": "Migrate current workspace to a Databricks Project: \n[Migrate to Databricks Project](command:databricks.bundle.startManualMigration)",
382-
"when": "workspaceFolderCount > 0 && databricks.context.initialized && databricks.context.pendingManualMigration"
381+
"contents": "[Create a new Databricks Project](command:databricks.bundle.initNewProject)",
382+
"when": "workspaceFolderCount > 0 && databricks.context.initialized"
383383
},
384384
{
385385
"view": "configurationView",

packages/databricks-vscode/resources/migration-template/databricks_template_schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"properties": {
3+
"auto_migration": {
4+
"type": "boolean",
5+
"description": "Auto migration",
6+
"order": 1
7+
},
38
"project_name": {
49
"type": "string",
510
"description": "Project name",

packages/databricks-vscode/resources/migration-template/template/databricks.yml.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# This is a Databricks asset bundle definition for {{.project_name}}.
2+
{{- if .auto_migration}}
3+
# The file was generated automatically by the Databricks extension.
4+
# It's based on the configuration located in `.databricks/project.json`.
5+
# If you don't want this file to be created automatically, remove the `.databricks/project.json`.
6+
{{- else}}
27
# The Databricks extension requires databricks.yml configuration file.
8+
{{- end}}
39
# See https://docs.databricks.com/dev-tools/bundles/index.html for documentation.
410

511
bundle:

packages/databricks-vscode/src/bundle/BundleProjectManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ export class BundleProjectManager {
223223
}
224224
await this.migrateProjectJsonToBundle(
225225
authProvider as ProfileAuthProvider,
226-
legacyProjectConfig
226+
legacyProjectConfig,
227+
true
227228
);
228229
recordEvent({success: true});
229230
}
@@ -260,11 +261,13 @@ export class BundleProjectManager {
260261

261262
private async migrateProjectJsonToBundle(
262263
authProvider: ProfileAuthProvider,
263-
legacyProjectConfig?: ProjectConfigFile
264+
legacyProjectConfig?: ProjectConfigFile,
265+
autoMigration: boolean = false
264266
) {
265267
const configVars = {
266268
/* eslint-disable @typescript-eslint/naming-convention */
267269
project_name: path.basename(this.workspaceUri.fsPath),
270+
auto_migration: autoMigration,
268271
compute_id: legacyProjectConfig?.clusterId,
269272
root_path: legacyProjectConfig?.workspacePath?.path,
270273
/* eslint-enable @typescript-eslint/naming-convention */

0 commit comments

Comments
 (0)