sibi-dst 2025.9.13__py3-none-any.whl → 2025.9.14__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.
- sibi_dst/df_helper/_df_helper.py +1 -1
- sibi_dst/utils/base.py +40 -18
- sibi_dst/utils/dask_utils.py +0 -41
- {sibi_dst-2025.9.13.dist-info → sibi_dst-2025.9.14.dist-info}/METADATA +1 -1
- {sibi_dst-2025.9.13.dist-info → sibi_dst-2025.9.14.dist-info}/RECORD +7 -7
- {sibi_dst-2025.9.13.dist-info → sibi_dst-2025.9.14.dist-info}/WHEEL +0 -0
- {sibi_dst-2025.9.13.dist-info → sibi_dst-2025.9.14.dist-info}/top_level.txt +0 -0
sibi_dst/df_helper/_df_helper.py
CHANGED
@@ -137,7 +137,7 @@ class DfHelper(ManagedResource):
|
|
137
137
|
def __init__(self, backend="sqlalchemy", **kwargs):
|
138
138
|
self.default_config = self.default_config or {}
|
139
139
|
kwargs = {**self.default_config.copy(), **kwargs}
|
140
|
-
kwargs.setdefault("auto_sse",
|
140
|
+
kwargs.setdefault("auto_sse", False)
|
141
141
|
super().__init__(**kwargs)
|
142
142
|
self.backend = backend
|
143
143
|
|
sibi_dst/utils/base.py
CHANGED
@@ -14,7 +14,18 @@ from sibi_dst.utils import Logger
|
|
14
14
|
|
15
15
|
# --------- Minimal built-in SSE sink (used when auto_sse=True) ----------
|
16
16
|
class _QueueSSE:
|
17
|
-
"""
|
17
|
+
"""
|
18
|
+
Handles asynchronous streaming of events with structured data.
|
19
|
+
|
20
|
+
This class provides the ability to manage an asynchronous queue for handling
|
21
|
+
streamed Server-Sent Events (SSE). It supports operations like sending events
|
22
|
+
with associated data, manually enqueuing items, and iterating over items in an
|
23
|
+
asynchronous loop. The class also includes mechanisms for clean closure of the
|
24
|
+
stream.
|
25
|
+
|
26
|
+
:ivar q: An asynchronous queue used to store events and data.
|
27
|
+
:type q: asyncio.Queue
|
28
|
+
"""
|
18
29
|
__slots__ = ("q", "_closed")
|
19
30
|
|
20
31
|
def __init__(self) -> None:
|
@@ -46,11 +57,31 @@ class _QueueSSE:
|
|
46
57
|
# ------------------------------ Base class ------------------------------
|
47
58
|
class ManagedResource(abc.ABC):
|
48
59
|
"""
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
60
|
+
Management of shared resources with configurable verbosity, logging,
|
61
|
+
and support for external file systems and server-sent events (SSE).
|
62
|
+
|
63
|
+
This class is designed to assist in managing resources such as logging,
|
64
|
+
file systems, and SSE within an asynchronous or synchronous environment.
|
65
|
+
It provides facilities for handling resource lifecycle, introspection,
|
66
|
+
and cleanup while ensuring resources are appropriately managed. The class
|
67
|
+
also supports lazy initialization of external dependencies via factories.
|
68
|
+
|
69
|
+
:ivar verbose: Controls verbosity of logging or operations. If set to True,
|
70
|
+
more detailed logging/output will be generated.
|
71
|
+
:type verbose: bool
|
72
|
+
:ivar debug: Enables debug-level logging and internal diagnostics when True.
|
73
|
+
Typically used for troubleshooting purposes.
|
74
|
+
:type debug: bool
|
75
|
+
:ivar logger: The logger instance used for this resource. If left unset,
|
76
|
+
a default logger will be created.
|
77
|
+
:type logger: Optional[Logger]
|
78
|
+
:ivar fs: The file system interface being used. Typically an instance of
|
79
|
+
`fsspec.AbstractFileSystem`. If not provided, it may be created lazily
|
80
|
+
using a supplied factory function.
|
81
|
+
:type fs: Optional[fsspec.AbstractFileSystem]
|
82
|
+
:ivar emitter: A callable, potentially asynchronous, function for emitting
|
83
|
+
events. Events are sent as a combination of event names and payload data.
|
84
|
+
:type emitter: Optional[Callable[[str, Dict[str, Any]], Awaitable[None]]]
|
54
85
|
"""
|
55
86
|
|
56
87
|
__slots__ = (
|
@@ -74,28 +105,23 @@ class ManagedResource(abc.ABC):
|
|
74
105
|
debug: bool = False,
|
75
106
|
log_cleanup_errors: bool = True,
|
76
107
|
logger: Optional[Logger] = None,
|
77
|
-
# filesystem
|
78
108
|
fs: Optional[fsspec.AbstractFileSystem] = None,
|
79
109
|
fs_factory: Optional[Callable[[], fsspec.AbstractFileSystem]] = None,
|
80
|
-
# SSE
|
81
110
|
emitter: Optional[Callable[[str, Dict[str, Any]], Awaitable[None]]] = None,
|
82
111
|
emitter_factory: Optional[Callable[[], Callable[[str, Dict[str, Any]], Awaitable[None]]]] = None,
|
83
112
|
sse: Optional[object] = None,
|
84
113
|
sse_factory: Optional[Callable[[], object]] = None,
|
85
|
-
auto_sse: bool = False,
|
114
|
+
auto_sse: bool = False,
|
86
115
|
**_: object,
|
87
116
|
) -> None:
|
88
|
-
# flags
|
89
117
|
self.verbose = verbose
|
90
118
|
self.debug = debug
|
91
119
|
self._log_cleanup_errors = log_cleanup_errors
|
92
120
|
|
93
|
-
# lifecycle
|
94
121
|
self._is_closed = False
|
95
122
|
self._closing = False
|
96
123
|
self._close_lock = threading.RLock()
|
97
124
|
|
98
|
-
# logger
|
99
125
|
if logger is None:
|
100
126
|
self.logger = Logger.default_logger(logger_name=self.__class__.__name__)
|
101
127
|
self._owns_logger = True
|
@@ -105,7 +131,6 @@ class ManagedResource(abc.ABC):
|
|
105
131
|
self.logger = logger
|
106
132
|
self._owns_logger = False
|
107
133
|
|
108
|
-
# fs
|
109
134
|
self.fs: Optional[fsspec.AbstractFileSystem] = None
|
110
135
|
self._fs_factory = None
|
111
136
|
self._owns_fs = False
|
@@ -119,7 +144,6 @@ class ManagedResource(abc.ABC):
|
|
119
144
|
self._fs_factory = fs_factory
|
120
145
|
self._owns_fs = True
|
121
146
|
|
122
|
-
# sse / emitter
|
123
147
|
self._sse: Optional[object] = None
|
124
148
|
self._sse_factory: Optional[Callable[[], object]] = None
|
125
149
|
self._owns_sse = False
|
@@ -140,16 +164,15 @@ class ManagedResource(abc.ABC):
|
|
140
164
|
self._sse_factory = sse_factory
|
141
165
|
self._owns_sse = True
|
142
166
|
|
143
|
-
# EAGER auto-SSE: create sink+emitter now if none supplied
|
144
167
|
if self._auto_sse and self._sse is None and self._emitter is None and self._sse_factory is None:
|
145
168
|
self._create_auto_sse()
|
146
169
|
|
147
|
-
#
|
170
|
+
# Garbage Collector finaliser
|
148
171
|
self._finalizer = weakref.finalize(self, self._finalize_static, weakref.ref(self))
|
149
172
|
|
150
173
|
if self.debug:
|
151
174
|
with contextlib.suppress(Exception):
|
152
|
-
self.logger.debug("
|
175
|
+
self.logger.debug("Initialised %s %s", self.__class__.__name__, repr(self))
|
153
176
|
|
154
177
|
# ---------- Introspection ----------
|
155
178
|
@property
|
@@ -222,7 +245,6 @@ class ManagedResource(abc.ABC):
|
|
222
245
|
|
223
246
|
# ---------- SSE ----------
|
224
247
|
def _create_auto_sse(self) -> None:
|
225
|
-
# internal helper: create queue sink + emitter, mark as owned
|
226
248
|
sink = _QueueSSE()
|
227
249
|
self._sse = sink
|
228
250
|
self._owns_sse = True
|
sibi_dst/utils/dask_utils.py
CHANGED
@@ -5,7 +5,6 @@ import logging
|
|
5
5
|
from typing import List, Any, Dict
|
6
6
|
|
7
7
|
import dask
|
8
|
-
# dask.config.set({"distributed.worker.daemon": False})
|
9
8
|
import dask.dataframe as dd
|
10
9
|
|
11
10
|
def _to_int_safe(x) -> int:
|
@@ -158,43 +157,3 @@ async def shared_dask_session(**kwargs):
|
|
158
157
|
yield mixin.dask_client
|
159
158
|
finally:
|
160
159
|
mixin._close_dask_client()
|
161
|
-
|
162
|
-
# from contextlib import suppress
|
163
|
-
# from dask.distributed import Client, get_client
|
164
|
-
#
|
165
|
-
# class DaskClientMixin:
|
166
|
-
# """
|
167
|
-
# Provides shared Dask client lifecycle management.
|
168
|
-
# Ensures reuse of existing client when available, otherwise creates a lightweight local one.
|
169
|
-
# """
|
170
|
-
#
|
171
|
-
# def _init_dask_client(self, dask_client=None, logger=None):
|
172
|
-
# self.dask_client = dask_client
|
173
|
-
# self.own_dask_client = False
|
174
|
-
# self.logger = logger
|
175
|
-
#
|
176
|
-
# if self.dask_client is None:
|
177
|
-
# with suppress(ValueError, RuntimeError):
|
178
|
-
# # Try to attach to an existing active client if running inside a Dask context
|
179
|
-
# self.dask_client = get_client()
|
180
|
-
#
|
181
|
-
# if self.dask_client is None:
|
182
|
-
# # Start a local in-process scheduler for fallback
|
183
|
-
# self.dask_client = Client(processes=False)
|
184
|
-
# self.own_dask_client = True
|
185
|
-
# if self.logger:
|
186
|
-
# self.logger.info(f"Started local Dask client: {self.dask_client.dashboard_link}")
|
187
|
-
# else:
|
188
|
-
# if self.logger:
|
189
|
-
# self.logger.debug(f"Using existing Dask client: {self.dask_client.dashboard_link}")
|
190
|
-
#
|
191
|
-
# def _close_dask_client(self):
|
192
|
-
# """Close client only if this instance created it."""
|
193
|
-
# if getattr(self, "own_dask_client", False) and self.dask_client is not None:
|
194
|
-
# try:
|
195
|
-
# self.dask_client.close()
|
196
|
-
# if self.logger:
|
197
|
-
# self.logger.info("Closed local Dask client.")
|
198
|
-
# except Exception as e:
|
199
|
-
# if self.logger:
|
200
|
-
# self.logger.warning(f"Error while closing Dask client: {e}")
|
@@ -2,7 +2,7 @@ sibi_dst/__init__.py,sha256=QQVT3Xlj8iZN17sSMfRQFSb_DHr8A7giJP8hn02K2Oo,585
|
|
2
2
|
sibi_dst/df_helper/__init__.py,sha256=7rUdMybgCNZhQL_J7IFTTHz_xtFin81xavi5-PUExkA,463
|
3
3
|
sibi_dst/df_helper/_artifact_updater_async.py,sha256=AZp0vM3vji0tjiaScr8a9SUMH15NjPIKYPdRQ7SJe3Y,11372
|
4
4
|
sibi_dst/df_helper/_artifact_updater_threaded.py,sha256=M5GNZismOqMmBrcyfolP1DPv87VILQf_P18is_epn50,7238
|
5
|
-
sibi_dst/df_helper/_df_helper.py,sha256=
|
5
|
+
sibi_dst/df_helper/_df_helper.py,sha256=30J6f7TwfOkCXAUbk3QS-K_5ouYx2tc8BGXrcvNwvC8,17006
|
6
6
|
sibi_dst/df_helper/_parquet_artifact.py,sha256=UXkhDSAVRNKp9DykVhJd3agnryCZT0Sj2qhdhUZomuM,19421
|
7
7
|
sibi_dst/df_helper/_parquet_reader.py,sha256=RI1e7S7u5RLqkdOD5apcuXel7KtefglS9bhzCO_TB_k,3259
|
8
8
|
sibi_dst/df_helper/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -38,11 +38,11 @@ sibi_dst/tests/test_baseclass.py,sha256=5huAwjWo_SOEZR2_0y5w9qUmw5G7pVdm8X1OTG87
|
|
38
38
|
sibi_dst/tests/test_data_wrapper_class.py,sha256=6uFmZR2DxnxQz49L5jT2ehlKvlLnpUHMLFB_PqqUq7k,3336
|
39
39
|
sibi_dst/utils/__init__.py,sha256=eoW7iROrCUVYjNT1owMgGvW6U7lolbNy3FrBb_wInPs,1304
|
40
40
|
sibi_dst/utils/async_utils.py,sha256=53aywfgq1Q6-0OVr9qR1Sf6g7Qv3I9qunAAR4fjFXBE,351
|
41
|
-
sibi_dst/utils/base.py,sha256=
|
41
|
+
sibi_dst/utils/base.py,sha256=ycaaXlXTH4tn3fM954jGx8-zKWEmdjJkJKArQ2rfAH0,17527
|
42
42
|
sibi_dst/utils/business_days.py,sha256=DPZExTXTt7n3IbAaEuVacm-vZgbR_Ug2bJTPBUaoP3g,6694
|
43
43
|
sibi_dst/utils/clickhouse_writer.py,sha256=8W_dTEOKQp4pXANznVSxRqFA2H5oD8UJifiBAONpXWY,17001
|
44
44
|
sibi_dst/utils/credentials.py,sha256=cHJPPsmVyijqbUQIq7WWPe-lIallA-mI5RAy3YUuRME,1724
|
45
|
-
sibi_dst/utils/dask_utils.py,sha256=
|
45
|
+
sibi_dst/utils/dask_utils.py,sha256=t6pXmg-xDBhVi_CLg8_bw3pCy_CyM7bhbS4pbZG3Mbs,5500
|
46
46
|
sibi_dst/utils/data_from_http_source.py,sha256=AcpKNsqTgN2ClNwuhgUpuNCx62r5_DdsAiKY8vcHEBA,1867
|
47
47
|
sibi_dst/utils/data_utils.py,sha256=7bLidEjppieNoozDFb6OuRY0W995cxg4tiGAlkGfePI,7768
|
48
48
|
sibi_dst/utils/data_wrapper.py,sha256=9HTuDXgvfhmFAOyNG_GEOaHuojxE3639yyzOoBt7Unc,18000
|
@@ -94,7 +94,7 @@ sibi_dst/v2/df_helper/core/_params_config.py,sha256=DYx2drDz3uF-lSPzizPkchhy-kxR
|
|
94
94
|
sibi_dst/v2/df_helper/core/_query_config.py,sha256=Y8LVSyaKuVkrPluRDkQoOwuXHQxner1pFWG3HPfnDHM,441
|
95
95
|
sibi_dst/v2/utils/__init__.py,sha256=6H4cvhqTiFufnFPETBF0f8beVVMpfJfvUs6Ne0TQZNY,58
|
96
96
|
sibi_dst/v2/utils/log_utils.py,sha256=rfk5VsLAt-FKpv6aPTC1FToIPiyrnHAFFBAkHme24po,4123
|
97
|
-
sibi_dst-2025.9.
|
98
|
-
sibi_dst-2025.9.
|
99
|
-
sibi_dst-2025.9.
|
100
|
-
sibi_dst-2025.9.
|
97
|
+
sibi_dst-2025.9.14.dist-info/METADATA,sha256=pKn_x6mtctOqGIy4MDZgy9kFkR9vsRTneFkwNFjJAj8,2413
|
98
|
+
sibi_dst-2025.9.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
99
|
+
sibi_dst-2025.9.14.dist-info/top_level.txt,sha256=g3Cj4R-rciuNyJgcxuxNgw5nhN0n4TCB0ujcTEjZNiU,9
|
100
|
+
sibi_dst-2025.9.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|