Registry / aws / databricks-labs-blueprint

databricks-labs-blueprint

JSON →
library0.12.0pypypi✓ verified 52d ago

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]

awsdevopsdata
pip install databricks-labs-blueprint
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
musl
glibc
py 3.10
✓ —
✓ 4.75s
py 3.11
✓ —
✓ 4.25s
py 3.12
✓ —
✓ 4.03s
py 3.13
✓ —
✓ 4.13s
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).")
Debug
Known issues
breakingIn `v0.11.3`, the unmarshalling of JSON floating-point values was fixed. Previously, JSON floats might have been silently truncated to integers. The updated functionality now raises a `SerdeError` when precision would be lost during conversion from float to integer. [release notes]
fix
Review code that reads JSON configuration files, especially if it expects integer values from floating-point inputs. Handle `SerdeError` for explicit type conversions.
affects: <0.11.3
deprecatedStarting with `v0.11.0`, using `Any` and `object` as type annotations on data classes for marshalling is deprecated and will issue a `DeprecationWarning`. [release notes]
fix
Refactor data classes to use more specific type annotations instead of `Any` or `object` to avoid deprecation warnings and ensure type safety.
affects: >=0.11.0
gotchaIn versions prior to `v0.9.3`, there was an issue where `databricks-sdk` config objects could be unintentionally overridden when creating installation config files. This could lead to unexpected behavior or incorrect workspace configurations. [release notes]
fix
Upgrade to `v0.9.3` or newer. If upgrading is not immediately possible, carefully review any custom logic that modifies or saves Databricks SDK configuration objects to ensure they are handled correctly.
affects: <0.9.3
gotchaThe `databricks-labs-blueprint` library requires Python 3.10 or newer. Installing it on Python versions older than 3.10 will result in an `ERROR: No matching distribution found`.
fix
Ensure your Python environment is version 3.10 or higher before installing `databricks-labs-blueprint`. Upgrade your Python interpreter or use a compatible virtual environment.
affects: >0.0.1
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.
fix
Install 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.
fix
Import '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()'.
fix
Use 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.
fix
Run the code within a Databricks notebook or job environment, or mock 'dbutils' for local testing if appropriate.
Upgrade
Version history
0.12.0latest on PyPI
Audit
Dependencies
databricks-sdkrequiredRequired for interacting with the Databricks Workspace (e.g., WorkspaceClient, WorkspacePath operations).
Agent activity
18 hits · last 30 days
node
8
mj12bot
3
ahrefsbot
3
seranking-bot
2
amazonbot
1
Resources