Databricks Bundles (Declarative Automation Bundles)

0.296.0 · active · verified Mon Apr 13

Databricks Bundles, recently renamed to Declarative Automation Bundles, provides Python support for defining, dynamically creating, and modifying Databricks jobs and pipelines. It extends the core Declarative Automation Bundles functionality, allowing users to apply software engineering best practices like source control, code review, testing, and CI/CD to their data and AI projects. The library is currently at version 0.296.0 and is actively maintained, with a focus on streamlining deployments and enabling programmatic configuration through Python and YAML files, orchestrated via the Databricks CLI.

Warnings

Install

Imports

Quickstart

To get started with Databricks Bundles, first ensure the Databricks CLI is installed and authenticated. Then, initialize a new bundle project using a template, typically `experimental-jobs-as-code` for Python support. Define your Databricks resources (like jobs or pipelines) in `databricks.yml` or dedicated Python files within the bundle structure. Finally, use the CLI commands `databricks bundle validate`, `databricks bundle deploy`, and `databricks bundle run` to manage and execute your project on Databricks.

# 1. Initialize a new bundle project (select 'Default Python' template when prompted)
databricks bundle init --template experimental-jobs-as-code

# 2. Navigate into the new project directory
cd <your-bundle-project-name>

# 3. Create a Python file for a job task (e.g., src/my_job.py)
#    Content for src/my_job.py:
#    print("Hello from my Databricks Bundle!")

# 4. Define a simple job in databricks.yml (or a Python resource definition if using Python bundles)
#    Example databricks.yml snippet defining a job running my_job.py (ensure 'target: dev' matches your config)
#    bundle:
#      name: my-first-bundle
#    resources:
#      jobs:
#        my_example_job:
#          name: MyExampleJob
#          tasks:
#            - task_key: run_script
#              python_file_task:
#                python_file: src/my_job.py
#              new_cluster:
#                spark_version: 13.3.x-scala2.12
#                node_type_id: Standard_DS3_v2
#                num_workers: 1
#    targets:
#      dev:
#        default: true
#        workspace:
#          host: https://<your-workspace-url>

# 5. Validate the bundle configuration
databricks bundle validate

# 6. Deploy the bundle to your Databricks workspace
databricks bundle deploy --target dev

# 7. Run the deployed job
databricks bundle run my_example_job --target dev

view raw JSON →