Skip to content

Added support for Databricks Apps in DABs#1928

Merged
andrewnester merged 32 commits intomainfrom
feature/apps
Jan 13, 2025
Merged

Added support for Databricks Apps in DABs#1928
andrewnester merged 32 commits intomainfrom
feature/apps

Conversation

@andrewnester
Copy link
Contributor

@andrewnester andrewnester commented Nov 21, 2024

Changes

Now it's possible to configure new app resource in bundle and point it to the custom source_code_path location where Databricks App code is defined.

On databricks bundle deploy DABs will create an app. All consecutive databricks bundle deploy execution will update an existing app if there are any updated

On databricks bundle run <my_app> DABs will execute app deployment. If the app is not started yet, it will start the app first.

Bundle configuration

bundle:
  name: apps

variables:
  my_job_id:
    description: "ID of job to run app"
    lookup:
      job: "My Job"
  databricks_name:
    description: "Name for app user"
  additional_flags:
    description: "Additional flags to run command app"
    default: ""
  my_app_config:
    type: complex
    description: "Configuration for my Databricks App"
    default:
      command:
        - flask
        - --app
        - hello
        - run
        - ${var.additional_flags}
      env:
        - name: DATABRICKS_NAME
          value: ${var.databricks_name}

resources:
  apps:
    my_app:
      name: "anester-app" # required and has to be unique
      description: "My App"
      source_code_path: ./app # required and points to location of app code
      config: ${var.my_app_config}
      resources:
        - name: "my-job"
          description: "A job for app to be able to run"
          job:
            id: ${var.my_job_id}
            permission: "CAN_MANAGE_RUN"
      permissions:
        - user_name: "foo@bar.com"
          level: "CAN_VIEW"
        - service_principal_name: "my_sp"
          level: "CAN_MANAGE"

targets:
  dev:
    variables:
      databricks_name: "Andrew (from dev)"
      additional_flags: --debug
  
  prod:
    variables:
      databricks_name: "Andrew (from prod)"

Execution

  1. databricks bundle deploy -t dev
  2. databricks bundle run my_app -t dev

If app is started

✓ Getting the status of the app my-app
✓ App is in RUNNING state
✓ Preparing source code for new app deployment.
✓ Deployment is pending
✓ Starting app with command: flask --app hello run --debug
✓ App started successfully
You can access the app at <app-url>

If app is not started

✓ Getting the status of the app my-app
✓ App is in UNAVAILABLE state
✓ Starting the app my-app
✓ App is starting...
....
✓ App is starting...
✓ App is started!
✓ Preparing source code for new app deployment.
✓ Downloading source code from /Workspace/Users/...
✓ Starting app with command: flask --app hello run --debug
✓ App started successfully
You can access the app at <app-url>

Tests

Added unit and config tests + manual test.

--- PASS: TestAccDeployBundleWithApp (404.59s)
PASS
coverage: 36.8% of statements in ./...
ok      github.com/databricks/cli/internal/bundle       405.035s        coverage: 36.8% of statements in ./...

@andrewnester andrewnester requested a review from pietern December 30, 2024 11:44
@github-actions
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 1928
  • Commit SHA: 7693f0add0ab88bd49c109047cedc75cc16edd42

Checks will be approved automatically on success.

}

