Skip to content

fix(dbutils): accept pathlib.Path arguments in fs methods#1461

Open
nileshpatil6 wants to merge 3 commits into
databricks:mainfrom
nileshpatil6:fix/dbutils-pathlib-support
Open

fix(dbutils): accept pathlib.Path arguments in fs methods#1461
nileshpatil6 wants to merge 3 commits into
databricks:mainfrom
nileshpatil6:fix/dbutils-pathlib-support

Conversation

@nileshpatil6

Copy link
Copy Markdown

Fixes #1459

dbutils.fs methods only accepted plain strings, so passing a pathlib.Path failed even though Path is idiomatic in modern Python.

What changed

Added a small _as_str helper in databricks/sdk/dbutils.py that converts a Path to str and leaves strings untouched. Called it at the entry of every _FsUtil method that takes a path argument (ls, cp, mv, rm, mkdirs, head, put, mount, unmount, updateMount).

Tests

Added 7 unit tests (one per patched method) that pass a Path object and assert the underlying API is still called with a plain string.

Signed-off-by: nileshpatil6 technil6436@gmail.com

DBUtils fs methods only accepted string paths, raising an error when
pathlib.Path objects were passed. Since Path is the standard way to
handle paths in modern Python, convert Path to str at method entry
via a small _as_str helper.

Fixes databricks#1459

Signed-off-by: nileshpatil6 <technil6436@gmail.com>
Signed-off-by: nileshpatil6 <technil6436@gmail.com>
@GodNooNoo

Copy link
Copy Markdown

@nileshpatil6 any updates here?

@github-actions

Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1461
  • Commit SHA: 109e64d1084598ccae568753f064597dda3abf22

Checks will be approved automatically on success.

@nileshpatil6

Copy link
Copy Markdown
Author

Hey, sorry for the delay. The branch had gone stale, upstream removed NEXT_CHANGELOG.md (and its workflow) in the v0.117.0 release, which is what caused the merge conflict. I've merged the latest main and dropped the changelog hunk since that whole mechanism is gone now. The diff is back to just the two files: dbutils.py and its tests. Reran the full tests/test_dbutils.py suite locally, 26/26 pass, and ruff format/lint (pinned 0.5.6) are clean. Worth noting per the updated CONTRIBUTING.md this repo is now a read-only mirror, so even once approved a maintainer re-applies the change internally and it ships with a release rather than merging here directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE] DBUtils does not support Path objects.

2 participants