thoth-dbmanager 0.5.2__py3-none-any.whl → 0.5.3__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.
- thoth_dbmanager/core/interfaces.py +1 -82
- {thoth_dbmanager-0.5.2.dist-info → thoth_dbmanager-0.5.3.dist-info}/METADATA +1 -7
- {thoth_dbmanager-0.5.2.dist-info → thoth_dbmanager-0.5.3.dist-info}/RECORD +6 -6
- {thoth_dbmanager-0.5.2.dist-info → thoth_dbmanager-0.5.3.dist-info}/WHEEL +0 -0
- {thoth_dbmanager-0.5.2.dist-info → thoth_dbmanager-0.5.3.dist-info}/licenses/LICENSE +0 -0
- {thoth_dbmanager-0.5.2.dist-info → thoth_dbmanager-0.5.3.dist-info}/top_level.txt +0 -0
@@ -278,85 +278,4 @@ class DbPlugin(ABC):
|
|
278
278
|
"""Get unique values (backward compatibility)"""
|
279
279
|
if not self.adapter:
|
280
280
|
raise RuntimeError("Plugin not initialized")
|
281
|
-
return self.adapter.get_unique_values()
|
282
|
-
|
283
|
-
def get_embedding_function(self):
|
284
|
-
"""
|
285
|
-
Get the embedding function for similarity computations.
|
286
|
-
|
287
|
-
Returns:
|
288
|
-
SafeSentenceTransformer: An embedding function with encode method
|
289
|
-
"""
|
290
|
-
try:
|
291
|
-
# Import SafeSentenceTransformer
|
292
|
-
try:
|
293
|
-
from sentence_transformers import SentenceTransformer
|
294
|
-
import logging
|
295
|
-
|
296
|
-
logger = logging.getLogger(__name__)
|
297
|
-
|
298
|
-
class SafeSentenceTransformer:
|
299
|
-
"""
|
300
|
-
Wrapper for SentenceTransformer that handles PyTorch meta tensor issues.
|
301
|
-
"""
|
302
|
-
def __init__(self, model_name_or_path: str):
|
303
|
-
self.model_name_or_path = model_name_or_path
|
304
|
-
self._model = None
|
305
|
-
|
306
|
-
def _get_model(self):
|
307
|
-
"""Lazy initialization of the SentenceTransformer model."""
|
308
|
-
if self._model is None:
|
309
|
-
try:
|
310
|
-
logger.info(f"Initializing SentenceTransformer with model: {self.model_name_or_path}")
|
311
|
-
self._model = SentenceTransformer(
|
312
|
-
model_name_or_path=self.model_name_or_path,
|
313
|
-
device='cpu' # Explicitly set device to CPU to avoid meta tensor issues
|
314
|
-
)
|
315
|
-
logger.info("SentenceTransformer initialized successfully")
|
316
|
-
except Exception as e:
|
317
|
-
logger.error(f"Failed to initialize SentenceTransformer: {e}")
|
318
|
-
# Try alternative initialization approach
|
319
|
-
try:
|
320
|
-
logger.info("Trying alternative initialization approach...")
|
321
|
-
self._model = SentenceTransformer(self.model_name_or_path)
|
322
|
-
# Move to CPU explicitly after initialization
|
323
|
-
self._model = self._model.to('cpu')
|
324
|
-
logger.info("Alternative initialization successful")
|
325
|
-
except Exception as e2:
|
326
|
-
logger.error(f"Alternative initialization also failed: {e2}")
|
327
|
-
raise e2
|
328
|
-
return self._model
|
329
|
-
|
330
|
-
def encode(self, sentences, **kwargs):
|
331
|
-
"""Encode sentences using the underlying SentenceTransformer model."""
|
332
|
-
model = self._get_model()
|
333
|
-
return model.encode(sentences, **kwargs)
|
334
|
-
|
335
|
-
return SafeSentenceTransformer(
|
336
|
-
model_name_or_path="paraphrase-multilingual-MiniLM-L12-v2"
|
337
|
-
)
|
338
|
-
|
339
|
-
except ImportError:
|
340
|
-
import logging
|
341
|
-
logger = logging.getLogger(__name__)
|
342
|
-
logger.warning("sentence_transformers not available, creating dummy embedding function")
|
343
|
-
# Create a dummy embedding function for testing
|
344
|
-
class DummyEmbeddingFunction:
|
345
|
-
def encode(self, sentences, **kwargs):
|
346
|
-
import numpy as np
|
347
|
-
# Return dummy embeddings - same shape for all sentences
|
348
|
-
return np.random.rand(len(sentences), 384) # 384 is typical embedding size
|
349
|
-
|
350
|
-
return DummyEmbeddingFunction()
|
351
|
-
|
352
|
-
except Exception as e:
|
353
|
-
import logging
|
354
|
-
logger = logging.getLogger(__name__)
|
355
|
-
logger.error(f"Failed to create embedding function: {e}")
|
356
|
-
# Return a basic dummy function as fallback
|
357
|
-
class BasicDummyEmbeddingFunction:
|
358
|
-
def encode(self, sentences, **kwargs):
|
359
|
-
import numpy as np
|
360
|
-
return np.random.rand(len(sentences), 384)
|
361
|
-
|
362
|
-
return BasicDummyEmbeddingFunction()
|
281
|
+
return self.adapter.get_unique_values()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: thoth_dbmanager
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.3
|
4
4
|
Summary: A Python library for managing SQL databases with support for multiple database types, LSH-based similarity search, and a modern plugin architecture.
|
5
5
|
Author-email: Marco Pancotti <mp@tylconsulting.it>
|
6
6
|
Project-URL: Homepage, https://github.com/mptyl/thoth_dbmanager
|
@@ -26,7 +26,6 @@ Requires-Dist: datasketch>=1.5.0
|
|
26
26
|
Requires-Dist: tqdm>=4.60.0
|
27
27
|
Requires-Dist: SQLAlchemy>=1.4.0
|
28
28
|
Requires-Dist: pydantic>=2.0.0
|
29
|
-
Requires-Dist: pandas>=1.3.0
|
30
29
|
Requires-Dist: requests>=2.25.0
|
31
30
|
Provides-Extra: postgresql
|
32
31
|
Requires-Dist: psycopg2-binary>=2.9.0; extra == "postgresql"
|
@@ -35,15 +34,10 @@ Requires-Dist: mariadb>=1.1.0; extra == "mariadb"
|
|
35
34
|
Provides-Extra: sqlserver
|
36
35
|
Requires-Dist: pyodbc>=4.0.0; extra == "sqlserver"
|
37
36
|
Provides-Extra: sqlite
|
38
|
-
Provides-Extra: embeddings
|
39
|
-
Requires-Dist: sentence-transformers>=2.0.0; extra == "embeddings"
|
40
|
-
Requires-Dist: numpy>=1.21.0; extra == "embeddings"
|
41
37
|
Provides-Extra: all
|
42
38
|
Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
|
43
39
|
Requires-Dist: mariadb>=1.1.0; extra == "all"
|
44
40
|
Requires-Dist: pyodbc>=4.0.0; extra == "all"
|
45
|
-
Requires-Dist: sentence-transformers>=2.0.0; extra == "all"
|
46
|
-
Requires-Dist: numpy>=1.21.0; extra == "all"
|
47
41
|
Provides-Extra: dev
|
48
42
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
49
43
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
@@ -9,7 +9,7 @@ thoth_dbmanager/adapters/sqlite.py,sha256=RTDszgnAtkE14LKFeoe9lBHgsqXqkmDk6jDCTm
|
|
9
9
|
thoth_dbmanager/adapters/sqlserver.py,sha256=V555kUH54Fb1Atow0BfvbSHmoSwGnrB_RJGn718VQSI,23880
|
10
10
|
thoth_dbmanager/core/__init__.py,sha256=FlqNW0GZNv1rnwNgyXGzveLqaw0Z90y5AKhR_1DvHBE,269
|
11
11
|
thoth_dbmanager/core/factory.py,sha256=84EeZYRoH7y7b19EFHqN4X0CSA6dv-0yxUmlX2zHETk,8840
|
12
|
-
thoth_dbmanager/core/interfaces.py,sha256=
|
12
|
+
thoth_dbmanager/core/interfaces.py,sha256=s6t-8w4QWu_4Dl654LAU2p3Ao34wjeNaGEsUOJwYHaM,9575
|
13
13
|
thoth_dbmanager/core/registry.py,sha256=url4qpQMoMw4rDrdAAvV6L7-NdO4z86xSJPSwTH_l5g,8624
|
14
14
|
thoth_dbmanager/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
thoth_dbmanager/helpers/multi_db_generator.py,sha256=frN0SZtWAfeojoJFLs4XLR3ri6h9pHYc-2O4aLAOlbo,23238
|
@@ -26,8 +26,8 @@ thoth_dbmanager/plugins/mariadb.py,sha256=ElYa4Rexwrofcjcs0UQKan8fZpbU6-n9zghYR9
|
|
26
26
|
thoth_dbmanager/plugins/postgresql.py,sha256=pI1W9oHpQty8tHMoEDcsOT-Msv6S4aoFcArOGFxLR7Q,5518
|
27
27
|
thoth_dbmanager/plugins/sqlite.py,sha256=gkgZ6-Vjkab0IP3ffHOg4bbpDHsjO_N4DesUnSDNAmQ,8857
|
28
28
|
thoth_dbmanager/plugins/sqlserver.py,sha256=mMb3F5FmSWV02FZwj-Ult-2TjuyeVA4Fl1iME1dbgLU,5289
|
29
|
-
thoth_dbmanager-0.5.
|
30
|
-
thoth_dbmanager-0.5.
|
31
|
-
thoth_dbmanager-0.5.
|
32
|
-
thoth_dbmanager-0.5.
|
33
|
-
thoth_dbmanager-0.5.
|
29
|
+
thoth_dbmanager-0.5.3.dist-info/licenses/LICENSE,sha256=81-BOzGgwtY1XdYfkwMQB87AkOGXI9OMq0kjNcZA4UE,1071
|
30
|
+
thoth_dbmanager-0.5.3.dist-info/METADATA,sha256=ex4_W1vKNmcoFo0ZDHa4Hq-uaoO2YM6T_2a0VvdChvw,14752
|
31
|
+
thoth_dbmanager-0.5.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
32
|
+
thoth_dbmanager-0.5.3.dist-info/top_level.txt,sha256=b9ttxm9RUc0KUCASEKRx6FqoREYJ1-KZWSpNuaM0uQ4,16
|
33
|
+
thoth_dbmanager-0.5.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|