Skip to content

Commit 2ae8d66

Browse files
Merge branch 'main' into dependabot/pip/ipython-gte-8-and-lt-10
2 parents 10bfecc + ea3d2b5 commit 2ae8d66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+852
-352
lines changed

.codegen/_openapi_sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bdd8536d26484460f450b1d17722c01c5a6a50a9
1+
cd641c9dd4febe334b339dd7878d099dcf0eeab5

.release_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"timestamp": "2025-03-06 11:35:45+0000"
2+
"timestamp": "2025-03-11 15:30:51+0000"
33
}

CHANGELOG.md

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

3+
## Release v0.46.0
4+
5+
### New Features and Improvements
6+
* [Experimental] Add support for async token refresh ([#916](https://github.com/databricks/databricks-sdk-py/pull/916)).
7+
This can be enabled with by setting the following setting:
8+
```
9+
export DATABRICKS_ENABLE_EXPERIMENTAL_ASYNC_TOKEN_REFRESH=1.
10+
```
11+
This feature and its setting are experimental and may be removed in future releases.
12+
13+
### API Changes
14+
* Added [w.forecasting](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/ml/forecasting.html) workspace-level service.
15+
* Added `statement_id` field for `databricks.sdk.service.dashboards.GenieQueryAttachment`.
16+
* Added `could_not_get_model_deployments_exception` enum value for `databricks.sdk.service.dashboards.MessageErrorType`.
17+
* [Breaking] Removed `jwks_uri` field for `databricks.sdk.service.oauth2.OidcFederationPolicy`.
18+
19+
320
## Release v0.45.0
421

522
### New Features and Improvements

NEXT_CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NEXT CHANGELOG
22

3-
## Release v0.46.0
3+
## Release v0.47.0
44

55
### New Features and Improvements
66

databricks/sdk/__init__.py

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks/sdk/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class Config:
9595
max_connections_per_pool: int = ConfigAttribute()
9696
databricks_environment: Optional[DatabricksEnvironment] = None
9797

98+
enable_experimental_async_token_refresh: bool = ConfigAttribute(
99+
env="DATABRICKS_ENABLE_EXPERIMENTAL_ASYNC_TOKEN_REFRESH"
100+
)
101+
98102
enable_experimental_files_api_client: bool = ConfigAttribute(env="DATABRICKS_ENABLE_EXPERIMENTAL_FILES_API_CLIENT")
99103
files_api_client_download_max_total_recovers = None
100104
files_api_client_download_max_total_recovers_without_progressing = 1

databricks/sdk/credentials_provider.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def oauth_service_principal(cfg: "Config") -> Optional[CredentialsProvider]:
191191
token_url=oidc.token_endpoint,
192192
scopes=["all-apis"],
193193
use_header=True,
194+
disable_async=not cfg.enable_experimental_async_token_refresh,
194195
)
195196

196197
def inner() -> Dict[str, str]:
@@ -290,6 +291,7 @@ def token_source_for(resource: str) -> TokenSource:
290291
token_url=f"{aad_endpoint}{cfg.azure_tenant_id}/oauth2/token",
291292
endpoint_params={"resource": resource},
292293
use_params=True,
294+
disable_async=not cfg.enable_experimental_async_token_refresh,
293295
)
294296

295297
_ensure_host_present(cfg, token_source_for)
@@ -355,6 +357,7 @@ def github_oidc_azure(cfg: "Config") -> Optional[CredentialsProvider]:
355357
token_url=f"{aad_endpoint}{cfg.azure_tenant_id}/oauth2/token",
356358
endpoint_params=params,
357359
use_params=True,
360+
disable_async=not cfg.enable_experimental_async_token_refresh,
358361
)
359362

