Skip to main content

Opinionated Databricks Utilities (ODU)

PyPI version License: MIT Python 3.12+

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:

  1. Locate your repository root from inside a running notebook.
  2. Add your src/ directory to sys.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

MIT

Release files for odu 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for odu 0.1.0
File Size Uploaded
odu-0.1.0.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for odu 0.1.0
File Interpreter ABI Platform
odu-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / odu-0.1.0.tar.gz

Download URL odu-0.1.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ee7d4430fd671acd44d2a5a9ff050bfb7950db662390b12f3a2be9120b029a20
BLAKE2b-256 checksum
How to use checksums
eaba6becba22d45c7c9c36375a13852817a9c327672d519e895569237739d1d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Release files / odu-0.1.0-py3-none-any.whl

Download URL odu-0.1.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45f7f56c1feada49f00d1adf328f6b7dd2588d170ed5018da0bd1a4439decf36
BLAKE2b-256 checksum
How to use checksums
3f540f80b31928360006e70e6fcf3a72e64f442030ca1ca0e264e326492077fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page