foundry-dev-tools 2.1.15__tar.gz → 2.1.17__tar.gz
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.
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/PKG-INFO +1 -1
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/pyproject.toml +1 -1
- foundry_dev_tools-2.1.17/src/foundry_dev_tools/__about__.py +1 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/api_client.py +7 -5
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/context_client.py +11 -18
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/multipass.py +13 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/s3_client.py +2 -1
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/config.py +8 -3
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/context.py +18 -2
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/token_provider.py +40 -20
- foundry_dev_tools-2.1.17/src/foundry_dev_tools/errors/multipass.py +23 -0
- foundry_dev_tools-2.1.15/src/foundry_dev_tools/__about__.py +0 -1
- foundry_dev_tools-2.1.15/src/foundry_dev_tools/errors/multipass.py +0 -9
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/README.md +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/pandas.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/polars.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/pyarrow.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/pyspark.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cached_foundry_client.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/build.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/config.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/git.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/git_credential_foundry.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/info.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/main.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/s3.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cli/stubs.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/build2.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/catalog.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/compass.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/data_proxy.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/foundry_sql_server.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/foundry_stats.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/jemma.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/magritte_coordinator.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/metadata.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/public_ontologies_client.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/scheduler.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/schema_inference.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/tables.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/config_types.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/compass.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/config.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/dataset.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/handling.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/meta.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/sql.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/foundry_api_client.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/helpers/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/helpers/multipass/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/helpers/multipass/group.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/helpers/multipass/principal.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/helpers/multipass/user.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/py.typed +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/dataset.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/folder.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/resource.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/api_types.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/async_s3.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/caches/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/caches/metadata_store.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/caches/spark_caches.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/cli.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/clients.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/compat.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/config.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/converter/__init__.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/converter/foundry_spark.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/misc.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/public_api_types.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/repo.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/s3.py +0 -0
- {foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/spark.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: foundry-dev-tools
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.17
|
|
4
4
|
Summary: Seamlessly run your Palantir Foundry Repository transforms code on your local machine.
|
|
5
5
|
Author-Email: Nicolas Renkamp <nicolas.renkamp@merckgroup.com>, Jonas Wunderlich <jonas.wunderlich@merckgroup.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.1.17'
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/api_client.py
RENAMED
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import TYPE_CHECKING, ClassVar, Literal
|
|
6
6
|
|
|
7
|
+
from foundry_dev_tools.errors.handling import ErrorHandlingConfig, raise_foundry_api_error
|
|
7
8
|
from foundry_dev_tools.utils.clients import build_api_url, build_public_api_url
|
|
8
9
|
|
|
9
10
|
if TYPE_CHECKING:
|
|
@@ -23,7 +24,6 @@ if TYPE_CHECKING:
|
|
|
23
24
|
)
|
|
24
25
|
|
|
25
26
|
from foundry_dev_tools.config.context import FoundryContext
|
|
26
|
-
from foundry_dev_tools.errors.handling import ErrorHandlingConfig
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class APIClient:
|
|
@@ -93,7 +93,7 @@ class APIClient:
|
|
|
93
93
|
else:
|
|
94
94
|
headers = {"content-type": "application/json"}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
response = self.context.client.request(
|
|
97
97
|
method=method,
|
|
98
98
|
url=self.api_url(api_path),
|
|
99
99
|
params=params,
|
|
@@ -110,8 +110,9 @@ class APIClient:
|
|
|
110
110
|
verify=verify,
|
|
111
111
|
cert=cert,
|
|
112
112
|
json=json,
|
|
113
|
-
error_handling=error_handling,
|
|
114
113
|
)
|
|
114
|
+
raise_foundry_api_error(response, error_handling)
|
|
115
|
+
return response
|
|
115
116
|
|
|
116
117
|
|
|
117
118
|
class PublicAPIClient:
|
|
@@ -196,7 +197,7 @@ class PublicAPIClient:
|
|
|
196
197
|
params["preview"] = "true"
|
|
197
198
|
else:
|
|
198
199
|
params = {"preview": "true"}
|
|
199
|
-
|
|
200
|
+
response = self.context.client.request(
|
|
200
201
|
method=method,
|
|
201
202
|
url=self.api_url(api_path, version=api_version),
|
|
202
203
|
params=params,
|
|
@@ -213,5 +214,6 @@ class PublicAPIClient:
|
|
|
213
214
|
verify=verify,
|
|
214
215
|
cert=cert,
|
|
215
216
|
json=json,
|
|
216
|
-
error_handling=error_handling,
|
|
217
217
|
)
|
|
218
|
+
raise_foundry_api_error(response, error_handling)
|
|
219
|
+
return response
|
|
@@ -7,14 +7,14 @@ import numbers
|
|
|
7
7
|
import os
|
|
8
8
|
import time
|
|
9
9
|
import typing
|
|
10
|
-
from
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import TYPE_CHECKING
|
|
11
12
|
|
|
12
13
|
import requests
|
|
13
14
|
|
|
14
|
-
from foundry_dev_tools.__about__ import __version__
|
|
15
|
-
from foundry_dev_tools.errors.handling import ErrorHandlingConfig, raise_foundry_api_error
|
|
16
|
-
|
|
17
15
|
if TYPE_CHECKING:
|
|
16
|
+
from os import PathLike
|
|
17
|
+
|
|
18
18
|
from requests import Response
|
|
19
19
|
from requests.cookies import RequestsCookieJar
|
|
20
20
|
from requests.sessions import ( # type: ignore[attr-defined]
|
|
@@ -31,7 +31,6 @@ if TYPE_CHECKING:
|
|
|
31
31
|
_Verify,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
|
-
from foundry_dev_tools.config.context import FoundryContext
|
|
35
34
|
|
|
36
35
|
DEFAULT_TIMEOUT = (60, None)
|
|
37
36
|
LOGGER = logging.getLogger(__name__)
|
|
@@ -73,14 +72,13 @@ def retry(times: int, exceptions: tuple[Exception]) -> typing.Callable:
|
|
|
73
72
|
class ContextHTTPClient(requests.Session):
|
|
74
73
|
"""Requests Session with config and authentication applied."""
|
|
75
74
|
|
|
76
|
-
def __init__(self,
|
|
77
|
-
self.
|
|
75
|
+
def __init__(self, debug: bool = False, requests_ca_bundle: PathLike[str] | None = None) -> None:
|
|
76
|
+
self.debug = debug
|
|
78
77
|
super().__init__()
|
|
79
|
-
if
|
|
80
|
-
self.verify = os.fspath(
|
|
81
|
-
|
|
78
|
+
if requests_ca_bundle is not None and Path(requests_ca_bundle).is_file():
|
|
79
|
+
self.verify = os.fspath(requests_ca_bundle)
|
|
80
|
+
|
|
82
81
|
self._counter = 0
|
|
83
|
-
self.headers = {"User-Agent": f"foundry-dev-tools/{__version__}/python-requests"}
|
|
84
82
|
|
|
85
83
|
@retry(times=3, exceptions=requests.exceptions.ConnectionError)
|
|
86
84
|
def request(
|
|
@@ -101,7 +99,6 @@ class ContextHTTPClient(requests.Session):
|
|
|
101
99
|
verify: _Verify | None = None,
|
|
102
100
|
cert: _Cert | None = None,
|
|
103
101
|
json: Incomplete | None = None,
|
|
104
|
-
error_handling: ErrorHandlingConfig | Literal[False] | None = None,
|
|
105
102
|
) -> Response:
|
|
106
103
|
"""Make an authenticated HTTP request.
|
|
107
104
|
|
|
@@ -122,11 +119,8 @@ class ContextHTTPClient(requests.Session):
|
|
|
122
119
|
verify: see :py:meth:`requests.Session.request`
|
|
123
120
|
cert: see :py:meth:`requests.Session.request`
|
|
124
121
|
json: see :py:meth:`requests.Session.request`
|
|
125
|
-
error_handling: error handling config; if set to False, errors won't be automatically handled
|
|
126
122
|
"""
|
|
127
|
-
if
|
|
128
|
-
verify = rcab
|
|
129
|
-
if self.context.config.debug:
|
|
123
|
+
if self.debug:
|
|
130
124
|
self._counter = count = self._counter + 1
|
|
131
125
|
LOGGER.debug(f"(r{count}) Making {method!s} request to {url!s}") # noqa: G004
|
|
132
126
|
|
|
@@ -155,12 +149,11 @@ class ContextHTTPClient(requests.Session):
|
|
|
155
149
|
cert=cert,
|
|
156
150
|
json=json,
|
|
157
151
|
)
|
|
158
|
-
if self.
|
|
152
|
+
if self.debug:
|
|
159
153
|
LOGGER.debug(
|
|
160
154
|
f"(r{count}) Got response status={response.status_code}, " # noqa: G004
|
|
161
155
|
f"content_type={response.headers.get('content-type')}, "
|
|
162
156
|
f"content_length={response.headers.get('content-length')}, "
|
|
163
157
|
f"Server-Timing={response.headers.get('Server-Timing')}",
|
|
164
158
|
)
|
|
165
|
-
raise_foundry_api_error(response, error_handling)
|
|
166
159
|
return response
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/multipass.py
RENAMED
|
@@ -359,6 +359,19 @@ class MultipassClient(APIClient):
|
|
|
359
359
|
**kwargs,
|
|
360
360
|
)
|
|
361
361
|
|
|
362
|
+
def api_delete_user(self, user_id: api_types.UserId, **kwargs) -> requests.Response:
|
|
363
|
+
"""Deletes multipass user.
|
|
364
|
+
|
|
365
|
+
Args:
|
|
366
|
+
user_id: the identifier of the group which to delete
|
|
367
|
+
**kwargs: gets passed to :py:meth:`APIClient.api_request`
|
|
368
|
+
"""
|
|
369
|
+
return self.api_request(
|
|
370
|
+
"DELETE",
|
|
371
|
+
f"administration/users/{user_id}",
|
|
372
|
+
**kwargs,
|
|
373
|
+
)
|
|
374
|
+
|
|
362
375
|
def api_get_group_manager_managers(
|
|
363
376
|
self,
|
|
364
377
|
group_id: api_types.GroupId,
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/s3_client.py
RENAMED
|
@@ -177,7 +177,8 @@ class S3Client:
|
|
|
177
177
|
expiration_duration: seconds the credentials should be valid, defaults to 3600 (the upper bound)
|
|
178
178
|
"""
|
|
179
179
|
# does not call the api_request method, as this is not a regular api
|
|
180
|
-
resp = self.context.client.
|
|
180
|
+
resp = self.context.client.request(
|
|
181
|
+
"POST",
|
|
181
182
|
self.get_url(),
|
|
182
183
|
params={
|
|
183
184
|
"Action": "AssumeRoleWithWebIdentity",
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/config.py
RENAMED
|
@@ -32,6 +32,8 @@ if TYPE_CHECKING:
|
|
|
32
32
|
from collections.abc import Iterable
|
|
33
33
|
from os import PathLike
|
|
34
34
|
|
|
35
|
+
import requests
|
|
36
|
+
|
|
35
37
|
# compatibility for python version < 3.11
|
|
36
38
|
if sys.version_info < (3, 11):
|
|
37
39
|
import tomli as tomllib
|
|
@@ -44,16 +46,17 @@ class Config:
|
|
|
44
46
|
|
|
45
47
|
def __init__(
|
|
46
48
|
self,
|
|
47
|
-
requests_ca_bundle: PathLike[str] | None = None,
|
|
49
|
+
requests_ca_bundle: PathLike[str] | str | None = None,
|
|
48
50
|
transforms_sql_sample_row_limit: int = 5000,
|
|
49
51
|
transforms_sql_dataset_size_threshold: int = 500,
|
|
50
52
|
transforms_sql_sample_select_random: bool = False,
|
|
51
53
|
transforms_force_full_dataset_download: bool = False,
|
|
52
|
-
cache_dir: PathLike[str] | None = None,
|
|
54
|
+
cache_dir: PathLike[str] | str | None = None,
|
|
53
55
|
transforms_freeze_cache: bool = False,
|
|
54
|
-
transforms_output_folder: PathLike[str] | None = None,
|
|
56
|
+
transforms_output_folder: PathLike[str] | str | None = None,
|
|
55
57
|
rich_traceback: bool = False,
|
|
56
58
|
debug: bool = False,
|
|
59
|
+
requests_session: requests.Session | None = None,
|
|
57
60
|
) -> None:
|
|
58
61
|
"""Initialize the configuration.
|
|
59
62
|
|
|
@@ -76,6 +79,7 @@ class Config:
|
|
|
76
79
|
files are written to this folder.
|
|
77
80
|
rich_traceback: enables a prettier traceback provided by the module `rich` See: https://rich.readthedocs.io/en/stable/traceback.html
|
|
78
81
|
debug: enables debug logging
|
|
82
|
+
requests_session (requests.Session): Overwrite the default used requests.Session.
|
|
79
83
|
|
|
80
84
|
"""
|
|
81
85
|
self.requests_ca_bundle = os.fspath(requests_ca_bundle) if requests_ca_bundle else None
|
|
@@ -90,6 +94,7 @@ class Config:
|
|
|
90
94
|
self.transforms_freeze_cache = bool(transforms_freeze_cache)
|
|
91
95
|
self.rich_traceback = bool(rich_traceback)
|
|
92
96
|
self.debug = bool(debug)
|
|
97
|
+
self.requests_session = requests_session
|
|
93
98
|
|
|
94
99
|
def __repr__(self) -> str:
|
|
95
100
|
return "<" + self.__class__.__name__ + "(" + self.__dict__.__str__() + ")>"
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/context.py
RENAMED
|
@@ -5,6 +5,9 @@ from __future__ import annotations
|
|
|
5
5
|
from functools import cached_property, partial
|
|
6
6
|
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
from foundry_dev_tools.__about__ import __version__
|
|
8
11
|
from foundry_dev_tools.clients import (
|
|
9
12
|
build2,
|
|
10
13
|
catalog,
|
|
@@ -42,7 +45,7 @@ class FoundryContext:
|
|
|
42
45
|
|
|
43
46
|
config: Config
|
|
44
47
|
token_provider: TokenProvider
|
|
45
|
-
client:
|
|
48
|
+
client: requests.Session
|
|
46
49
|
|
|
47
50
|
def __init__(
|
|
48
51
|
self,
|
|
@@ -57,7 +60,20 @@ class FoundryContext:
|
|
|
57
60
|
else:
|
|
58
61
|
self.token_provider = token_provider
|
|
59
62
|
self.config = config
|
|
60
|
-
|
|
63
|
+
|
|
64
|
+
if not self.config.requests_session:
|
|
65
|
+
self.client = context_client.ContextHTTPClient(
|
|
66
|
+
debug=self.config.debug, requests_ca_bundle=self.config.requests_ca_bundle
|
|
67
|
+
)
|
|
68
|
+
else:
|
|
69
|
+
self.client = self.config.requests_session
|
|
70
|
+
|
|
71
|
+
self.token_provider.set_requests_session(self.client)
|
|
72
|
+
self.client.auth = lambda r: self.token_provider.requests_auth_handler(r)
|
|
73
|
+
self.client.headers["User-Agent"] = requests.utils.default_user_agent(
|
|
74
|
+
f"foundry-dev-tools/{__version__}/python-requests"
|
|
75
|
+
)
|
|
76
|
+
|
|
61
77
|
if self.config.rich_traceback:
|
|
62
78
|
from rich.traceback import install
|
|
63
79
|
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/token_provider.py
RENAMED
|
@@ -13,7 +13,8 @@ from requests.structures import CaseInsensitiveDict
|
|
|
13
13
|
|
|
14
14
|
from foundry_dev_tools.config.config_types import Host
|
|
15
15
|
from foundry_dev_tools.errors.config import TokenProviderConfigError
|
|
16
|
-
from foundry_dev_tools.errors.
|
|
16
|
+
from foundry_dev_tools.errors.handling import ErrorHandlingConfig, raise_foundry_api_error
|
|
17
|
+
from foundry_dev_tools.errors.multipass import ClientAuthenticationFailedError
|
|
17
18
|
from foundry_dev_tools.utils.config import entry_point_fdt_token_provider
|
|
18
19
|
|
|
19
20
|
if TYPE_CHECKING:
|
|
@@ -52,6 +53,9 @@ class TokenProvider:
|
|
|
52
53
|
r.headers.setdefault("authorization", f"Bearer {self.token}")
|
|
53
54
|
return r
|
|
54
55
|
|
|
56
|
+
def set_requests_session(self, session: requests.Session) -> None:
|
|
57
|
+
"""No-op by default."""
|
|
58
|
+
|
|
55
59
|
|
|
56
60
|
class JWTTokenProvider(TokenProvider):
|
|
57
61
|
"""Provides Host and Token."""
|
|
@@ -150,6 +154,7 @@ class OAuthTokenProvider(CachedTokenProvider):
|
|
|
150
154
|
self.scopes = DEFAULT_OAUTH_SCOPES
|
|
151
155
|
else:
|
|
152
156
|
self.scopes = scopes
|
|
157
|
+
self._requests_session = requests.Session()
|
|
153
158
|
|
|
154
159
|
def _scopes_to_list(self, scopes: list[str] | str | None) -> list[str] | None:
|
|
155
160
|
if scopes is not None and isinstance(scopes, str):
|
|
@@ -168,27 +173,38 @@ class OAuthTokenProvider(CachedTokenProvider):
|
|
|
168
173
|
)
|
|
169
174
|
return credentials.token, credentials.expiry.timestamp()
|
|
170
175
|
if self.grant_type == "client_credentials" and self._client_secret is not None:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
176
|
+
# since we share the same requests session everywhere and on this session
|
|
177
|
+
# the auth is set to a lambda function we need to manually disable this
|
|
178
|
+
# for the single token call
|
|
179
|
+
auth_handler = self._requests_session.auth
|
|
180
|
+
self._requests_session.auth = None
|
|
181
|
+
try:
|
|
182
|
+
resp = self._requests_session.request(
|
|
183
|
+
"POST",
|
|
184
|
+
f"{self.host.url}/multipass/api/oauth2/token",
|
|
185
|
+
data={"grant_type": "client_credentials", "scope": " ".join(self.scopes)}
|
|
186
|
+
if self.scopes
|
|
187
|
+
else {"grant_type": "client_credentials"},
|
|
188
|
+
headers={
|
|
189
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
190
|
+
"Authorization": "Basic "
|
|
191
|
+
+ base64.b64encode(
|
|
192
|
+
bytes(
|
|
193
|
+
self._client_id + ":" + self._client_secret,
|
|
194
|
+
"ISO-8859-1",
|
|
195
|
+
),
|
|
196
|
+
).decode("ascii"),
|
|
197
|
+
},
|
|
198
|
+
timeout=30,
|
|
199
|
+
)
|
|
200
|
+
finally:
|
|
201
|
+
# add original auth handler again
|
|
202
|
+
self._requests_session.auth = auth_handler
|
|
203
|
+
raise_foundry_api_error(
|
|
204
|
+
resp,
|
|
205
|
+
error_handling=ErrorHandlingConfig({401: ClientAuthenticationFailedError}, client_id=self._client_id),
|
|
188
206
|
)
|
|
189
207
|
credentials = resp.json()
|
|
190
|
-
if "error" in credentials:
|
|
191
|
-
raise FoundryAPIError(resp)
|
|
192
208
|
return credentials["access_token"], credentials["expires_in"] + time.time()
|
|
193
209
|
if self._client_secret is None:
|
|
194
210
|
msg = f"For grant type {self.grant_type} you need to set a client_secret."
|
|
@@ -197,6 +213,10 @@ class OAuthTokenProvider(CachedTokenProvider):
|
|
|
197
213
|
msg = f"Grant type {self.grant_type} is not implemented."
|
|
198
214
|
raise NotImplementedError(msg)
|
|
199
215
|
|
|
216
|
+
def set_requests_session(self, session: requests.Session) -> None:
|
|
217
|
+
"""Sets request session used for client credentials grant.."""
|
|
218
|
+
self._requests_session = session
|
|
219
|
+
|
|
200
220
|
|
|
201
221
|
class AppServiceTokenProvider(CachedTokenProvider):
|
|
202
222
|
"""Token Provider for the AppService, which gets the token via a header from flask/dash/streamlit."""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Multipass specific errors."""
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
from foundry_dev_tools.errors.meta import FoundryAPIError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DuplicateGroupNameError(FoundryAPIError):
|
|
9
|
+
"""Exception is thrown when the group name already exists."""
|
|
10
|
+
|
|
11
|
+
message = "The group name already exists!"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ClientAuthenticationFailedError(FoundryAPIError):
|
|
15
|
+
"""Exception is thrown when client credentials grant failed."""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self, response: requests.Response | None = None, info: str | None = None, client_id: str | None = None
|
|
19
|
+
):
|
|
20
|
+
self.client_id = client_id
|
|
21
|
+
self.message = "Client authentication failed (invalid_client)."
|
|
22
|
+
|
|
23
|
+
super().__init__(response=response, info=info, client_id=client_id)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.1.15'
|
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/__init__.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/pandas.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/polars.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/pyarrow.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/_optional/pyspark.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/cached_foundry_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/__init__.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/build2.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/catalog.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/compass.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/data_proxy.py
RENAMED
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/foundry_stats.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/jemma.py
RENAMED
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/metadata.py
RENAMED
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/scheduler.py
RENAMED
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/clients/tables.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/__init__.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/config/config_types.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/__init__.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/compass.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/config.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/dataset.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/errors/handling.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/foundry_api_client.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/helpers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/__init__.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/dataset.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/folder.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/resources/resource.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/__init__.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/api_types.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/async_s3.py
RENAMED
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/caches/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{foundry_dev_tools-2.1.15 → foundry_dev_tools-2.1.17}/src/foundry_dev_tools/utils/clients.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|