sibi-dst 2025.9.12__tar.gz → 2025.9.14__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.
Files changed (105) hide show
  1. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/PKG-INFO +1 -1
  2. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/pyproject.toml +1 -1
  3. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/_df_helper.py +1 -1
  4. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/base.py +40 -18
  5. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/dask_utils.py +16 -41
  6. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst.egg-info/PKG-INFO +1 -1
  7. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/README.md +0 -0
  8. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/setup.cfg +0 -0
  9. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/__init__.py +0 -0
  10. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/__init__.py +0 -0
  11. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/_artifact_updater_async.py +0 -0
  12. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/_artifact_updater_threaded.py +0 -0
  13. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/_parquet_artifact.py +0 -0
  14. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/_parquet_reader.py +0 -0
  15. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/__init__.py +0 -0
  16. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/http/__init__.py +0 -0
  17. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/http/_http_config.py +0 -0
  18. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/parquet/__init__.py +0 -0
  19. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/parquet/_parquet_options.py +0 -0
  20. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/sqlalchemy/__init__.py +0 -0
  21. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/sqlalchemy/_db_connection.py +0 -0
  22. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/sqlalchemy/_db_gatekeeper.py +0 -0
  23. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/sqlalchemy/_io_dask.py +0 -0
  24. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/sqlalchemy/_load_from_db.py +0 -0
  25. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/sqlalchemy/_model_registry.py +0 -0
  26. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/backends/sqlalchemy/_sql_model_builder.py +0 -0
  27. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/core/__init__.py +0 -0
  28. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/core/_defaults.py +0 -0
  29. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/core/_filter_handler.py +0 -0
  30. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/core/_params_config.py +0 -0
  31. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/df_helper/core/_query_config.py +0 -0
  32. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/geopy_helper/__init__.py +0 -0
  33. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/geopy_helper/geo_location_service.py +0 -0
  34. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/geopy_helper/utils.py +0 -0
  35. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/__init__.py +0 -0
  36. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/base_osm_map.py +0 -0
  37. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/basemaps/__init__.py +0 -0
  38. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/basemaps/calendar_html.py +0 -0
  39. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/basemaps/route_map_plotter.py +0 -0
  40. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/basemaps/router_plotter.py +0 -0
  41. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/route_path_builder.py +0 -0
  42. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/osmnx_helper/utils.py +0 -0
  43. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/tests/__init__.py +0 -0
  44. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/tests/test_baseclass.py +0 -0
  45. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/tests/test_data_wrapper_class.py +0 -0
  46. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/__init__.py +0 -0
  47. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/async_utils.py +0 -0
  48. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/__init__.py +0 -0
  49. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/base_attacher.py +0 -0
  50. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/base_data_cube.py +0 -0
  51. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/base_parquet_artifact.py +0 -0
  52. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/base_parquet_reader.py +0 -0
  53. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/base_pipeline.py +0 -0
  54. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/base_pipeline_template.py +0 -0
  55. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/boilerplate/hybrid_data_loader.py +0 -0
  56. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/business_days.py +0 -0
  57. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/clickhouse_writer.py +0 -0
  58. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/credentials.py +0 -0
  59. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/data_from_http_source.py +0 -0
  60. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/data_utils.py +0 -0
  61. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/data_wrapper.py +0 -0
  62. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/date_utils.py +0 -0
  63. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/df_utils.py +0 -0
  64. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/file_age_checker.py +0 -0
  65. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/file_utils.py +0 -0
  66. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/filepath_generator.py +0 -0
  67. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/iceberg_saver.py +0 -0
  68. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/log_utils.py +0 -0
  69. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/manifest_manager.py +0 -0
  70. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/parquet_saver.py +0 -0
  71. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/periods.py +0 -0
  72. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/phone_formatter.py +0 -0
  73. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/progress/__init__.py +0 -0
  74. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/progress/jobs.py +0 -0
  75. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/progress/sse_runner.py +0 -0
  76. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/storage_config.py +0 -0
  77. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/storage_hive.py +0 -0
  78. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/storage_manager.py +0 -0
  79. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/update_planner.py +0 -0
  80. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/webdav_client.py +0 -0
  81. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/utils/write_gatekeeper.py +0 -0
  82. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/__init__.py +0 -0
  83. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/__init__.py +0 -0
  84. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/_df_helper.py +0 -0
  85. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/__init__.py +0 -0
  86. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlalchemy/__init__.py +0 -0
  87. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlalchemy/_db_connection.py +0 -0
  88. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlalchemy/_io_dask.py +0 -0
  89. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlalchemy/_load_from_db.py +0 -0
  90. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlalchemy/_model_builder.py +0 -0
  91. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlmodel/__init__.py +0 -0
  92. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlmodel/_db_connection.py +0 -0
  93. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlmodel/_io_dask.py +0 -0
  94. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlmodel/_load_from_db.py +0 -0
  95. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/backends/sqlmodel/_model_builder.py +0 -0
  96. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/core/__init__.py +0 -0
  97. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/core/_filter_handler.py +0 -0
  98. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/core/_params_config.py +0 -0
  99. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/df_helper/core/_query_config.py +0 -0
  100. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/utils/__init__.py +0 -0
  101. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst/v2/utils/log_utils.py +0 -0
  102. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst.egg-info/SOURCES.txt +0 -0
  103. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst.egg-info/dependency_links.txt +0 -0
  104. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst.egg-info/requires.txt +0 -0
  105. {sibi_dst-2025.9.12 → sibi_dst-2025.9.14}/sibi_dst.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sibi-dst
