Registry /
aws / databricks-labs-blueprint
Databricks Labs Blueprint is a Python library that provides common building blocks and utilities for Databricks Labs projects. It offers Python-native pathlib-like interfaces for Databricks Workspace paths, tools for trivial terminal user interfaces (TUI), and utilities for managing application and installation state. The current version is 0.12.0, with a regular release cadence, typically monthly or bi-monthly, reflecting active development and maintenance. [1, 3]
Install & Compatibility
Where this runs
tested against v0.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✕ build_error
56MB installed
● package 56MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
WorkspacePath
✓ from databricks.labs.blueprint.paths import WorkspacePath
Provides pathlib-like interface for Databricks Workspace paths.
Prompts
✓ from databricks.labs.blueprint.tui import Prompts
Offers utilities for interactive terminal user interfaces (TUI).
ProductInfo
✓ from databricks.labs.blueprint.wheels import ProductInfo
Used for managing wheel installations and dependencies.
This quickstart demonstrates how to initialize a `WorkspaceClient` and use `WorkspacePath` to create and manage directories within your Databricks workspace. It expands a relative path to the user's home directory, creates the specified folder structure, verifies its existence, and then cleans it up. Ensure your Databricks SDK authentication (environment variables or CLI profile) is configured before running. [1]
import os
from databricks.sdk import WorkspaceClient
from databricks.labs.blueprint.paths import WorkspacePath
# Ensure DATABRICKS_HOST and DATABRICKS_TOKEN environment variables are set,
# or a Databricks CLI profile is configured.
# For local testing, you might run:
# export DATABRICKS_HOST='https://<your-databricks-instance>.cloud.databricks.com'
# export DATABRICKS_TOKEN='dapi...'
if not os.environ.get('DATABRICKS_HOST') or not os.environ.get('DATABRICKS_TOKEN'):
print("Please set DATABRICKS_HOST and DATABRICKS_TOKEN environment variables or configure Databricks CLI.")
# In a real quickstart, you might exit or raise an error here.
# For demonstration, we'll use placeholder values that will likely fail.
ws = WorkspaceClient(host=os.environ.get('DATABRICKS_HOST', 'https://example.cloud.databricks.com'),
token=os.environ.get('DATABRICKS_TOKEN', 'dapi-fake-token'))
else:
ws = WorkspaceClient()
print(f"Initialized WorkspaceClient for host: {ws.host}")
try:
user_name = ws.current_user.me().user_name
print(f"Current user: {user_name}")
# Example: Working with user home folders
folder_name = 'blueprint-test-folder'
wsp = WorkspacePath(ws, f"~/{{folder_name}}/sub/dir")
# Expand the user path and create the directory
with_user = wsp.expanduser()
print(f"Expanded path: {with_user}")
with_user.mkdir()
print(f"Directory '{with_user}' created.")
# Verify existence
assert with_user.is_dir()
print(f"Directory '{with_user}' exists.")
# Clean up (recursive rmdir)
with_user.parent.parent.rmdir(recursive=True)
assert not with_user.parent.parent.exists()
print(f"Directory '{with_user.parent.parent}' and its contents removed.")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure your Databricks environment is correctly configured (host, token, permissions).")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'blueprint'
The 'databricks-labs-blueprint' package, which provides the 'blueprint' module, is not installed or not available in the current Python environment.
fixInstall the package using pip: `pip install databricks-labs-blueprint`
ImportError: cannot import name 'WorkspacePath' from 'blueprint'
The 'WorkspacePath' class is located within the 'blueprint.path' submodule, not directly under the top-level 'blueprint' package.
fixImport 'WorkspacePath' from its correct submodule: `from blueprint.path import WorkspacePath`
AttributeError: 'WorkspacePath' object has no attribute 'touch'
The 'WorkspacePath' class provides a pathlib-like interface but does not implement all methods available in 'pathlib.Path', such as 'touch()'.
fixUse an alternative method to create an empty file, such as `workspace_path.write_text('')`. RuntimeError: dbutils is not available.
The Databricks-specific functionalities, like 'WorkspacePath', rely on the 'dbutils' object, which is only available within a Databricks notebook or job environment. This error occurs when the code is run outside Databricks.
fixRun the code within a Databricks notebook or job environment, or mock 'dbutils' for local testing if appropriate.
Audit
Dependencies
databricks-sdkrequiredRequired for interacting with the Databricks Workspace (e.g., WorkspaceClient, WorkspacePath operations).