360363
def refreshed_headers() -> Dict[str, str]:
@@ -458,8 +461,9 @@ def __init__(
458461
token_type_field: str,
459462
access_token_field: str,
460463
expiry_field: str,
464+
disable_async: bool = True,
461465
):
462-
super().__init__()
466+
super().__init__(disable_async=disable_async)
463467
self._cmd = cmd
464468
self._token_type_field = token_type_field
465469
self._access_token_field = access_token_field
@@ -690,6 +694,7 @@ def __init__(self, cfg: "Config"):
690694
token_type_field="token_type",
691695
access_token_field="access_token",
692696
expiry_field="expiry",
697+
disable_async=not cfg.enable_experimental_async_token_refresh,
693698
)
694699

695700
@staticmethod

databricks/sdk/data_plane.py

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import threading
44
from dataclasses import dataclass
5-
from typing import Callable, List, Optional
5+
from typing import Callable, Optional
66
from urllib import parse
77

88
from databricks.sdk import oauth
@@ -88,61 +88,3 @@ class DataPlaneDetails:
8888
"""URL used to query the endpoint through the DataPlane."""
8989
token: Token
9090
"""Token to query the DataPlane endpoint."""
91-
92-
93-
## Old implementation. #TODO: Remove after the new implementation is used
94-
95-
96-
class DataPlaneService:
97-
"""Helper class to fetch and manage DataPlane details."""
98-
99-
from .service.serving import DataPlaneInfo
100-
101-
def __init__(self):
102-
self._data_plane_info = {}
103-
self._tokens = {}
104-
self._lock = threading.Lock()
105-
106-
def get_data_plane_details(
107-
self,
108-
method: str,
109-
params: List[str],
110-
info_getter: Callable[[], DataPlaneInfo],
111-
refresh: Callable[[str], Token],
112-
):
113-
"""Get and cache information required to query a Data Plane endpoint using the provided methods.
114-
115-
Returns a cached DataPlaneDetails if the details have already been fetched previously and are still valid.
116-
If not, it uses the provided functions to fetch the details.
117-
118-
:param method: method name. Used to construct a unique key for the cache.
119-
:param params: path params used in the "get" operation which uniquely determine the object. Used to construct a unique key for the cache.
120-
:param info_getter: function which returns the DataPlaneInfo. It will only be called if the information is not already present in the cache.
121-
:param refresh: function to refresh the token. It will only be called if the token is missing or expired.
122-
"""
123-
all_elements = params.copy()
124-
all_elements.insert(0, method)
125-
map_key = "/".join(all_elements)
126-
info = self._data_plane_info.get(map_key)
127-
if not info:
128-
self._lock.acquire()
129-
try:
130-
info = self._data_plane_info.get(map_key)
131-
if not info:
132-
info = info_getter()
133-
self._data_plane_info[map_key] = info
134-
finally:
135-
self._lock.release()
136-
137-
token = self._tokens.get(map_key)
138-
if not token or not token.valid:
139-
self._lock.acquire()
140-
token = self._tokens.get(map_key)
141-
try:
142-
if not token or not token.valid:
143-
token = refresh(info.authorization_details)
144-
self._tokens[map_key] = token
145-
finally:
146-
self._lock.release()
147-
148-
return DataPlaneDetails(endpoint_url=info.endpoint_url, token=token)

databricks/sdk/oauth.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,16 @@ def __init__(
426426
client_id: str,
427427
client_secret: str = None,
428428
redirect_url: str = None,
429+
disable_async: bool = True,
429430
):
430431
self._token_endpoint = token_endpoint
431432
self._client_id = client_id
432433
self._client_secret = client_secret
433434
self._redirect_url = redirect_url
434-
super().__init__(token)
435+
super().__init__(
436+
token=token,
437+
disable_async=disable_async,
438+
)
435439

436440
def as_dict(self) -> dict:
437441
return {"token": self.token().as_dict()}
@@ -708,9 +712,10 @@ class ClientCredentials(Refreshable):
708712
scopes: List[str] = None
709713
use_params: bool = False
710714
use_header: bool = False
715+
disable_async: bool = True
711716

712717
def __post_init__(self):
713-
super().__init__()
718+
super().__init__(disable_async=self.disable_async)
714719

715720
def refresh(self) -> Token:
716721
params = {"grant_type": "client_credentials"}

0 commit comments

Comments
 (0)