Skip to content

Commit

Permalink
Improve auto-migration template (#1200)
Browse files Browse the repository at this point in the history
Should help avoid confusion on why this file was created and how to
avoid it if neccessary
  • Loading branch information
ilia-db authored Apr 24, 2024
1 parent 132044e commit 370e0f5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"properties": {
"auto_migration": {
"type": "boolean",
"description": "Auto migration",
"order": 1
},
"project_name": {
"type": "string",
"description": "Project name",
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
7 changes: 5 additions & 2 deletions packages/databricks-vscode/src/bundle/BundleProjectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ export class BundleProjectManager {
}
await this.migrateProjectJsonToBundle(
authProvider as ProfileAuthProvider,
legacyProjectConfig
legacyProjectConfig,
true
);
recordEvent({success: true});
}
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 370e0f5

Please sign in to comment.