Skip to content

Commit fbfa4cc

Browse files
committed
Remove --experimental-is-unified-host flag and update tests
Remove the two CLI token source tests that asserted the flag was passed, as we are dropping --experimental-is-unified-host from the CLI args. Co-authored-by: Isaac
1 parent 6c426a5 commit fbfa4cc

File tree

5 files changed

+15
-81
lines changed

5 files changed

+15
-81
lines changed

databricks/sdk/config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ def host_type(self) -> HostType:
419419
Host type and client type are deprecated. Some hosts can now support both workspace and account APIs.
420420
This method returns the HostType based on the host pattern, which is not accurate.
421421
For example, a unified host can support both workspace and account APIs, but WORKSPACE is returned.
422+
423+
This method still returns the correct value for legacy hosts which only support either workspace or account APIs.
422424
"""
423425
if not self.host:
424426
return HostType.WORKSPACE
@@ -436,7 +438,8 @@ def client_type(self) -> ClientType:
436438
Host type and client type are deprecated. Some hosts can now support both workspace and account APIs.
437439
This method returns the ClientType based on the host pattern, which is not accurate.
438440
For example, a unified host can support both workspace and account APIs, but WORKSPACE is returned.
439-
Use client_type instead.
441+
442+
This method still returns the correct value for legacy hosts which only support either workspace or account APIs.
440443
"""
441444
host_type = self.host_type
442445

@@ -452,10 +455,11 @@ def client_type(self) -> ClientType:
452455
@property
453456
def is_account_client(self) -> bool:
454457
"""[Deprecated]
455-
Host type and client type are deprecated. Clients can now support both workspace and account APIs.
458+
Host type and client type are deprecated. Some hosts can now support both workspace and account APIs.
456459
This method returns True if the host is an accounts host, which is not accurate.
457460
For example, a unified host can support both workspace and account APIs, but False is returned.
458-
Use client_type instead.
461+
462+
This method still returns the correct value for legacy hosts which only support either workspace or account APIs.
459463
"""
460464
if not self.host:
461465
return False

databricks/sdk/credentials_provider.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -984,14 +984,9 @@ def _validate_token_scopes(self, token: oauth.Token):
984984
def _build_host_args(cfg: "Config") -> List[str]:
985985
"""Build CLI arguments using --host (legacy path)."""
986986
args = ["auth", "token", "--host", cfg.host]
987-
if cfg.experimental_is_unified_host:
988-
# For unified hosts, pass account_id, workspace_id, and experimental flag
989-
args += ["--experimental-is-unified-host"]
990-
if cfg.account_id:
991-
args += ["--account-id", cfg.account_id]
992-
if cfg.workspace_id:
993-
args += ["--workspace-id", str(cfg.workspace_id)]
994-
elif cfg.client_type == ClientType.ACCOUNT:
987+
# This is here to support older versions of the Databricks CLI, so we need to keep the client type check.
988+
# This won't work for unified hosts, but it is not supposed to.
989+
if cfg.client_type == ClientType.ACCOUNT:
995990
args += ["--account-id", cfg.account_id]
996991
return args
997992

tests/integration/conftest.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,10 @@ def _load_debug_env_if_runs_from_ide(key) -> bool:
176176

177177

178178
def _is_in_debug() -> bool:
179-
return (
180-
os.path.basename(sys.argv[0])
181-
in [
182-
"_jb_pytest_runner.py",
183-
"testlauncher.py",
184-
]
185-
or "vscode_pytest" in sys.modules
186-
)
179+
return os.path.basename(sys.argv[0]) in [
180+
"_jb_pytest_runner.py",
181+
"testlauncher.py",
182+
]
187183

188184

189185
def _is_cloud(cloud: Cloud) -> bool:

tests/integration/test_auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def test_wif_workspace(ucacct, env_or_skip, random):
273273

274274

275275
def test_workspace_config_resolves_account_and_workspace_id(w, env_or_skip):
276+
"""Test that Config resolves account_id and workspace_id from host metadata."""
276277
env_or_skip("CLOUD_ENV")
277278

278279
config = Config()

tests/test_credentials_provider.py

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -310,68 +310,6 @@ def mock_exchange_id_token(id_token: oidc.IdToken):
310310
class TestDatabricksCliTokenSourceArgs:
311311
"""Tests that DatabricksCliTokenSource constructs correct CLI arguments."""
312312

313-
def test_unified_host_passes_all_flags(self, mocker):
314-
"""Unified host should pass --experimental-is-unified-host, --account-id, and --workspace-id."""
315-
# Mock the parent class __init__ to capture the command arguments
316-
mock_init = mocker.patch.object(
317-
credentials_provider.CliTokenSource,
318-
"__init__",
319-
return_value=None,
320-
)
321-
322-
mock_cfg = Mock()
323-
mock_cfg.profile = None
324-
mock_cfg.host = "https://example.databricks.com"
325-
mock_cfg.experimental_is_unified_host = True
326-
mock_cfg.account_id = "test-account-id"
327-
mock_cfg.workspace_id = 12345
328-
mock_cfg.databricks_cli_path = "/path/to/databricks"
329-
mock_cfg.disable_async_token_refresh = False
330-
331-
credentials_provider.DatabricksCliTokenSource(mock_cfg)
332-
333-
# Verify the command was constructed correctly
334-
call_kwargs = mock_init.call_args
335-
cmd = call_kwargs.kwargs["cmd"]
336-
337-
assert cmd[0] == "/path/to/databricks"
338-
assert "auth" in cmd
339-
assert "token" in cmd
340-
assert "--host" in cmd
341-
assert "https://example.databricks.com" in cmd
342-
assert "--experimental-is-unified-host" in cmd
343-
assert "--account-id" in cmd
344-
assert "test-account-id" in cmd
345-
assert "--workspace-id" in cmd
346-
assert "12345" in cmd
347-
348-
def test_unified_host_without_workspace_id(self, mocker):
349-
"""Unified host without workspace_id should only pass --experimental-is-unified-host and --account-id."""
350-
mock_init = mocker.patch.object(
351-
credentials_provider.CliTokenSource,
352-
"__init__",
353-
return_value=None,
354-
)
355-
356-
mock_cfg = Mock()
357-
mock_cfg.profile = None
358-
mock_cfg.host = "https://example.databricks.com"
359-
mock_cfg.experimental_is_unified_host = True
360-
mock_cfg.account_id = "test-account-id"
361-
mock_cfg.workspace_id = None
362-
mock_cfg.databricks_cli_path = "/path/to/databricks"
363-
mock_cfg.disable_async_token_refresh = False
364-
365-
credentials_provider.DatabricksCliTokenSource(mock_cfg)
366-
367-
call_kwargs = mock_init.call_args
368-
cmd = call_kwargs.kwargs["cmd"]
369-
370-
assert "--experimental-is-unified-host" in cmd
371-
assert "--account-id" in cmd
372-
assert "test-account-id" in cmd
373-
assert "--workspace-id" not in cmd
374-
375313
def test_account_client_passes_account_id(self, mocker):
376314
"""Non-unified account client should pass --account-id."""
377315
mock_init = mocker.patch.object(

0 commit comments

Comments
 (0)