Skip to main content

Manage Databricks notebook parameters as Python classes

Project description

dbxparams

PyPI version Python Versions License: MIT

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

🧩 Load Parameters from JSON

You can now initialize your parameter class directly from a JSON file or raw JSON string using from_json():

from dbxparams import NotebookParams

class ConfigParams(NotebookParams):
    database_name: str
    storage_path: str

params = ConfigParams.from_json("config/settings.json", dbutils=dbutils)

print(params.database_name)
print(params.storage_path)

This is useful for storing environment settings, connection strings, or other reusable constants without hardcoding them into your notebooks.


🚀 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


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.18.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbxparams-0.1.18-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file dbxparams-0.1.18.tar.gz.

File metadata

  • Download URL: dbxparams-0.1.18.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for dbxparams-0.1.18.tar.gz
Algorithm Hash digest
SHA256 a08e3037dbae704e166e1dfaab1b9c0b8e5d260dddf08d512875a54c91c3a574
MD5 58f0f21fd7818280f3e9620c1e31728d
BLAKE2b-256 966de99c802335addeffd6e61651bb466cd2134a618d8f88723e6b177f8483f0

See more details on using hashes here.

File details

Details for the file dbxparams-0.1.18-py3-none-any.whl.

File metadata

  • Download URL: dbxparams-0.1.18-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for dbxparams-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 9af366ca1f25738ed52118bcaee1d534cab410ce707cd3bc6580ddcaa2a3c04d
MD5 a3405ee7a42e50d6242da9a68754f8e3
BLAKE2b-256 7d39231e1c5ae66bb36e200e5305b1afa90354a9caa881ef2faa17bce071ada3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page