atlan-application-sdk-api 3.54.0__tar.gz → 3.55.1__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.
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/PKG-INFO +7 -3
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_runtime/offload.py +218 -16
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/sql.py +178 -8
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/ssl_utils.py +1 -7
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/errors.py +1 -2
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/constants.py +24 -4
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/__init__.py +3 -1
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/leaves.py +32 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/object_routes.py +1 -2
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/request_contract.py +1 -3
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/version.py +3 -4
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/pyproject.toml +10 -5
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/.gitignore +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/README.md +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/api-files.txt +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_build_info.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_context_errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_install.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_logging.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_runtime/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_runtime/cgroup.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_runtime/progress.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/_interface.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/_sql_failure_classifier.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/base.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/http_errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/models.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/sql_errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/sql_typecasters.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/_generated_tree.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/_listing.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/aws_utils.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/aws_utils_errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/backoff.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/build_identity.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/concurrency.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/filter_matching.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/logger.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/models.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/sql_filters.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/sql_filters_errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/task_queue.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/types.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/common/utils.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/contracts/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/contracts/base.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/contracts/events.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/contracts/types.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/contracts/types_errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/extra.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/ingress.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/ref.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/requirements.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/spec.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/types.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/credentials/utils.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/base.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/categories.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/http.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/wire.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/_dispatch.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/_warmup.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/asgi.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/base.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/context.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/contracts.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/manifest.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/metadata_routes.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/routes.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/handler/service_errors.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/server/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/server/fastapi/models.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/templates/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/templates/contracts/__init__.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/templates/contracts/base_metadata_extraction.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/templates/contracts/incremental_sql.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/templates/contracts/sql_metadata.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/templates/contracts/sql_query.py +0 -0
- {atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/hatch_build.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: atlan-application-sdk-api
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.55.1
|
|
4
4
|
Summary: Experimental: the handler surface of the Atlan Application SDK, for the consolidated API host
|
|
5
5
|
Project-URL: Homepage, https://github.com/atlanhq/application-sdk
|
|
6
6
|
Project-URL: Source, https://github.com/atlanhq/application-sdk/tree/main/packages/api
|
|
@@ -14,6 +14,9 @@ Classifier: Intended Audience :: Developers
|
|
|
14
14
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
20
|
Requires-Python: >=3.11
|
|
18
21
|
Requires-Dist: certifi>=2026.10.19
|
|
19
22
|
Requires-Dist: fastapi<0.163.0,>=0.162.0
|
|
@@ -21,14 +24,15 @@ Requires-Dist: httpx<0.29.0,>=0.27.0
|
|
|
21
24
|
Requires-Dist: orjson<4.0.0,>=3.11.6
|
|
22
25
|
Requires-Dist: pydantic<3.0.0,>=2.10.6
|
|
23
26
|
Requires-Dist: python-multipart>=0.0.26
|
|
27
|
+
Requires-Dist: typing-extensions<5,>=4.12.2
|
|
24
28
|
Provides-Extra: aws
|
|
25
29
|
Requires-Dist: boto3<2.0.0,>=1.38.6; extra == 'aws'
|
|
26
30
|
Requires-Dist: httpx<0.29.0,>=0.27.0; extra == 'aws'
|
|
27
31
|
Requires-Dist: python-dotenv<2.0.0,>=1.2.2; extra == 'aws'
|
|
28
32
|
Provides-Extra: pandas
|
|
29
|
-
Requires-Dist: pandas<
|
|
33
|
+
Requires-Dist: pandas<4.0.0,>=2.2.3; extra == 'pandas'
|
|
30
34
|
Provides-Extra: pyatlan
|
|
31
|
-
Requires-Dist: authlib<2,>=1.9.
|
|
35
|
+
Requires-Dist: authlib<2,>=1.9.4; extra == 'pyatlan'
|
|
32
36
|
Requires-Dist: pyatlan<12,>=11.7.0; extra == 'pyatlan'
|
|
33
37
|
Provides-Extra: sql
|
|
34
38
|
Requires-Dist: httpx<0.29.0,>=0.27.0; extra == 'sql'
|
|
@@ -191,6 +191,35 @@ class CancelHandle:
|
|
|
191
191
|
return
|
|
192
192
|
_fire_cancel_action(action)
|
|
193
193
|
|
|
194
|
+
@contextlib.contextmanager
|
|
195
|
+
def registered(self, action: Callable[[], None]) -> Iterator[None]:
|
|
196
|
+
"""Register *action* for the block, then put the previous action back.
|
|
197
|
+
|
|
198
|
+
For nested scopes inside one call — a helper opening its own connection
|
|
199
|
+
while the caller's is mid-query. A plain :meth:`set` would leave the
|
|
200
|
+
handle pointing at the inner connection after it closed, and the outer
|
|
201
|
+
query could no longer be cancelled. If a cancel lands inside the block,
|
|
202
|
+
the inner action fires then and the outer one fires on the way out.
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
action: Zero-argument callable that tells the driver to stop.
|
|
206
|
+
|
|
207
|
+
Yields:
|
|
208
|
+
Nothing; the scoped work runs inside the block.
|
|
209
|
+
"""
|
|
210
|
+
with self._lock:
|
|
211
|
+
previous = self._action
|
|
212
|
+
self.set(action)
|
|
213
|
+
try:
|
|
214
|
+
yield
|
|
215
|
+
finally:
|
|
216
|
+
with self._lock:
|
|
217
|
+
fire_previous = self._requested and previous is not None
|
|
218
|
+
if not self._requested and self._action is action:
|
|
219
|
+
self._action = previous
|
|
220
|
+
if fire_previous:
|
|
221
|
+
_fire_cancel_action(previous) # type: ignore[arg-type]
|
|
222
|
+
|
|
194
223
|
def request(self) -> None:
|
|
195
224
|
"""Request a cancel: fire the registered action, if any, at most once.
|
|
196
225
|
|
|
@@ -247,6 +276,107 @@ def _run_cancel_action(action: Callable[[], None]) -> None:
|
|
|
247
276
|
)
|
|
248
277
|
|
|
249
278
|
|
|
279
|
+
#: The :class:`CancelHandle` of the ``run_in_thread`` call whose thread is
|
|
280
|
+
#: running. Set only inside the copied context the thread runs in, so the event
|
|
281
|
+
#: loop, other tasks and other offloaded calls never see it: a cancel is scoped
|
|
282
|
+
#: to the one call whose caller stopped waiting.
|
|
283
|
+
_CURRENT_CANCEL_HANDLE: contextvars.ContextVar[CancelHandle | None] = (
|
|
284
|
+
contextvars.ContextVar("_CURRENT_CANCEL_HANDLE", default=None)
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def current_cancel_handle() -> CancelHandle | None:
|
|
289
|
+
"""The :class:`CancelHandle` of the ``run_in_thread`` call running on this thread.
|
|
290
|
+
|
|
291
|
+
Every ``run_in_thread`` call has one — the handle bound with
|
|
292
|
+
:meth:`CancelHandle.bind`, or a fresh one — so code deep inside the
|
|
293
|
+
offloaded call can register a driver cancel without the handle being
|
|
294
|
+
passed down to it::
|
|
295
|
+
|
|
296
|
+
def _query() -> list[Row]:
|
|
297
|
+
cursor = connection.cursor()
|
|
298
|
+
handle = current_cancel_handle()
|
|
299
|
+
if handle is not None:
|
|
300
|
+
handle.set(cursor.cancel)
|
|
301
|
+
cursor.execute(sql)
|
|
302
|
+
return cursor.fetchall()
|
|
303
|
+
|
|
304
|
+
rows = await run_in_thread(_query)
|
|
305
|
+
|
|
306
|
+
Returns:
|
|
307
|
+
The handle, or ``None`` outside a ``run_in_thread`` call (on the event
|
|
308
|
+
loop, or in a thread the SDK did not start).
|
|
309
|
+
"""
|
|
310
|
+
return _CURRENT_CANCEL_HANDLE.get()
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def is_cancelled() -> bool:
|
|
314
|
+
"""Whether the work running here has been asked to stop.
|
|
315
|
+
|
|
316
|
+
True when either:
|
|
317
|
+
|
|
318
|
+
- the ``run_in_thread`` call this thread is running was abandoned — its
|
|
319
|
+
awaiting task was cancelled, by Temporal or locally (``asyncio.timeout``,
|
|
320
|
+
a ``TaskGroup`` sibling failing). Scoped to that one call: a caller that
|
|
321
|
+
catches its own timeout and carries on does not see it, nor does any
|
|
322
|
+
other offloaded call; or
|
|
323
|
+
- the current Temporal activity has been asked to cancel.
|
|
324
|
+
|
|
325
|
+
A cancel does not stop an offloaded thread — Python cannot kill one — so a
|
|
326
|
+
long loop inside ``run_in_thread`` should check this every few seconds and
|
|
327
|
+
return. Safe to call anywhere: outside an activity and outside an offload it
|
|
328
|
+
returns ``False``.
|
|
329
|
+
"""
|
|
330
|
+
handle = _CURRENT_CANCEL_HANDLE.get()
|
|
331
|
+
if handle is not None and handle.requested:
|
|
332
|
+
return True
|
|
333
|
+
try:
|
|
334
|
+
from temporalio import ( # noqa: PLC0415 — the api distribution ships this file without temporalio
|
|
335
|
+
activity as _activity,
|
|
336
|
+
)
|
|
337
|
+
except ImportError:
|
|
338
|
+
return False
|
|
339
|
+
return _activity.in_activity() and _activity.is_cancelled()
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def raise_if_cancelled() -> None:
|
|
343
|
+
"""Raise ``CancelledError`` if :func:`is_cancelled` is true; else return.
|
|
344
|
+
|
|
345
|
+
For the step boundary of a long loop inside ``run_in_thread``: the thread
|
|
346
|
+
unwinds through its ``with`` blocks and ``finally`` clauses, so files and
|
|
347
|
+
connections close, instead of running on after its caller has gone.
|
|
348
|
+
|
|
349
|
+
Raises ``asyncio.CancelledError``, a ``BaseException``, so the
|
|
350
|
+
``except Exception`` a per-record loop uses to skip bad records does not
|
|
351
|
+
swallow it and keep the loop going.
|
|
352
|
+
|
|
353
|
+
Raises:
|
|
354
|
+
asyncio.CancelledError: The work was asked to stop.
|
|
355
|
+
"""
|
|
356
|
+
if is_cancelled():
|
|
357
|
+
raise asyncio.CancelledError
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def raise_if_offload_abandoned() -> None:
|
|
361
|
+
"""Raise ``CancelledError`` if this ``run_in_thread`` call was abandoned.
|
|
362
|
+
|
|
363
|
+
The SDK's own check. Unlike :func:`raise_if_cancelled` it ignores the
|
|
364
|
+
Temporal activity's flag and reads only this call's handle, which a
|
|
365
|
+
Temporal cancel also reaches (it arrives as the ``CancelledError`` that
|
|
366
|
+
abandons the call). So an offload the SDK starts *after* a cancel and
|
|
367
|
+
waits on to the end — a drain, a shielded finish, cleanup in an activity
|
|
368
|
+
that caught its cancel — still runs to completion.
|
|
369
|
+
|
|
370
|
+
Raises:
|
|
371
|
+
asyncio.CancelledError: The call's caller stopped waiting. A
|
|
372
|
+
``BaseException``, so no ``except Exception`` on the way out
|
|
373
|
+
swallows it.
|
|
374
|
+
"""
|
|
375
|
+
handle = _CURRENT_CANCEL_HANDLE.get()
|
|
376
|
+
if handle is not None and handle.requested:
|
|
377
|
+
raise asyncio.CancelledError
|
|
378
|
+
|
|
379
|
+
|
|
250
380
|
#: Label prefixes for the auto-holds on the two offload seams (ADR-0018 →
|
|
251
381
|
#: *Feeding the tracker*, mechanism 2). The offloaded callable's own name is
|
|
252
382
|
#: appended, so warn mode ranks *sites* — "run_in_thread.Cursor.execute, p99
|
|
@@ -650,8 +780,10 @@ def _abandon(slot: _OffloadSlot, future: "concurrent.futures.Future[Any]") -> No
|
|
|
650
780
|
logger.warning(
|
|
651
781
|
"Offloaded call %s for app %s outlived its caller; the thread keeps a "
|
|
652
782
|
"blocking-pool slot until the call returns on its own (%d stranded for "
|
|
653
|
-
"this app).
|
|
654
|
-
"
|
|
783
|
+
"this app). Stop it when its caller gives up: check is_cancelled() "
|
|
784
|
+
"between steps of a long loop, register the driver's cancel on "
|
|
785
|
+
"current_cancel_handle() for a single long call, and give the call a "
|
|
786
|
+
"driver-level timeout",
|
|
655
787
|
slot.label,
|
|
656
788
|
slot.owner,
|
|
657
789
|
count,
|
|
@@ -704,7 +836,7 @@ async def run_in_thread(
|
|
|
704
836
|
========================= ====================== ====================
|
|
705
837
|
Need Use (async) Avoid (blocking)
|
|
706
838
|
========================= ====================== ====================
|
|
707
|
-
HTTP requests ``httpx
|
|
839
|
+
HTTP requests ``httpx`` ``requests``
|
|
708
840
|
AWS SDK ``aioboto3``, ``boto3``
|
|
709
841
|
``aiobotocore``
|
|
710
842
|
PostgreSQL ``asyncpg`` ``psycopg2``
|
|
@@ -780,6 +912,15 @@ async def run_in_thread(
|
|
|
780
912
|
travels on the callable, never in ``**kwargs``, so every keyword argument
|
|
781
913
|
still reaches ``func`` — no name is reserved.
|
|
782
914
|
|
|
915
|
+
**Every call has a handle.** Without ``bind``, a fresh one is created, and
|
|
916
|
+
code anywhere inside the call reaches it with :func:`current_cancel_handle`
|
|
917
|
+
— so a driver cancel can be registered without passing the handle down.
|
|
918
|
+
It is requested whenever the awaiting task is cancelled, by Temporal or
|
|
919
|
+
locally (``asyncio.timeout``, a ``TaskGroup`` sibling failing), and that
|
|
920
|
+
is what :func:`is_cancelled` reports inside the thread: a long loop checks
|
|
921
|
+
it between steps and returns. It is scoped to this call; the caller, and
|
|
922
|
+
every other offloaded call, still read ``False``.
|
|
923
|
+
|
|
783
924
|
Args:
|
|
784
925
|
func: Blocking function to run. MUST have internal timeout handling.
|
|
785
926
|
A :meth:`CancelHandle.bind` result is cancelled at the driver too.
|
|
@@ -794,6 +935,11 @@ async def run_in_thread(
|
|
|
794
935
|
- ``self.context.storage`` / ``self.context.state`` — already async.
|
|
795
936
|
"""
|
|
796
937
|
ctx = contextvars.copy_context()
|
|
938
|
+
# Every call gets a handle, bound or fresh, and the thread can reach it
|
|
939
|
+
# through `current_cancel_handle()` / `is_cancelled()`. Set in the copy, so
|
|
940
|
+
# only this call's thread sees it.
|
|
941
|
+
cancel_handle = _bound_handle(func) or CancelHandle()
|
|
942
|
+
ctx.run(_CURRENT_CANCEL_HANDLE.set, cancel_handle)
|
|
797
943
|
loop = asyncio.get_running_loop()
|
|
798
944
|
# Auto-hold, unbounded (ADR-0018 → *Feeding the tracker*, mechanism 2).
|
|
799
945
|
# `run_in_thread` is a mandatory seam, so this is the one place the SDK can
|
|
@@ -816,7 +962,6 @@ async def run_in_thread(
|
|
|
816
962
|
scopes = _OFFLOAD_SCOPES.get()
|
|
817
963
|
if scopes:
|
|
818
964
|
call = _tracked_offload(call, scopes, label)
|
|
819
|
-
cancel_handle = _bound_handle(func)
|
|
820
965
|
# The app's own pool on the consolidated host (``blocking_executor``), else
|
|
821
966
|
# the process-wide one.
|
|
822
967
|
executor = _BLOCKING_EXECUTOR_OVERRIDE.get() or _BLOCKING_EXECUTOR
|
|
@@ -836,9 +981,9 @@ async def run_in_thread(
|
|
|
836
981
|
try:
|
|
837
982
|
return await asyncio.wrap_future(future, loop=loop)
|
|
838
983
|
except asyncio.CancelledError:
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
984
|
+
# Non-blocking: any registered action goes to the cancel pool. Also
|
|
985
|
+
# what flips `is_cancelled()` inside the thread, whoever cancelled.
|
|
986
|
+
cancel_handle.request()
|
|
842
987
|
_abandon(slot, future)
|
|
843
988
|
raise
|
|
844
989
|
|
|
@@ -1040,6 +1185,12 @@ def submit_in_thread(
|
|
|
1040
1185
|
never ran. Ignoring the return value is the normal case.
|
|
1041
1186
|
"""
|
|
1042
1187
|
ctx = contextvars.copy_context()
|
|
1188
|
+
# Cleanup submitted from inside an offloaded call must not inherit that
|
|
1189
|
+
# call's handle: it runs to completion whether or not its caller survives,
|
|
1190
|
+
# so `raise_if_offload_abandoned()` never stops it. (The Temporal activity
|
|
1191
|
+
# context still travels with the copy, so inside a cancelled activity the
|
|
1192
|
+
# public `is_cancelled()` does report that activity's cancel.)
|
|
1193
|
+
ctx.run(_CURRENT_CANCEL_HANDLE.set, None)
|
|
1043
1194
|
executor = _BLOCKING_EXECUTOR_OVERRIDE.get() or _BLOCKING_EXECUTOR
|
|
1044
1195
|
try:
|
|
1045
1196
|
future = executor.submit(ctx.run, functools.partial(func, *args, **kwargs))
|
|
@@ -1278,11 +1429,30 @@ def _discard_process_pool(max_workers: int, pool: _IsolationPool) -> None:
|
|
|
1278
1429
|
executor.shutdown(wait=False)
|
|
1279
1430
|
|
|
1280
1431
|
|
|
1432
|
+
def _retire_single_use_pool(pool: _IsolationPool) -> None:
|
|
1433
|
+
"""Shut a ``fresh_child=True`` pool down once its one call's child is done.
|
|
1434
|
+
|
|
1435
|
+
Runs from the child future's done callback, which fires on the executor's
|
|
1436
|
+
own manager thread — joining the children there would deadlock, so the
|
|
1437
|
+
join happens on a short-lived daemon thread. ``reaped`` is set once every
|
|
1438
|
+
child has exited, as for an idle-reaped pool.
|
|
1439
|
+
"""
|
|
1440
|
+
|
|
1441
|
+
def _join() -> None:
|
|
1442
|
+
pool.executor.shutdown(wait=True)
|
|
1443
|
+
pool.reaped.set()
|
|
1444
|
+
|
|
1445
|
+
threading.Thread(
|
|
1446
|
+
target=_join, name="sdk-isolation-fresh-retire", daemon=True
|
|
1447
|
+
).start()
|
|
1448
|
+
|
|
1449
|
+
|
|
1281
1450
|
async def run_fault_isolated(
|
|
1282
1451
|
func: Callable[..., T],
|
|
1283
1452
|
*args: Any,
|
|
1284
1453
|
timeout: float | None = None,
|
|
1285
1454
|
max_workers: int | None = None,
|
|
1455
|
+
fresh_child: bool = False,
|
|
1286
1456
|
**kwargs: Any,
|
|
1287
1457
|
) -> T:
|
|
1288
1458
|
"""Run ``func`` in an isolated child process (native-crash containment).
|
|
@@ -1329,6 +1499,15 @@ async def run_fault_isolated(
|
|
|
1329
1499
|
all ``max_workers=1`` callers share a single child and queue behind
|
|
1330
1500
|
one another; pass another integer to bound concurrency at a
|
|
1331
1501
|
different width. Must be >= 1.
|
|
1502
|
+
fresh_child: Run on a single-use child that serves this call only and exits
|
|
1503
|
+
as soon as it finishes, instead of a pooled one. A pooled child
|
|
1504
|
+
serves every call that arrives within the idle period, and the
|
|
1505
|
+
peak heap one call leaves behind stays resident into the next. Use
|
|
1506
|
+
``fresh_child=True`` for heavy calls made back to back — each step then
|
|
1507
|
+
starts on an empty heap, and the memory is returned the moment the
|
|
1508
|
+
call ends rather than after the idle period. Costs one spawn and
|
|
1509
|
+
import per call. Never shared, so no other caller can queue behind
|
|
1510
|
+
it or discard it. ``max_workers`` must be ``None`` or ``1``.
|
|
1332
1511
|
|
|
1333
1512
|
Raises:
|
|
1334
1513
|
BrokenProcessPool: The child died abnormally (native crash), or a
|
|
@@ -1337,11 +1516,22 @@ async def run_fault_isolated(
|
|
|
1337
1516
|
width gets a fresh child.
|
|
1338
1517
|
TimeoutError: ``timeout`` elapsed. The child is killed and the pool
|
|
1339
1518
|
discarded.
|
|
1340
|
-
InvalidInputValueError: ``max_workers`` is < 1
|
|
1519
|
+
InvalidInputValueError: ``max_workers`` is < 1, or is neither ``None``
|
|
1520
|
+
nor ``1`` with ``fresh_child=True`` (also a ``ValueError``).
|
|
1341
1521
|
"""
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1522
|
+
if fresh_child and max_workers not in (None, 1):
|
|
1523
|
+
raise InvalidInputValueError(
|
|
1524
|
+
message=f"fresh_child=True runs on a single-use width-1 child; got max_workers={max_workers}",
|
|
1525
|
+
field="max_workers",
|
|
1526
|
+
constraint="None or 1 when fresh_child=True",
|
|
1527
|
+
value_summary=str(max_workers),
|
|
1528
|
+
)
|
|
1529
|
+
if fresh_child:
|
|
1530
|
+
workers = 1
|
|
1531
|
+
else:
|
|
1532
|
+
workers = (
|
|
1533
|
+
_default_process_pool_max_workers() if max_workers is None else max_workers
|
|
1534
|
+
)
|
|
1345
1535
|
if workers < 1:
|
|
1346
1536
|
raise InvalidInputValueError(
|
|
1347
1537
|
message=f"max_workers must be >= 1, got {workers}",
|
|
@@ -1371,7 +1561,21 @@ async def run_fault_isolated(
|
|
|
1371
1561
|
# the child, so the call returns at its deadline whether or not a hold is
|
|
1372
1562
|
# watching.
|
|
1373
1563
|
with _auto_hold(_ISOLATED_HOLD_PREFIX + _offloaded_callable_name(func), timeout):
|
|
1374
|
-
|
|
1564
|
+
if fresh_child:
|
|
1565
|
+
# Never registered in _PROCESS_POOLS, so no other caller can reach
|
|
1566
|
+
# it; _discard_process_pool below leaves the shared width-1 pool
|
|
1567
|
+
# alone for the same reason.
|
|
1568
|
+
pool = _IsolationPool(1)
|
|
1569
|
+
|
|
1570
|
+
def release() -> None:
|
|
1571
|
+
_retire_single_use_pool(pool)
|
|
1572
|
+
|
|
1573
|
+
else:
|
|
1574
|
+
pool = _acquire_process_pool(workers)
|
|
1575
|
+
|
|
1576
|
+
def release() -> None:
|
|
1577
|
+
_release_process_pool(workers, pool)
|
|
1578
|
+
|
|
1375
1579
|
try:
|
|
1376
1580
|
child_future = pool.executor.submit(
|
|
1377
1581
|
functools.partial(func, *args, **kwargs)
|
|
@@ -1379,12 +1583,10 @@ async def run_fault_isolated(
|
|
|
1379
1583
|
except BaseException:
|
|
1380
1584
|
# Never submitted (pool broken or shut down): nothing will release
|
|
1381
1585
|
# the in-flight count, so release it here.
|
|
1382
|
-
|
|
1586
|
+
release()
|
|
1383
1587
|
raise
|
|
1384
1588
|
# Released when the *child* is done, not when this caller stops waiting.
|
|
1385
|
-
child_future.add_done_callback(
|
|
1386
|
-
lambda _done: _release_process_pool(workers, pool)
|
|
1387
|
-
)
|
|
1589
|
+
child_future.add_done_callback(lambda _done: release())
|
|
1388
1590
|
future = asyncio.wrap_future(child_future, loop=loop)
|
|
1389
1591
|
if timeout is not None:
|
|
1390
1592
|
# Not asyncio.wait_for: on timeout it cancels the future and then
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/clients/sql.py
RENAMED
|
@@ -234,6 +234,130 @@ def _invalidate_if_cancelled(connection: "Connection", handle: CancelHandle) ->
|
|
|
234
234
|
connection.invalidate()
|
|
235
235
|
|
|
236
236
|
|
|
237
|
+
class _ChunksHoldingConnection(Iterator["pd.DataFrame"]):
|
|
238
|
+
"""*frames*, keeping *connection* checked out until they are done.
|
|
239
|
+
|
|
240
|
+
A chunked ``read_sql_query`` reads each chunk lazily from the cursor, so the
|
|
241
|
+
connection must stay open until the last one. Closing it as soon as the
|
|
242
|
+
iterator was built (what a ``with`` around the call did) handed it back to
|
|
243
|
+
the pool while its cursor was still being read: a server-side cursor could
|
|
244
|
+
then share a connection with its next borrower, and a buffered one had
|
|
245
|
+
already loaded the whole result, so ``chunksize`` saved nothing.
|
|
246
|
+
|
|
247
|
+
Released on exhaustion, on a failed read, or on :meth:`close` — including a
|
|
248
|
+
close before the first chunk, which a generator's ``finally`` would skip.
|
|
249
|
+
Dropped instead of pooled when the read that closes it was cancelled.
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
def __init__(
|
|
253
|
+
self, connection: "Connection", frames: Iterator["pd.DataFrame"]
|
|
254
|
+
) -> None:
|
|
255
|
+
self._connection = connection
|
|
256
|
+
self._frames = frames
|
|
257
|
+
self._closed = False
|
|
258
|
+
|
|
259
|
+
def __next__(self) -> "pd.DataFrame":
|
|
260
|
+
if self._closed:
|
|
261
|
+
raise StopIteration
|
|
262
|
+
try:
|
|
263
|
+
return next(self._frames)
|
|
264
|
+
except BaseException:
|
|
265
|
+
# StopIteration included: the last chunk is read, release now.
|
|
266
|
+
self.close()
|
|
267
|
+
raise
|
|
268
|
+
|
|
269
|
+
def close(self) -> None:
|
|
270
|
+
"""Stop reading and release the connection; idempotent."""
|
|
271
|
+
if self._closed:
|
|
272
|
+
return
|
|
273
|
+
self._closed = True
|
|
274
|
+
try:
|
|
275
|
+
close_frames = getattr(self._frames, "close", None)
|
|
276
|
+
if close_frames is not None:
|
|
277
|
+
close_frames()
|
|
278
|
+
finally:
|
|
279
|
+
read = _ACTIVE_READ.get()
|
|
280
|
+
if read is not None:
|
|
281
|
+
_invalidate_if_cancelled(self._connection, read.handle)
|
|
282
|
+
self._connection.close()
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
#: What :meth:`_BatchedResults._next_frame` returns once the frames run out.
|
|
286
|
+
#: ``StopIteration`` cannot cross a future, so the end travels as a value.
|
|
287
|
+
_NO_MORE_FRAMES = object()
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class _BatchedResults(Iterator["pd.DataFrame"], AsyncIterator["pd.DataFrame"]):
|
|
291
|
+
"""``get_batched_results``' return: the same frames, iterable either way.
|
|
292
|
+
|
|
293
|
+
``for frame in results`` behaves exactly as the plain iterator did, which
|
|
294
|
+
is what every existing caller relies on. ``async for frame in results``
|
|
295
|
+
fetches each chunk with ``run_in_thread`` instead, so the cursor read and
|
|
296
|
+
the DataFrame build stay off the event loop. A cancel stops any further
|
|
297
|
+
chunk being read and closes (and drops) the connection once the fetch in
|
|
298
|
+
flight returns; that fetch itself is not interrupted, since the cursor's
|
|
299
|
+
cancel is registered only at execute. The SDK's writers take the async
|
|
300
|
+
path whenever it is offered.
|
|
301
|
+
"""
|
|
302
|
+
|
|
303
|
+
def __init__(self, frames: Iterator["pd.DataFrame"], read: _CancellableRead):
|
|
304
|
+
self._frames = frames
|
|
305
|
+
self._read = read
|
|
306
|
+
# Held by every fetch and by close: a close handed to the pool after a
|
|
307
|
+
# cancel waits for the abandoned fetch instead of closing a generator
|
|
308
|
+
# that is still running.
|
|
309
|
+
self._in_use = threading.Lock()
|
|
310
|
+
# Set when a failed or cancelled fetch has already handed close to a
|
|
311
|
+
# thread; aclose then returns at once instead of waiting on that fetch.
|
|
312
|
+
self._close_scheduled = False
|
|
313
|
+
|
|
314
|
+
def __iter__(self) -> "_BatchedResults":
|
|
315
|
+
return self
|
|
316
|
+
|
|
317
|
+
def __next__(self) -> "pd.DataFrame":
|
|
318
|
+
with self._in_use:
|
|
319
|
+
return next(self._frames)
|
|
320
|
+
|
|
321
|
+
def __aiter__(self) -> "_BatchedResults":
|
|
322
|
+
return self
|
|
323
|
+
|
|
324
|
+
def _next_frame(self) -> object:
|
|
325
|
+
with self._in_use, _reading(self._read):
|
|
326
|
+
return next(self._frames, _NO_MORE_FRAMES)
|
|
327
|
+
|
|
328
|
+
def close(self) -> None:
|
|
329
|
+
"""Stop iterating and release the connection; idempotent."""
|
|
330
|
+
close = getattr(self._frames, "close", None)
|
|
331
|
+
if close is None:
|
|
332
|
+
return
|
|
333
|
+
with self._in_use, _reading(self._read):
|
|
334
|
+
close()
|
|
335
|
+
|
|
336
|
+
async def __anext__(self) -> "pd.DataFrame":
|
|
337
|
+
try:
|
|
338
|
+
frame = await run_in_thread(self._read.handle.bind(self._next_frame))
|
|
339
|
+
except BaseException:
|
|
340
|
+
# Cancelled or failed: release the connection once the fetch the
|
|
341
|
+
# thread may still be running returns.
|
|
342
|
+
self._close_scheduled = True
|
|
343
|
+
submit_in_thread(self.close)
|
|
344
|
+
raise
|
|
345
|
+
if frame is _NO_MORE_FRAMES:
|
|
346
|
+
raise StopAsyncIteration
|
|
347
|
+
return cast("pd.DataFrame", frame)
|
|
348
|
+
|
|
349
|
+
async def aclose(self) -> None:
|
|
350
|
+
"""Async counterpart of :meth:`close`, run off the event loop.
|
|
351
|
+
|
|
352
|
+
Returns at once when a failed or cancelled fetch already scheduled the
|
|
353
|
+
close: waiting would hold the caller (often unwinding a cancel) until
|
|
354
|
+
the abandoned fetch returns.
|
|
355
|
+
"""
|
|
356
|
+
if self._close_scheduled:
|
|
357
|
+
return
|
|
358
|
+
await run_in_thread(self.close)
|
|
359
|
+
|
|
360
|
+
|
|
237
361
|
#: The connect-timeout keyword of each driver that has no connect timeout by
|
|
238
362
|
#: default, so a black-holed host holds the connect (and its worker thread)
|
|
239
363
|
#: until the OS gives up. Drivers that already bound their connect (pymysql,
|
|
@@ -912,13 +1036,40 @@ class BaseSQLClient(ClientInterface):
|
|
|
912
1036
|
if not self.engine:
|
|
913
1037
|
raise EngineNotInitializedError()
|
|
914
1038
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1039
|
+
if chunksize is None:
|
|
1040
|
+
with self.engine.connect() as conn:
|
|
1041
|
+
try:
|
|
1042
|
+
return self._execute_pandas_query(conn, query, chunksize)
|
|
1043
|
+
finally:
|
|
1044
|
+
read = _ACTIVE_READ.get()
|
|
1045
|
+
if read is not None:
|
|
1046
|
+
_invalidate_if_cancelled(conn, read.handle)
|
|
1047
|
+
|
|
1048
|
+
# Chunked: the frames are read lazily from the cursor, so the
|
|
1049
|
+
# connection stays checked out until they are done, not until this
|
|
1050
|
+
# returns.
|
|
1051
|
+
conn = self.engine.connect()
|
|
1052
|
+
try:
|
|
1053
|
+
frames = self._execute_pandas_query(conn, query, chunksize)
|
|
1054
|
+
except BaseException:
|
|
1055
|
+
read = _ACTIVE_READ.get()
|
|
1056
|
+
if read is not None:
|
|
1057
|
+
_invalidate_if_cancelled(conn, read.handle)
|
|
1058
|
+
conn.close()
|
|
1059
|
+
raise
|
|
1060
|
+
read = _ACTIVE_READ.get()
|
|
1061
|
+
if read is not None and read.handle.requested:
|
|
1062
|
+
# The caller was cancelled during the execute and will never read
|
|
1063
|
+
# or close the result: drop the connection now rather than leave it
|
|
1064
|
+
# checked out until garbage collection pools it again.
|
|
1065
|
+
_invalidate_if_cancelled(conn, read.handle)
|
|
1066
|
+
conn.close()
|
|
1067
|
+
raise asyncio.CancelledError
|
|
1068
|
+
if not isinstance(frames, Iterator):
|
|
1069
|
+
# An override that materialised the result: nothing left to read.
|
|
1070
|
+
conn.close()
|
|
1071
|
+
return frames
|
|
1072
|
+
return _ChunksHoldingConnection(conn, frames)
|
|
922
1073
|
|
|
923
1074
|
async def _execute_async_read_operation(
|
|
924
1075
|
self, query: str, chunksize: int | None
|
|
@@ -976,6 +1127,14 @@ class BaseSQLClient(ClientInterface):
|
|
|
976
1127
|
) -> AsyncIterator["pd.DataFrame"] | Iterator["pd.DataFrame"]: # type: ignore
|
|
977
1128
|
"""Get query results as batched pandas DataFrames asynchronously.
|
|
978
1129
|
|
|
1130
|
+
The result is iterable both ways. ``async for frame in results`` reads
|
|
1131
|
+
each chunk off the event loop, and a cancel stops further reads and
|
|
1132
|
+
releases the connection once the chunk in flight returns; prefer it.
|
|
1133
|
+
``for frame in results`` still works as it always has, but every chunk
|
|
1134
|
+
is then read on the iterating thread — the event loop, from async code.
|
|
1135
|
+
The query's connection stays checked out until the chunks are read or
|
|
1136
|
+
the result is closed (``close()`` / ``await aclose()``).
|
|
1137
|
+
|
|
979
1138
|
Returns:
|
|
980
1139
|
AsyncIterator["pd.DataFrame"]: Async iterator yielding batches of query results.
|
|
981
1140
|
|
|
@@ -986,7 +1145,18 @@ class BaseSQLClient(ClientInterface):
|
|
|
986
1145
|
try:
|
|
987
1146
|
# We cast to Iterator because passing chunk_size guarantees an Iterator return
|
|
988
1147
|
result = await self._execute_async_read_operation(query, self.chunk_size)
|
|
989
|
-
|
|
1148
|
+
frames = cast(Iterator["pd.DataFrame"], result)
|
|
1149
|
+
from sqlalchemy.ext.asyncio import ( # noqa: PLC0415 — optional dep: sqlalchemy
|
|
1150
|
+
AsyncEngine,
|
|
1151
|
+
)
|
|
1152
|
+
|
|
1153
|
+
if isinstance(self.engine, AsyncEngine) or not isinstance(frames, Iterator):
|
|
1154
|
+
# An async engine's frames come off a greenlet-bound session;
|
|
1155
|
+
# pulling them on a worker thread is not supported there.
|
|
1156
|
+
return frames
|
|
1157
|
+
return _BatchedResults(
|
|
1158
|
+
frames, _CancellableRead(CancelHandle(), self.cancel_cursor)
|
|
1159
|
+
)
|
|
990
1160
|
except AppError:
|
|
991
1161
|
raise
|
|
992
1162
|
# conformance: ignore[E004] exception re-raised immediately as typed SqlPandasResultError; cause chain preserved via `from e`
|
|
@@ -90,7 +90,7 @@ def create_ssl_context_with_custom_certs(cert_dir: str) -> ssl.SSLContext:
|
|
|
90
90
|
@functools.lru_cache(maxsize=1)
|
|
91
91
|
def get_ssl_context() -> bool | ssl.SSLContext:
|
|
92
92
|
"""
|
|
93
|
-
Get the SSL verification context for HTTP clients
|
|
93
|
+
Get the SSL verification context for HTTP clients such as httpx.
|
|
94
94
|
|
|
95
95
|
If SSL_CERT_DIR is set and points to a valid directory, returns an SSLContext
|
|
96
96
|
that includes both default system certificates AND custom certificates from that directory.
|
|
@@ -105,12 +105,6 @@ def get_ssl_context() -> bool | ssl.SSLContext:
|
|
|
105
105
|
>>> ssl_context = get_ssl_context()
|
|
106
106
|
>>> async with httpx.AsyncClient(verify=ssl_context) as client:
|
|
107
107
|
... response = await client.get("https://example.com")
|
|
108
|
-
|
|
109
|
-
>>> import aiohttp
|
|
110
|
-
>>> ssl_context = get_ssl_context()
|
|
111
|
-
>>> async with aiohttp.ClientSession() as session:
|
|
112
|
-
... async with session.get("https://example.com", ssl=ssl_context) as response:
|
|
113
|
-
... pass
|
|
114
108
|
"""
|
|
115
109
|
ssl_cert_dir = get_ssl_cert_dir()
|
|
116
110
|
if ssl_cert_dir:
|
|
@@ -88,8 +88,7 @@ class UnserializableMapperResultError(DataIntegrityError):
|
|
|
88
88
|
|
|
89
89
|
code: ClassVar[str] = "DATA_INTEGRITY_UNSERIALIZABLE_MAPPER_RESULT"
|
|
90
90
|
message: str = (
|
|
91
|
-
"Asset mapper returned a value the SDK cannot serialise to the Atlas "
|
|
92
|
-
"wire shape"
|
|
91
|
+
"Asset mapper returned a value the SDK cannot serialise to the Atlas wire shape"
|
|
93
92
|
)
|
|
94
93
|
suggested_action: str | None = (
|
|
95
94
|
"Return a pyatlan asset (one exposing to_nested_bytes(), "
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/constants.py
RENAMED
|
@@ -1061,7 +1061,7 @@ WINDOWS_EXTENDED_PATH_PREFIX = "\\\\?\\"
|
|
|
1061
1061
|
|
|
1062
1062
|
# SSL Configuration
|
|
1063
1063
|
#: Custom SSL certificate directory path.
|
|
1064
|
-
#: When set,
|
|
1064
|
+
#: When set, the SDK's httpx clients will use certificates from this directory.
|
|
1065
1065
|
SSL_CERT_DIR = os.getenv("SSL_CERT_DIR", "")
|
|
1066
1066
|
|
|
1067
1067
|
|
|
@@ -1130,9 +1130,29 @@ INCREMENTAL_DEFAULT_STATE = "NO CHANGE"
|
|
|
1130
1130
|
#: Base folder for DuckDB temp files (each connection gets a unique UUID subfolder)
|
|
1131
1131
|
DUCKDB_COMMON_TEMP_FOLDER = "/tmp/incremental_duckdb"
|
|
1132
1132
|
|
|
1133
|
-
#:
|
|
1133
|
+
#: Upper bound on DuckDB's memory limit. A connection opened without an
|
|
1134
|
+
#: explicit ``memory_limit`` gets this when the container has no memory limit;
|
|
1135
|
+
#: otherwise it gets the smaller of this and a share of the container's free
|
|
1136
|
+
#: memory (see ``duckdb_utils.default_duckdb_memory_limit``).
|
|
1134
1137
|
DUCKDB_DEFAULT_MEMORY_LIMIT = "2GB"
|
|
1135
1138
|
|
|
1139
|
+
#: ``DUCKDB_DEFAULT_MEMORY_LIMIT`` in bytes (DuckDB's ``GB`` is 1000^3).
|
|
1140
|
+
DUCKDB_MAX_MEMORY_LIMIT_BYTES = 2 * 1000**3
|
|
1141
|
+
|
|
1142
|
+
#: Share of the container's free memory (limit minus current usage) that the
|
|
1143
|
+
#: DuckDB connections opened without an explicit ``memory_limit`` may use
|
|
1144
|
+
#: between them. The rest is a reserve for the worker's own growth and for
|
|
1145
|
+
#: DuckDB's allocations outside its buffer manager, so a scan spills to
|
|
1146
|
+
#: ``temp_directory`` rather than pushing the container toward an OOM kill.
|
|
1147
|
+
DUCKDB_MEMORY_LIMIT_FRACTION = 0.5
|
|
1148
|
+
|
|
1149
|
+
#: Lower bound, in bytes, on a container-derived DuckDB memory limit.
|
|
1150
|
+
DUCKDB_MIN_MEMORY_LIMIT_BYTES = 256 * 1024 * 1024
|
|
1151
|
+
|
|
1152
|
+
#: Operator override for the default DuckDB memory limit (any DuckDB size
|
|
1153
|
+
#: string, e.g. ``1GB``). Empty means derive it from the container limit.
|
|
1154
|
+
DUCKDB_MEMORY_LIMIT_OVERRIDE = os.getenv("ATLAN_DUCKDB_MEMORY_LIMIT", "").strip()
|
|
1155
|
+
|
|
1136
1156
|
SSL_CERT_DIR = os.getenv("SSL_CERT_DIR", "")
|
|
1137
1157
|
"""Custom SSL/TLS certificate directory for corporate/private CAs.
|
|
1138
1158
|
|
|
@@ -1140,8 +1160,8 @@ If set and points to a directory, all .pem/.crt/.cer/.ca-bundle files
|
|
|
1140
1160
|
in that directory are trusted in addition to system CAs.
|
|
1141
1161
|
"""
|
|
1142
1162
|
|
|
1143
|
-
#
|
|
1144
|
-
# SCARF_NO_ANALYTICS
|
|
1163
|
+
# Third-party analytics are disabled via ENV vars in the Dockerfile (DO_NOT_TRACK,
|
|
1164
|
+
# SCARF_NO_ANALYTICS). They must NOT be set here at
|
|
1145
1165
|
# module level — os.environ assignments call os.putenv(), which Temporal's
|
|
1146
1166
|
# workflow sandbox flags as non-deterministic, causing worker eviction loops.
|
|
1147
1167
|
# See: https://github.com/atlanhq/application-sdk/pull/1129
|
|
@@ -14,7 +14,7 @@ Canonical API (v3.x+)::
|
|
|
14
14
|
RateLimitedError, UnimplementedError,
|
|
15
15
|
DependencyUnavailableError, SourceUnavailableError,
|
|
16
16
|
ObjectStoreReadError, ObjectStoreDownloadError,
|
|
17
|
-
ResourceExhaustedError, DiskFullError,
|
|
17
|
+
ResourceExhaustedError, DiskFullError, SdrDiskFullError,
|
|
18
18
|
DataIntegrityError, CancelledError, InternalError,
|
|
19
19
|
classify_http_status, classify_http_exception,
|
|
20
20
|
)
|
|
@@ -58,6 +58,7 @@ from application_sdk.errors.leaves import (
|
|
|
58
58
|
PreconditionError,
|
|
59
59
|
RateLimitedError,
|
|
60
60
|
ResourceExhaustedError,
|
|
61
|
+
SdrDiskFullError,
|
|
61
62
|
SourceUnavailableError,
|
|
62
63
|
SourceWarmupExhaustedError,
|
|
63
64
|
TaskStalledError,
|
|
@@ -161,6 +162,7 @@ __all__ = [
|
|
|
161
162
|
"DataIntegrityError",
|
|
162
163
|
"DependencyUnavailableError",
|
|
163
164
|
"DiskFullError",
|
|
165
|
+
"SdrDiskFullError",
|
|
164
166
|
"LocalVolumeUnwritableError",
|
|
165
167
|
"SourceUnavailableError",
|
|
166
168
|
"SourceWarmupExhaustedError",
|
|
@@ -451,6 +451,38 @@ class DiskFullError(ResourceExhaustedError):
|
|
|
451
451
|
)
|
|
452
452
|
|
|
453
453
|
|
|
454
|
+
#: What the operator of a Self-Deployed Runtime agent does about a full disk.
|
|
455
|
+
#: Shared with the storage variant, whose constructor does not take it.
|
|
456
|
+
SDR_DISK_FULL_ACTION = (
|
|
457
|
+
"Free space on, or expand, the agent host volume backing "
|
|
458
|
+
"ATLAN_TEMPORARY_PATH, or reduce the volume this step stages on local disk."
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
@dataclass(kw_only=True)
|
|
463
|
+
class SdrDiskFullError(DiskFullError):
|
|
464
|
+
"""A ``DiskFullError`` raised on a Self-Deployed Runtime (SDR) agent.
|
|
465
|
+
|
|
466
|
+
The full volume is on the customer's agent host, so the failure is theirs
|
|
467
|
+
to act on: no Atlan deployment can be resized to fix it. Ownership is a
|
|
468
|
+
property of the class, as for every other leaf, so readers that take
|
|
469
|
+
``type(exc).audience`` (the Temporal failure log, the preflight outcome)
|
|
470
|
+
route it the same way as the failure envelope. The class is chosen where
|
|
471
|
+
the error is raised (:mod:`application_sdk.common.atomic`), from whether
|
|
472
|
+
the worker runs in SDR mode.
|
|
473
|
+
|
|
474
|
+
Same code (``RESOURCE_EXHAUSTED_DISK_FULL``) and retryability as its
|
|
475
|
+
parent, so callers that match on either keep working.
|
|
476
|
+
"""
|
|
477
|
+
|
|
478
|
+
# Restated, not changed: the code stays the parent's so callers matching
|
|
479
|
+
# on ``RESOURCE_EXHAUSTED_DISK_FULL`` keep working (P003 wants each leaf to
|
|
480
|
+
# declare its own).
|
|
481
|
+
code: ClassVar[str] = "RESOURCE_EXHAUSTED_DISK_FULL"
|
|
482
|
+
audience: ClassVar[Audience] = Audience.USER
|
|
483
|
+
suggested_action: str | None = SDR_DISK_FULL_ACTION
|
|
484
|
+
|
|
485
|
+
|
|
454
486
|
@dataclass(kw_only=True)
|
|
455
487
|
class LocalVolumeUnwritableError(ResourceExhaustedError):
|
|
456
488
|
"""A local write failed because the volume is read-only or the path is unwritable.
|
|
@@ -37,9 +37,8 @@ from typing import Annotated, Any, Protocol, cast
|
|
|
37
37
|
from uuid import uuid4
|
|
38
38
|
|
|
39
39
|
import orjson
|
|
40
|
-
from fastapi import FastAPI, File, Form, HTTPException
|
|
40
|
+
from fastapi import FastAPI, File, Form, HTTPException, Query, Request, UploadFile
|
|
41
41
|
from fastapi import Path as PathParam
|
|
42
|
-
from fastapi import Query, Request, UploadFile
|
|
43
42
|
from fastapi.responses import JSONResponse
|
|
44
43
|
|
|
45
44
|
from application_sdk._logging import get_logger
|
|
@@ -84,8 +84,6 @@ async def read_json_object(request: Request) -> dict[str, Any]:
|
|
|
84
84
|
raise RequestContractError(message="Request body is not valid JSON.") from exc
|
|
85
85
|
if not isinstance(body, dict):
|
|
86
86
|
raise RequestContractError(
|
|
87
|
-
message=(
|
|
88
|
-
"Request body must be a JSON object, got " f"{type(body).__name__}."
|
|
89
|
-
)
|
|
87
|
+
message=(f"Request body must be a JSON object, got {type(body).__name__}.")
|
|
90
88
|
)
|
|
91
89
|
return body
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/version.py
RENAMED
|
@@ -24,17 +24,16 @@ re-hardcodes the version:
|
|
|
24
24
|
|
|
25
25
|
* ``application_sdk.dev._dapr`` imports ``__dapr_version`` directly for the
|
|
26
26
|
embedded local-dev daprd download.
|
|
27
|
-
* The external-Dapr CI
|
|
27
|
+
* The external-Dapr CI path reads it without importing, by grepping this file::
|
|
28
28
|
|
|
29
29
|
ver=$(grep '^__dapr_version' application_sdk/version.py | cut -d'"' -f2)
|
|
30
30
|
|
|
31
|
-
— namely ``.github/actions/
|
|
32
|
-
``.github/actions/connector-integration-tests/action.yaml``.
|
|
31
|
+
— namely ``.github/actions/connector-integration-tests/action.yaml``.
|
|
33
32
|
|
|
34
33
|
This constant is normally updated by the sync workflow above; bump it by hand
|
|
35
34
|
only to reconcile ahead of a release — and deliberately, since older Dapr
|
|
36
35
|
releases drop off the CDN.
|
|
37
36
|
"""
|
|
38
37
|
|
|
39
|
-
__version__ = "3.
|
|
38
|
+
__version__ = "3.55.1"
|
|
40
39
|
__dapr_version: str = "1.19.1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "atlan-application-sdk-api"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.55.1"
|
|
4
4
|
description = "Experimental: the handler surface of the Atlan Application SDK, for the consolidated API host"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
authors = [
|
|
@@ -15,13 +15,18 @@ classifiers = [
|
|
|
15
15
|
"License :: OSI Approved :: Apache Software License",
|
|
16
16
|
"Programming Language :: Python :: 3",
|
|
17
17
|
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
18
21
|
]
|
|
19
22
|
dependencies = [
|
|
20
23
|
"fastapi>=0.162.0,<0.163.0",
|
|
21
24
|
"pydantic>=2.10.6,<3.0.0",
|
|
25
|
+
# application_sdk/contracts/{base,types}.py import it; same pin as the SDK.
|
|
26
|
+
"typing-extensions>=4.12.2,<5",
|
|
22
27
|
"orjson>=3.11.6,<4.0.0",
|
|
23
|
-
# Form parsing for the file-upload route.
|
|
24
|
-
#
|
|
28
|
+
# Form parsing for the file-upload route. The SDK declares it directly with
|
|
29
|
+
# the same pin; the floor is the SDK's CVE constraint.
|
|
25
30
|
"python-multipart>=0.0.26",
|
|
26
31
|
# application_sdk.errors maps httpx failures onto the error leaves
|
|
27
32
|
# (errors/http.py); same pin as the SDK's core dependency.
|
|
@@ -42,7 +47,7 @@ sql = [
|
|
|
42
47
|
"httpx>=0.27.0,<0.29.0",
|
|
43
48
|
"python-dotenv>=1.2.2,<2.0.0", # CVE-2026-28684
|
|
44
49
|
]
|
|
45
|
-
pandas = ["pandas>=2.2.3,<
|
|
50
|
+
pandas = ["pandas>=2.2.3,<4.0.0"]
|
|
46
51
|
aws = [
|
|
47
52
|
"boto3>=1.38.6,<2.0.0",
|
|
48
53
|
"httpx>=0.27.0,<0.29.0",
|
|
@@ -56,7 +61,7 @@ pyatlan = [
|
|
|
56
61
|
# pyatlan 11.5.0 already requires authlib~=1.9.1 on Python >=3.10. Published
|
|
57
62
|
# here too so a resolver that ignores requires-python cannot pick pyatlan's
|
|
58
63
|
# py3.9 authlib branch for this wheel.
|
|
59
|
-
"authlib>=1.9.
|
|
64
|
+
"authlib>=1.9.4,<2", # CVE-2026-96760
|
|
60
65
|
]
|
|
61
66
|
|
|
62
67
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/__init__.py
RENAMED
|
File without changes
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_build_info.py
RENAMED
|
File without changes
|
|
File without changes
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_install.py
RENAMED
|
File without changes
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/_logging.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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/base.py
RENAMED
|
File without changes
|
|
File without changes
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/http.py
RENAMED
|
File without changes
|
{atlan_application_sdk_api-3.54.0 → atlan_application_sdk_api-3.55.1}/application_sdk/errors/wire.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
|
|
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
|
|
File without changes
|