feat(backend): add Databricks CLI auth for local dev#49
Conversation
Release v.0.3.0
…cloudfetch Fix/0.3.1 infinite recursion in DatabricksAuth on startup
release v0.4.0
|
Thanks for this — the CLI auth path is a clean addition and the precedence ordering (app → PAT → CLI) is well tested. A few things I'd like addressed before merge: 1. (blocking) 2. (should-fix) thread-safety of the CloudFetch recursion guard 3. (nit) scope Everything else looks good: no secret leakage in logs, no token persisted, CLI mode is correctly unreachable in App mode, and the health check fails eagerly. 👍 |
|
Thanks for the feedback! I'll try to address over the next week or so. |
What
Adds a third auth mode to
DatabricksAuthfor local development:Databricks CLI profile (
~/.databrickscfgpopulated bydatabricks auth login).Selected via
DATABRICKS_CONFIG_PROFILEor implicitly via the default profile.Resolution order is unchanged for the existing modes:
DATABRICKS_APP_PORT) — M2M OAuth (unchanged)DATABRICKS_TOKENset — PAT (unchanged)DATABRICKS_CONFIG_PROFILEset — named CLI profile (new)~/.databrickscfgdefault profile (new)Why
Some Databricks workspace policies block PAT generation, which prevented
local development entirely. CLI auth uses the SDK's
databricks.sdk.core.Configto read profiles — the credential is short-livedand refreshes transparently, no token to copy-paste into
.env.How to test
DATABRICKS_TOKENin.envand rundatabricks auth login.uv run python run.py— startup log should readDatabricksAuth init — host=..., mode=cli, profile=default, warehouse=....GET /healthreportsDatabricks CLI profile 'default' configured.DATABRICKS_CONFIG_PROFILE=<name>to use a non-default profile;set it to a bogus value to confirm the WARNING surfaces.
regression tests in tests/units/auth/test_auth.py.
Tests
uv run pytest tests/units/ -q\→ 2110 passed in ~15s.