DataBricks CLI eXtensions (dbx)

0.8.19 · active · verified Thu Apr 16

dbx is a Python CLI extension for Databricks that simplifies project development, deployment, and management workflows, especially for MLOps. It provides tools for structuring Databricks projects, building artifacts, and deploying them to various Databricks environments. The current version is 0.8.19, and it maintains an active release cadence with frequent updates.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates programmatic access to `dbx` for retrieving project configuration and listing profiles. This requires an existing `dbx` project setup with `dbx.json` and `deployment.yml` files, and configured Databricks credentials (e.g., via `dbx configure` or environment variables).

import os
from dbx.api import dbx_api

# This example assumes you have a 'dbx.json' and 'deployment.yml'
# in your current working directory, defining a dbx project.
# It also assumes you have configured dbx credentials (e.g., via `dbx configure`)
# or set environment variables like DBX_HOST and DBX_TOKEN.

print("Attempting to get project configuration...")
try:
    # Load the project configuration from dbx.json in the current directory
    project_config = dbx_api.get_project_config()
    print(f"Project Name: {project_config.project_name}")
    print(f"Project Type: {project_config.project_type}")

    # A simpler example: listing current connection profiles
    print("\nListing configured dbx connection profiles:")
    profiles = dbx_api.get_available_profiles()
    if profiles:
        for profile in profiles:
            print(f"- {profile}")
    else:
        print("No profiles found. Run `dbx configure` to set one up.")

except Exception as e:
    print(f"Error interacting with dbx API. Ensure dbx is configured and project files exist. Error: {e}")
    print("Hint: Run `dbx configure` in your terminal to set up credentials.")

view raw JSON →