3
- Version: 2025.9.12
3
+ Version: 2025.9.14
4
4
  Summary: A data science toolkit for scalable data processing and analysis.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sibi-dst"
3
- version = "2025.9.12"
3
+ version = "2025.9.14"
4
4
  description = "A data science toolkit for scalable data processing and analysis."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -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", True)
140
+ kwargs.setdefault("auto_sse", False)
141
141
  super().__init__(**kwargs)
142
142
  self.backend = backend
143
143
 
@@ -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
- """Async queue–backed SSE sink: async send/put, async iterator, graceful close."""
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
- Owns a logger and optional fsspec filesystem. Can emit SSE events via:
50
- - an async emitter callable: await emitter(event, data)
51
- - a sink exposing async send(event, data) or async put(item)
52
- If neither is provided and auto_sse=True, a queue-backed sink is created eagerly.
53
- Thread-safe lifecycle, CM support, GC finalizer.
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, # eager auto-create if no emitter/sink is supplied
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
- # GC finalizer
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("Initialized %s %s", self.__class__.__name__, repr(self))
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
@@ -1,10 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import asyncio
4
+ import logging
4
5
  from typing import List, Any, Dict
5
6
 
6
7
  import dask
7
- #dask.config.set({"distributed.worker.daemon": False})
8
8
  import dask.dataframe as dd
9
9
 
10
10
  def _to_int_safe(x) -> int:
@@ -63,7 +63,7 @@ class UniqueValuesExtractor:
63
63
  pairs = await asyncio.gather(*(one(c) for c in columns))
64
64
  return dict(pairs)
65
65
 
66
- from contextlib import suppress
66
+ from contextlib import suppress, asynccontextmanager
67
67
  from dask.distributed import Client, LocalCluster, get_client
68
68
  import os
69
69
 
@@ -93,6 +93,12 @@ class DaskClientMixin:
93
93
  self.dask_client = dask_client
94
94
  self.own_dask_client = False
95
95
  self.logger = logger
96
+ # Apply log filters globally
97
+ logging.getLogger("distributed.shuffle._scheduler_plugin").setLevel(
98
+ logging.ERROR
99
+ )
100
+ logging.getLogger("distributed.scheduler").setLevel(logging.WARNING)
101
+ logging.getLogger("distributed.worker").setLevel(logging.WARNING)
96
102
 
97
103
  if self.dask_client is None:
98
104
  with suppress(ValueError, RuntimeError):
@@ -143,42 +149,11 @@ class DaskClientMixin:
143
149
  if self.logger:
144
150
  self.logger.warning(f"Error while closing Dask client: {e}")
145
151
 
146
- # from contextlib import suppress
147
- # from dask.distributed import Client, get_client
148
- #
149
- # class DaskClientMixin:
150
- # """
151
- # Provides shared Dask client lifecycle management.
152
- # Ensures reuse of existing client when available, otherwise creates a lightweight local one.
153
- # """
154
- #
155
- # def _init_dask_client(self, dask_client=None, logger=None):
156
- # self.dask_client = dask_client
157
- # self.own_dask_client = False
158
- # self.logger = logger
159
- #
160
- # if self.dask_client is None:
161
- # with suppress(ValueError, RuntimeError):
162
- # # Try to attach to an existing active client if running inside a Dask context
163
- # self.dask_client = get_client()
164
- #
165
- # if self.dask_client is None:
166
- # # Start a local in-process scheduler for fallback
167
- # self.dask_client = Client(processes=False)
168
- # self.own_dask_client = True
169
- # if self.logger:
170
- # self.logger.info(f"Started local Dask client: {self.dask_client.dashboard_link}")
171
- # else:
172
- # if self.logger:
173
- # self.logger.debug(f"Using existing Dask client: {self.dask_client.dashboard_link}")
174
- #
175
- # def _close_dask_client(self):
176
- # """Close client only if this instance created it."""
177
- # if getattr(self, "own_dask_client", False) and self.dask_client is not None:
178
- # try:
179
- # self.dask_client.close()
180
- # if self.logger:
181
- # self.logger.info("Closed local Dask client.")
182
- # except Exception as e:
183
- # if self.logger:
184
- # self.logger.warning(f"Error while closing Dask client: {e}")
152
+ @asynccontextmanager
153
+ async def shared_dask_session(**kwargs):
154
+ mixin = DaskClientMixin()
155
+ mixin._init_dask_client(**kwargs)
156
+ try:
157
+ yield mixin.dask_client
158
+ finally:
159
+ mixin._close_dask_client()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sibi-dst
3
- Version: 2025.9.12
3
+ Version: 2025.9.14
4
4
  Summary: A data science toolkit for scalable data processing and analysis.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
File without changes
File without changes