databricks-sdk 0.29.0__py3-none-any.whl → 0.30.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of databricks-sdk might be problematic. Click here for more details.
- databricks/sdk/__init__.py +67 -19
- databricks/sdk/config.py +61 -75
- databricks/sdk/core.py +16 -9
- databricks/sdk/credentials_provider.py +15 -15
- databricks/sdk/data_plane.py +65 -0
- databricks/sdk/mixins/files.py +12 -4
- databricks/sdk/service/apps.py +977 -0
- databricks/sdk/service/billing.py +602 -218
- databricks/sdk/service/catalog.py +131 -34
- databricks/sdk/service/compute.py +494 -81
- databricks/sdk/service/dashboards.py +608 -5
- databricks/sdk/service/iam.py +99 -88
- databricks/sdk/service/jobs.py +34 -15
- databricks/sdk/service/marketplace.py +2 -122
- databricks/sdk/service/oauth2.py +127 -70
- databricks/sdk/service/pipelines.py +72 -52
- databricks/sdk/service/serving.py +303 -750
- databricks/sdk/service/settings.py +423 -4
- databricks/sdk/service/sharing.py +235 -25
- databricks/sdk/service/sql.py +2417 -566
- databricks/sdk/useragent.py +144 -0
- databricks/sdk/version.py +1 -1
- {databricks_sdk-0.29.0.dist-info → databricks_sdk-0.30.0.dist-info}/METADATA +36 -16
- {databricks_sdk-0.29.0.dist-info → databricks_sdk-0.30.0.dist-info}/RECORD +28 -25
- {databricks_sdk-0.29.0.dist-info → databricks_sdk-0.30.0.dist-info}/WHEEL +1 -1
- {databricks_sdk-0.29.0.dist-info → databricks_sdk-0.30.0.dist-info}/LICENSE +0 -0
- {databricks_sdk-0.29.0.dist-info → databricks_sdk-0.30.0.dist-info}/NOTICE +0 -0
- {databricks_sdk-0.29.0.dist-info → databricks_sdk-0.30.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Callable, List
|
|
4
|
+
|
|
5
|
+
from databricks.sdk.oauth import Token
|
|
6
|
+
from databricks.sdk.service.oauth2 import DataPlaneInfo
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class DataPlaneDetails:
|
|
11
|
+
"""
|
|
12
|
+
Contains details required to query a DataPlane endpoint.
|
|
13
|
+
"""
|
|
14
|
+
endpoint_url: str
|
|
15
|
+
"""URL used to query the endpoint through the DataPlane."""
|
|
16
|
+
token: Token
|
|
17
|
+
"""Token to query the DataPlane endpoint."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class DataPlaneService:
|
|
21
|
+
"""Helper class to fetch and manage DataPlane details."""
|
|
22
|
+
|
|
23
|
+
def __init__(self):
|
|
24
|
+
self._data_plane_info = {}
|
|
25
|
+
self._tokens = {}
|
|
26
|
+
self._lock = threading.Lock()
|
|
27
|
+
|
|
28
|
+
def get_data_plane_details(self, method: str, params: List[str], info_getter: Callable[[], DataPlaneInfo],
|
|
29
|
+
refresh: Callable[[str], Token]):
|
|
30
|
+
"""Get and cache information required to query a Data Plane endpoint using the provided methods.
|
|
31
|
+
|
|
32
|
+
Returns a cached DataPlaneDetails if the details have already been fetched previously and are still valid.
|
|
33
|
+
If not, it uses the provided functions to fetch the details.
|
|
34
|
+
|
|
35
|
+
:param method: method name. Used to construct a unique key for the cache.
|
|
36
|
+
:param params: path params used in the "get" operation which uniquely determine the object. Used to construct a unique key for the cache.
|
|
37
|
+
:param info_getter: function which returns the DataPlaneInfo. It will only be called if the information is not already present in the cache.
|
|
38
|
+
:param refresh: function to refresh the token. It will only be called if the token is missing or expired.
|
|
39
|
+
"""
|
|
40
|
+
all_elements = params.copy()
|
|
41
|
+
all_elements.insert(0, method)
|
|
42
|
+
map_key = "/".join(all_elements)
|
|
43
|
+
info = self._data_plane_info.get(map_key)
|
|
44
|
+
if not info:
|
|
45
|
+
self._lock.acquire()
|
|
46
|
+
try:
|
|
47
|
+
info = self._data_plane_info.get(map_key)
|
|
48
|
+
if not info:
|
|
49
|
+
info = info_getter()
|
|
50
|
+
self._data_plane_info[map_key] = info
|
|
51
|
+
finally:
|
|
52
|
+
self._lock.release()
|
|
53
|
+
|
|
54
|
+
token = self._tokens.get(map_key)
|
|
55
|
+
if not token or not token.valid:
|
|
56
|
+
self._lock.acquire()
|
|
57
|
+
token = self._tokens.get(map_key)
|
|
58
|
+
try:
|
|
59
|
+
if not token or not token.valid:
|
|
60
|
+
token = refresh(info.authorization_details)
|
|
61
|
+
self._tokens[map_key] = token
|
|
62
|
+
finally:
|
|
63
|
+
self._lock.release()
|
|
64
|
+
|
|
65
|
+
return DataPlaneDetails(endpoint_url=info.endpoint_url, token=token)
|
databricks/sdk/mixins/files.py
CHANGED
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import base64
|
|
4
4
|
import os
|
|
5
5
|
import pathlib
|
|
6
|
+
import platform
|
|
6
7
|
import shutil
|
|
7
8
|
import sys
|
|
8
9
|
from abc import ABC, abstractmethod
|
|
@@ -266,8 +267,9 @@ class _VolumesIO(BinaryIO):
|
|
|
266
267
|
|
|
267
268
|
class _Path(ABC):
|
|
268
269
|
|
|
269
|
-
|
|
270
|
-
|
|
270
|
+
@abstractmethod
|
|
271
|
+
def __init__(self):
|
|
272
|
+
...
|
|
271
273
|
|
|
272
274
|
@property
|
|
273
275
|
def is_local(self) -> bool:
|
|
@@ -327,6 +329,12 @@ class _Path(ABC):
|
|
|
327
329
|
|
|
328
330
|
class _LocalPath(_Path):
|
|
329
331
|
|
|
332
|
+
def __init__(self, path: str):
|
|
333
|
+
if platform.system() == "Windows":
|
|
334
|
+
self._path = pathlib.Path(str(path).replace('file:///', '').replace('file:', ''))
|
|
335
|
+
else:
|
|
336
|
+
self._path = pathlib.Path(str(path).replace('file:', ''))
|
|
337
|
+
|
|
330
338
|
def _is_local(self) -> bool:
|
|
331
339
|
return True
|
|
332
340
|
|
|
@@ -393,7 +401,7 @@ class _LocalPath(_Path):
|
|
|
393
401
|
class _VolumesPath(_Path):
|
|
394
402
|
|
|
395
403
|
def __init__(self, api: files.FilesAPI, src: Union[str, pathlib.Path]):
|
|
396
|
-
|
|
404
|
+
self._path = pathlib.PurePosixPath(str(src).replace('dbfs:', '').replace('file:', ''))
|
|
397
405
|
self._api = api
|
|
398
406
|
|
|
399
407
|
def _is_local(self) -> bool:
|
|
@@ -462,7 +470,7 @@ class _VolumesPath(_Path):
|
|
|
462
470
|
class _DbfsPath(_Path):
|
|
463
471
|
|
|
464
472
|
def __init__(self, api: files.DbfsAPI, src: str):
|
|
465
|
-
|
|
473
|
+
self._path = pathlib.PurePosixPath(str(src).replace('dbfs:', '').replace('file:', ''))
|
|
466
474
|
self._api = api
|
|
467
475
|
|
|
468
476
|
def _is_local(self) -> bool:
|