extends databricks dbutils
Project description
databricks-ddbxutils
dbutils 로 부족한 부분을 확장한 ddbxutils
Feature
-
dbutils.widgets에 jinja2 template 적용
setup
cd <PROJECT_ROOT>
pip install poetry
venv
poetry shell
Build
poetry build
Run
in databricks w/o init_script(= Serverless)
- Add Wheel
- wheel upload 용 Volume 생성 후 upload
/Volumes/<CATALOG>/<DATABASE>/<VOLUME_NAME>/ddbxutils-<VERSION>-py3-none-any.whl
- notebook 의 우측 Environment 에서 Environment version 2로 지정 후 volume 에 upload 한 wheel file 추가 후 Apply
- wheel upload 용 Volume 생성 후 upload
- Usage
# dbutils.widgets.text('rawdate', '2025-05-24', 'Raw Date') # dbutils.widgets.text('next_day', '{{add_days(rawdate, "%Y-%m-%d", "", 1)}}', 'Next Day') import ddbxutils next_day = ddbxutils.widgets.get('next_day') # next_day: 2025-05-25
in databricks w/ init_script
- Add Wheel
- wheel upload 용 Volume 생성 후 upload
/Volumes/<CATALOG>/<DATABASE>/<VOLUME_NAME>/ddbxutils-<VERSION>-py3-none-any.whl
- Libraries
/Volumes/<CATALOG>/<DATABASE>/<VOLUME_NAME>/ddbxutils-<VERSION>-py3-none-any.whl
- wheel upload 용 Volume 생성 후 upload
/Volumes/<CATALOG>/<DATABASE>/<VOLUME_NAME>/init_script_ddbxutils.sh#! /bin/bash STARTUP_SCRIPT=/tmp/pyspark_startup.py cat >> ${STARTUP_SCRIPT} << EOF prefix = 'PYTHONSTARTUP_ddbxutils' print(f'{prefix} custom startup script loading...') try: import ddbxutils print(f'{prefix} Custom modules [ddbxutils] are loaded.') except Exception as e: print(f'{prefix} e={e}') print(f'{prefix} import ddbxutils failed') EOF
- Spark config
spark.executorEnv.PYTHONSTARTUP /tmp/pyspark_startup.py
- Environment variables
PYTHONSTARTUP=/tmp/pyspark_startup.py
- Init scripts
/Volumes/<CATALOG>/<DATABASE>/<VOLUME_NAME>/init_script_ddbxutils.sh
- Usage
# dbutils.widgets.text('rawdate', '2025-05-24', 'Raw Date') # dbutils.widgets.text('next_day', '{{add_days(rawdate, "%Y-%m-%d", "", 1)}}', 'Next Day') next_day = ddbxutils.widgets.get('next_day') # next_day: 2025-05-25
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
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 databricks_ddbxutils-0.3.0.tar.gz.
File metadata
- Download URL: databricks_ddbxutils-0.3.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492e9b93d6eece82da98a6ada7fe89491f8caa5d5ff8212fecc576376852efc0
|
|
| MD5 |
42a12a7478f8471b5e01c2427476d61a
|
|
| BLAKE2b-256 |
8432fe5b34b3fa56559c5734ad2c8b2c2f430c4865baf8a4f7c668beca0aa23d
|
File details
Details for the file databricks_ddbxutils-0.3.0-py3-none-any.whl.
File metadata
- Download URL: databricks_ddbxutils-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
620c3a8bab6b98c7bcc5b2a013166b0e710441405c656576b41ca46cf6e1d637
|
|
| MD5 |
91cf604dba4d6f0a86ad7618ef92d4ec
|
|
| BLAKE2b-256 |
0e37e2e28fe69700e3725d71eef4a67b2d520f6767ed3981cfc3e1c9616e78d9
|