Opinionated Databricks Utilities
Project description
Opinionated Databricks Utilities (ODU)
ODU is a collection of opinionated utilities for working on the Databricks platform.
The Problem
When Databricks notebooks run as workflow tasks, the current working directory is a random location on the cluster — not the directory where your notebook lives. This breaks relative imports and pip install -r requirements.txt.
ODU solves this by providing utilities to:
- Locate your repository root from inside a running notebook.
- Add your
src/directory tosys.path.
Installation
pip install odu
Quick Start
Add these two cells at the top of every notebook that runs as a workflow task.
Cell 1 — Before restart:
import sys
from odu.bootstrap import repo_root_finder, add_src_path_to_sys_path
repo_root = repo_root_finder(dbutils)
# Install requirements and restart Python to make them effective
%pip install -r {repo_root}/requirements.txt
dbutils.library.restartPython()
Cell 2 — After restart:
import sys
from odu.bootstrap import repo_root_finder, add_src_path_to_sys_path
repo_root = repo_root_finder(dbutils)
add_src_path_to_sys_path(repo_root, sys)
# Now your src/ packages are importable
from my_package import my_module
Advanced Usage
# Get all repo paths as a dict
fs = repo_root_finder(dbutils, returns="all")
# {
# "repo_root": "/Workspace/Repos/user/my-repo",
# "notebook_path": "/Workspace/Repos/user/my-repo/notebooks/my_nb",
# "src_path": "/Workspace/Repos/user/my-repo/src",
# "requirements_path": "/Workspace/Repos/user/my-repo/requirements.txt",
# "notebooks_dir_path": "/Workspace/Repos/user/my-repo/notebooks",
# "configs_path": None, # (doesn't exist)
# "resources_path": None,
# "databricks_resources_path": None,
# }
add_src_path_to_sys_path(fs, sys) # works with both str and dict
# Custom markers and matching strategy
repo_root = repo_root_finder(
dbutils,
match_strategy="at least k",
k=2,
markers=["src", "notebooks", "requirements.txt", "pyproject.toml"],
)
Documentation
Full documentation is available at the GitHub Pages site.
License
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 odu-0.1.0.tar.gz.
File metadata
- Download URL: odu-0.1.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee7d4430fd671acd44d2a5a9ff050bfb7950db662390b12f3a2be9120b029a20
|
|
| MD5 |
18c177c1fac062420bedc4ba76b97cc1
|
|
| BLAKE2b-256 |
eaba6becba22d45c7c9c36375a13852817a9c327672d519e895569237739d1d2
|
Provenance
The following attestation bundles were made for odu-0.1.0.tar.gz:
Publisher:
main-release.yml on neolaw84/opinionated-databricks-utilities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
odu-0.1.0.tar.gz -
Subject digest:
ee7d4430fd671acd44d2a5a9ff050bfb7950db662390b12f3a2be9120b029a20 - Sigstore transparency entry: 1223815723
- Sigstore integration time:
-
Permalink:
neolaw84/opinionated-databricks-utilities@a5edd10f818643ae0b77e1271e8b15c428118510 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/neolaw84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-release.yml@a5edd10f818643ae0b77e1271e8b15c428118510 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file odu-0.1.0-py3-none-any.whl.
File metadata
- Download URL: odu-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45f7f56c1feada49f00d1adf328f6b7dd2588d170ed5018da0bd1a4439decf36
|
|
| MD5 |
4672b4d7e772e9c2f28bb46134d17be3
|
|
| BLAKE2b-256 |
3f540f80b31928360006e70e6fcf3a72e64f442030ca1ca0e264e326492077fc
|
Provenance
The following attestation bundles were made for odu-0.1.0-py3-none-any.whl:
Publisher:
main-release.yml on neolaw84/opinionated-databricks-utilities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
odu-0.1.0-py3-none-any.whl -
Subject digest:
45f7f56c1feada49f00d1adf328f6b7dd2588d170ed5018da0bd1a4439decf36 - Sigstore transparency entry: 1223815768
- Sigstore integration time:
-
Permalink:
neolaw84/opinionated-databricks-utilities@a5edd10f818643ae0b77e1271e8b15c428118510 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/neolaw84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-release.yml@a5edd10f818643ae0b77e1271e8b15c428118510 -
Trigger Event:
pull_request
-
Statement type: