Manage Databricks notebook parameters as Python classes
Project description
dbxparams
A lightweight library for managing Databricks notebook parameters with type safety, defaults, and automatic widget creation.
✨ Features
- Auto-create and populate Databricks widgets
- Type-safe parameter casting (
int,float,bool,date,datetime) - Support for defaults dict and class defaults
- Custom error handling:
MissingParameterError,InvalidTypeError - Cleaner, more maintainable notebooks (no more repetitive
dbutils.widgets.get!)
📦 Installation
pip install dbxparams
🚀 Quick Start
from dbxparams import NotebookParams
class MyParams(NotebookParams):
market: str # required
env: str = "dev" # optional with default
retries: int = 3 # optional with default
# Pass dbutils to auto-create widgets and populate values
params = MyParams(dbutils)
print(params.market) # Read from widget
print(params.env) # Uses default "dev" if not set
print(params.retries) # Uses default 3
🔒 Error Handling
- MissingParameterError → Raised when a required parameter is missing
- InvalidTypeError → Raised when a value cannot be cast to the expected type
Example:
class TypedParams(NotebookParams):
threshold: float
active: bool
# If "threshold" widget is "not-a-float" → InvalidTypeError
📜 License
This project is licensed under the MIT License.
Copyright (c) 2025 Víctor Ferrón Álvarez https://vicferron.github.io/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dbxparams-0.1.17.tar.gz
(6.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbxparams-0.1.17.tar.gz.
File metadata
- Download URL: dbxparams-0.1.17.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46224ab841bb8b567fef4cb538bcf87ef92643b7b66e927be7ba753d287ae0da
|
|
| MD5 |
4f90e09d9d7adc744c77b8995d4f4a07
|
|
| BLAKE2b-256 |
865fdedd679aeeee226a5205ee2e2babf709f3da37af053f57caf6b7060c92f9
|
File details
Details for the file dbxparams-0.1.17-py3-none-any.whl.
File metadata
- Download URL: dbxparams-0.1.17-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59f7b66fa83889a8c0c026a76648577ad74c658ad565690d9e4c42707449619f
|
|
| MD5 |
d6210da635f700ee433eae05839d2928
|
|
| BLAKE2b-256 |
227ac424f7a430f9c7ab66246d93bf22395abc0e7912f91232d2798dfe3aff08
|