func (a *App) TerraformResourceName() string {
return "databricks_app"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For later; this duplicates the entries in SupportedResources. Can it be de-duped?

PLACEHOLDER
"state":
"description": |-
PLACEHOLDER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you regenerate the OpenAPI annotations as well? That will populate these descriptions.

Can be in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pietern will do anyway as part of Go SDK upgarde

@andrewnester andrewnester added this pull request to the merge queue Jan 13, 2025
Merged via the queue into main with commit 913e10a Jan 13, 2025
9 checks passed
@andrewnester andrewnester deleted the feature/apps branch January 13, 2025 16:49
andrewnester added a commit that referenced this pull request Jan 16, 2025
New feature announcement.

You can now manage Databricks Apps using DABs by defining an `app` resource in your bundle configuration.
For more information see Databricks documentation https://docs.databricks.com/en/dev-tools/bundles/resources.html#app

CLI:
 * Filter out system clusters in cluster picker ([#2131](#2131)).
 * Process all the fields in top level request object even if it contains request body ([#2155](#2155)).

Bundles:
 * Added support for Databricks Apps in DABs ([#1928](#1928)).
 * Allow artifact path to be located outside the sync root ([#2128](#2128)).
 * Retry app deployment if there is an active deployment in progress ([#2153](#2153)).
 * Resolve variables in a loop ([#2164](#2164)).
 * Improve resolution of complex variables within complex variables ([#2157](#2157)).
 * Added output message to warn about slower deployments with apps ([#2161](#2161)).
 * Patch references to UC schemas to capture dependencies automatically ([#1989](#1989)).
 * Format default-python template ([#2110](#2110)).
 * Encourage the use of root_path in production to ensure single deployment ([#1712](#1712)).
 * Log warnings to stderr for "bundle validate -o json" ([#2109](#2109)).

Internal:
 * Move merge fix-ups after variable resolution ([#2125](#2125)).
 * Enable linter 'unconvert' and fix the issues found ([#2136](#2136)).
 * Coverage for acceptance tests ([#2123](#2123)).
 * Add acceptance tests for builtin templates ([#2135](#2135)).
 * Add a unique schema for recreate pipeline test ([#2159](#2159)).
 * Migrate resolution tests to acceptance tests ([#2143](#2143)).
 * Update runner for the publish-winget job ([#2105](#2105)).
 * Add a test for complex variable resolution with 3 levels ([#2163](#2163)).

API Changes:
 * Changed `databricks account federation-policy update` command with new required argument order.
 * Changed `databricks account service-principal-federation-policy update` command with new required argument order.

OpenAPI commit 779817ed8d63031f5ea761fbd25ee84f38feec0d (2025-01-08)
Dependency updates:
 * Upgrade TF provider to 1.63.0 ([#2162](#2162)).
 * Bump golangci-lint version to v1.63.4 from v1.63.1 ([#2114](#2114)).
 * Bump astral-sh/setup-uv from 4 to 5 ([#2116](#2116)).
 * Bump golang.org/x/oauth2 from 0.24.0 to 0.25.0 ([#2080](#2080)).
 * Bump github.com/hashicorp/hc-install from 0.9.0 to 0.9.1 ([#2079](#2079)).
 * Bump golang.org/x/term from 0.27.0 to 0.28.0 ([#2078](#2078)).
 * Bump github.com/databricks/databricks-sdk-go from 0.54.0 to 0.55.0 ([#2126](#2126)).
github-merge-queue bot pushed a commit that referenced this pull request Jan 16, 2025
### New feature announcement

#### Databricks Apps support

You can now manage Databricks Apps using DABs by defining an `app`
resource in your bundle configuration.
For more information see Databricks documentation
https://docs.databricks.com/en/dev-tools/bundles/resources.html#app

#### Referencing complex variables in complex variables

You can now reference complex variables within other complex variables.
For more details see #2157

CLI:
* Filter out system clusters in cluster picker
([#2131](#2131)).
* Add command line flags for fields that are not in the API request body
([#2155](#2155)).

Bundles:
* Added support for Databricks Apps in DABs
([#1928](#1928)).
* Allow artifact path to be located outside the sync root
([#2128](#2128)).
* Retry app deployment if there is an active deployment in progress
([#2153](#2153)).
* Resolve variables in a loop
([#2164](#2164)).
* Improve resolution of complex variables within complex variables
([#2157](#2157)).
* Added output message to warn about slower deployments with apps
([#2161](#2161)).
* Patch references to UC schemas to capture dependencies automatically
([#1989](#1989)).
* Format default-python template
([#2110](#2110)).
* Encourage the use of root_path in production to ensure single
deployment ([#1712](#1712)).
* Log warnings to stderr for "bundle validate -o json"
([#2109](#2109)).

API Changes:
* Changed `databricks account federation-policy update` command with new
required argument order.
* Changed `databricks account service-principal-federation-policy
update` command with new required argument order.

OpenAPI commit 779817ed8d63031f5ea761fbd25ee84f38feec0d (2025-01-08)
Dependency updates:
* Upgrade TF provider to 1.63.0
([#2162](#2162)).
* Bump golangci-lint version to v1.63.4 from v1.63.1
([#2114](#2114)).
* Bump astral-sh/setup-uv from 4 to 5
([#2116](#2116)).
* Bump golang.org/x/oauth2 from 0.24.0 to 0.25.0
([#2080](#2080)).
* Bump github.com/hashicorp/hc-install from 0.9.0 to 0.9.1
([#2079](#2079)).
* Bump golang.org/x/term from 0.27.0 to 0.28.0
([#2078](#2078)).
* Bump github.com/databricks/databricks-sdk-go from 0.54.0 to 0.55.0
([#2126](#2126)).

---------

Co-authored-by: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Apr 9, 2025
## Changes
The --config-dir and --source-dir for "bundle generate app" no longer
join value with bundle root.

Related: #1928

## Why
This arguments should be interpreted relative to CWD, as is the case for
all other generate commands.

## Tests
Existing tests.
pietern added a commit that referenced this pull request Jun 5, 2025
## Changes

The `TerraformResourceName` field was added to the description struct in
#1928. This PR removes the duplication between that field and the
`TerraformResourceName` function on all resources. It also uses this
value when interpolating Terraform resource references instead of
keeping another hardcoded value around. The value for the model serving
endpoint is updated to reflect the right value (it wasn't used before).


## Tests

Existing tests pass.
} else {
// If the app exists in terraform and bundle, we always set modified status to updated
// because we don't really know if the app source code was updated or not.
cur.ModifiedStatus = resources.ModifiedStatusUpdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other resources ever set ModifiedStatusUpdated, do we need this? @andrewnester

Are there plans to implement this status and use in IDE and Dabs-in-the-workspace? @ilia-db @ilyakuz-db @fjakobs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use modified_status in DABs in WS but it defaults to updated if not set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants