Skip to content

Commit 755f84a

Browse files
authored
Merge branch 'main' into main
2 parents 722b4b9 + b36a7b9 commit 755f84a

File tree

5 files changed

+64
-13
lines changed

5 files changed

+64
-13
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Version changelog
22

3+
## [Release] Release v0.31.1
4+
5+
### Bug Fixes
6+
7+
* Fix `DatabricksConfig.copy` when authenticated with OAuth ([#723](https://github.com/databricks/databricks-sdk-py/pull/723)).
8+
9+
10+
### Internal Changes
11+
12+
* Fix get_workspace_client test to match Go SDK behavior ([#738](https://github.com/databricks/databricks-sdk-py/pull/738)).
13+
* Verify that `WorkspaceClient` created from `AccountClient` does actually work through integration tests ([#736](https://github.com/databricks/databricks-sdk-py/pull/736)).
14+
15+
16+
317
## [Release] Release v0.31.0
418

519
### Bug Fixes

databricks/sdk/credentials_provider.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,10 @@ def inner() -> Dict[str, str]:
607607
token = token_source.token()
608608
return {'Authorization': f'{token.token_type} {token.access_token}'}
609609

610-
return OAuthCredentialsProvider(inner, token_source.token)
610+
def token() -> Token:
611+
return token_source.token()
612+
613+
return OAuthCredentialsProvider(inner, token)
611614

612615

613616
class MetadataServiceTokenSource(Refreshable):

databricks/sdk/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.31.0'
1+
__version__ = '0.31.1'

tests/integration/test_client.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import pytest
2-
3-
41
def test_get_workspace_client(ucacct, env_or_skip):
52
# Need to switch to ucacct
63
workspace_id = env_or_skip("TEST_WORKSPACE_ID")
@@ -14,11 +11,9 @@ def test_get_workspace_id(ucws, env_or_skip):
1411
assert ucws.get_workspace_id() == ws_id
1512

1613

17-
def test_creating_ws_client_from_ac_client_does_not_override_config(a):
18-
wss = list(a.workspaces.list())
19-
if len(wss) == 0:
20-
pytest.skip("no workspaces")
21-
a.get_workspace_client(wss[0])
22-
23-
# assert doesn't throw
24-
wss = list(a.workspaces.list())
14+
def test_creating_ws_client_from_ac_client_does_not_override_config(ucacct, env_or_skip):
15+
ws_id = env_or_skip('TEST_WORKSPACE_ID')
16+
ws = ucacct.workspaces.get(ws_id)
17+
w = ucacct.get_workspace_client(ws)
18+
me = w.current_user.me()
19+
assert me.user_name is not None

tests/test_config.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import os
2+
import pathlib
23
import platform
4+
import random
5+
import string
6+
from datetime import datetime
37

48
import pytest
59

610
from databricks.sdk import useragent
711
from databricks.sdk.config import Config, with_product, with_user_agent_extra
12+
from databricks.sdk.credentials_provider import Token
813
from databricks.sdk.version import __version__
914

1015
from .conftest import noop_credentials, set_az_path
@@ -79,6 +84,40 @@ def test_config_copy_deep_copies_user_agent_other_info(config):
7984
useragent._reset_extra(original_extra)
8085

8186

87+
def test_config_deep_copy(monkeypatch, mocker, tmp_path):
88+
mocker.patch('databricks.sdk.credentials_provider.CliTokenSource.refresh',
89+
return_value=Token(access_token='token',
90+
token_type='Bearer',
91+
expiry=datetime(2023, 5, 22, 0, 0, 0)))
92+
93+
write_large_dummy_executable(tmp_path)
94+
monkeypatch.setenv('PATH', tmp_path.as_posix())
95+
96+
config = Config(host="https://abc123.azuredatabricks.net", auth_type="databricks-cli")
97+
config_copy = config.deep_copy()
98+
assert config_copy.host == config.host
99+
100+
101+
def write_large_dummy_executable(path: pathlib.Path):
102+
cli = path.joinpath('databricks')
103+
104+
# Generate a long random string to inflate the file size.
105+
random_string = ''.join(random.choice(string.ascii_letters) for i in range(1024 * 1024))
106+
cli.write_text("""#!/bin/sh
107+
cat <<EOF
108+
{
109+
"access_token": "...",
110+
"token_type": "Bearer",
111+
"expiry": "2023-05-22T00:00:00.000000+00:00"
112+
}
113+
EOF
114+
exit 0
115+
""" + random_string)
116+
cli.chmod(0o755)
117+
assert cli.stat().st_size >= (1024 * 1024)
118+
return cli
119+
120+
82121
def test_load_azure_tenant_id_404(requests_mock, monkeypatch):
83122
set_az_path(monkeypatch)
84123
mock = requests_mock.get('https://abc123.azuredatabricks.net/aad/auth', status_code=404)

0 commit comments

Comments
 (0)