linkml-store 0.1.7__py3-none-any.whl → 0.1.9__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.

Potentially problematic release.


This version of linkml-store might be problematic. Click here for more details.

Files changed (32) hide show
  1. linkml_store/api/client.py +32 -5
  2. linkml_store/api/collection.py +276 -27
  3. linkml_store/api/config.py +6 -2
  4. linkml_store/api/database.py +264 -21
  5. linkml_store/api/stores/chromadb/__init__.py +5 -1
  6. linkml_store/api/stores/duckdb/__init__.py +9 -0
  7. linkml_store/api/stores/duckdb/duckdb_collection.py +7 -4
  8. linkml_store/api/stores/duckdb/duckdb_database.py +19 -5
  9. linkml_store/api/stores/duckdb/mappings.py +1 -0
  10. linkml_store/api/stores/filesystem/__init__.py +15 -0
  11. linkml_store/api/stores/filesystem/filesystem_collection.py +177 -0
  12. linkml_store/api/stores/filesystem/filesystem_database.py +72 -0
  13. linkml_store/api/stores/hdf5/__init__.py +7 -0
  14. linkml_store/api/stores/mongodb/__init__.py +25 -0
  15. linkml_store/api/stores/mongodb/mongodb_collection.py +31 -10
  16. linkml_store/api/stores/mongodb/mongodb_database.py +13 -2
  17. linkml_store/api/types.py +4 -0
  18. linkml_store/cli.py +150 -15
  19. linkml_store/index/__init__.py +6 -2
  20. linkml_store/index/implementations/llm_indexer.py +83 -5
  21. linkml_store/index/implementations/simple_indexer.py +2 -2
  22. linkml_store/index/indexer.py +32 -8
  23. linkml_store/utils/change_utils.py +17 -0
  24. linkml_store/utils/format_utils.py +139 -8
  25. linkml_store/utils/patch_utils.py +126 -0
  26. linkml_store/utils/query_utils.py +89 -0
  27. {linkml_store-0.1.7.dist-info → linkml_store-0.1.9.dist-info}/METADATA +7 -1
  28. linkml_store-0.1.9.dist-info/RECORD +49 -0
  29. linkml_store-0.1.7.dist-info/RECORD +0 -42
  30. {linkml_store-0.1.7.dist-info → linkml_store-0.1.9.dist-info}/LICENSE +0 -0
  31. {linkml_store-0.1.7.dist-info → linkml_store-0.1.9.dist-info}/WHEEL +0 -0
  32. {linkml_store-0.1.7.dist-info → linkml_store-0.1.9.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,89 @@
1
+ import operator
2
+ from typing import Any, Callable, Dict
3
+
4
+ MONGO_OPERATORS = {
5
+ "$eq": operator.eq,
6
+ "$ne": operator.ne,
7
+ "$gt": operator.gt,
8
+ "$gte": operator.ge,
9
+ "$lt": operator.lt,
10
+ "$lte": operator.le,
11
+ "$in": lambda a, b: any(x in b for x in (a if isinstance(a, list) else [a])),
12
+ "$nin": lambda a, b: all(x not in b for x in (a if isinstance(a, list) else [a])),
13
+ }
14
+
15
+
16
+ def mongo_query_to_match_function(where: Dict[str, Any]) -> Callable[[Dict[str, Any]], bool]:
17
+ """
18
+ Convert a MongoDB-style query to a matching function.
19
+
20
+ >>> query = {"name": "foo", "age": {"$gt": 25}}
21
+ >>> matcher = mongo_query_to_match_function(query)
22
+ >>> matcher({"name": "foo", "age": 30})
23
+ True
24
+ >>> matcher({"name": "foo", "age": 20})
25
+ False
26
+ >>> matcher({"name": "bar", "age": 30})
27
+ False
28
+
29
+ >>> nested_query = {"nested.job": "engineer", "skills": {"$in": ["python", "mongodb"]}}
30
+ >>> nested_matcher = mongo_query_to_match_function(nested_query)
31
+ >>> nested_matcher({"nested": {"job": "engineer"}, "skills": ["python", "javascript"]})
32
+ True
33
+ >>> nested_matcher({"nested": {"job": "designer"}, "skills": ["python", "mongodb"]})
34
+ False
35
+ >>> nested_matcher({"nested": {"job": "engineer"}, "skills": ["java", "c++"]})
36
+ False
37
+
38
+ >>> complex_query = {"name": "foo", "age": {"$gte": 25, "$lt": 40}, "nested.salary": {"$gt": 50000}}
39
+ >>> complex_matcher = mongo_query_to_match_function(complex_query)
40
+ >>> complex_matcher({"name": "foo", "age": 30, "nested": {"salary": 60000}})
41
+ True
42
+ >>> complex_matcher({"name": "foo", "age": 45, "nested": {"salary": 70000}})
43
+ False
44
+ >>> complex_matcher({"name": "foo", "age": 35, "nested": {"salary": 40000}})
45
+ False
46
+
47
+ >>> invalid_query = {"age": {"$invalid": 25}}
48
+ >>> invalid_matcher = mongo_query_to_match_function(invalid_query)
49
+ >>> invalid_matcher({"age": 30})
50
+ Traceback (most recent call last):
51
+ ...
52
+ ValueError: Unsupported operator: $invalid
53
+ """
54
+ if where is None:
55
+ where = {}
56
+
57
+ def matches(obj: Dict[str, Any]) -> bool:
58
+ def check_condition(key: str, condition: Any) -> bool:
59
+ if isinstance(condition, dict) and any(k.startswith("$") for k in condition.keys()):
60
+ for op, value in condition.items():
61
+ if op in MONGO_OPERATORS:
62
+ if not MONGO_OPERATORS[op](get_nested_value(obj, key), value):
63
+ return False
64
+ else:
65
+ raise ValueError(f"Unsupported operator: {op}")
66
+ elif isinstance(condition, dict):
67
+ return check_nested_condition(get_nested_value(obj, key), condition)
68
+ else:
69
+ return get_nested_value(obj, key) == condition
70
+ return True
71
+
72
+ def check_nested_condition(nested_obj: Dict[str, Any], nested_condition: Dict[str, Any]) -> bool:
73
+ for k, v in nested_condition.items():
74
+ if not check_condition(k, v):
75
+ return False
76
+ return True
77
+
78
+ def get_nested_value(obj: Dict[str, Any], key: str) -> Any:
79
+ parts = key.split(".")
80
+ for part in parts:
81
+ if isinstance(obj, dict):
82
+ obj = obj.get(part)
83
+ else:
84
+ return None
85
+ return obj
86
+
87
+ return all(check_condition(k, v) for k, v in where.items())
88
+
89
+ return matches
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkml-store
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: linkml-store
5
5
  License: MIT
6
6
  Author: Author 1
@@ -19,6 +19,7 @@ Provides-Extra: h5py
19
19
  Provides-Extra: llm
20
20
  Provides-Extra: map
21
21
  Provides-Extra: mongodb
22
+ Provides-Extra: pyarrow
22
23
  Provides-Extra: tests
23
24
  Provides-Extra: validation
24
25
  Requires-Dist: black (>=24.0.0) ; extra == "tests"
@@ -27,6 +28,8 @@ Requires-Dist: click
27
28
  Requires-Dist: duckdb (>=0.10.1,<0.11.0)
28
29
  Requires-Dist: duckdb-engine (>=0.11.2)
29
30
  Requires-Dist: h5py ; extra == "h5py"
31
+ Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
32
+ Requires-Dist: jsonlines (>=4.0.0,<5.0.0)
30
33
  Requires-Dist: linkml ; extra == "validation"
31
34
  Requires-Dist: linkml-runtime (>=1.7.5,<2.0.0)
32
35
  Requires-Dist: linkml_map ; extra == "map"
@@ -34,6 +37,7 @@ Requires-Dist: llm ; extra == "llm"
34
37
  Requires-Dist: matplotlib ; extra == "analytics"
35
38
  Requires-Dist: pandas (>=2.2.1) ; extra == "analytics"
36
39
  Requires-Dist: plotly ; extra == "analytics"
40
+ Requires-Dist: pyarrow ; extra == "pyarrow"
37
41
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
38
42
  Requires-Dist: pymongo ; extra == "mongodb"
39
43
  Requires-Dist: pystow (>=0.5.4,<0.6.0)
@@ -53,3 +57,5 @@ There is also experimental support for vector-based indexing using OpenAI test e
53
57
  The goals of this project are to provide high level access to data stored in heterogeneous databases,
54
58
  with optional schema management using LinkML.
55
59
 
60
+ See [these slides](https://docs.google.com/presentation/d/e/2PACX-1vSgtWUNUW0qNO_ZhMAGQ6fYhlXZJjBNMYT0OiZz8DDx8oj7iG9KofRs6SeaMXBBOICGknoyMG2zaHnm/embed?start=false&loop=false&delayms=3000) for more details
61
+
@@ -0,0 +1,49 @@
1
+ linkml_store/__init__.py,sha256=jlU6WOUAn8cKIhzbTULmBTWpW9gZdEt7q_RI6KZN1bY,118
2
+ linkml_store/api/__init__.py,sha256=3CelcFEFz0y3MkQAzhQ9JxHIt1zFk6nYZxSmYTo8YZE,226
3
+ linkml_store/api/client.py,sha256=YGji1WJp9j3W0yTqSbcPHmz7jjUXalnQXeWvJLyQNyE,8592
4
+ linkml_store/api/collection.py,sha256=7ZPSs8LnmPI_-dYkZoTM87BE2gglRnU2p4XQhv4DYuU,27470
5
+ linkml_store/api/config.py,sha256=VTtv42Vgnn3vKEERIOrtXjQDz4YHTJnm5pvvUnshqyA,3573
6
+ linkml_store/api/database.py,sha256=9H-bj4_v_iJ5iQm_uaoR4_LefZknmbod--tOqD5mYmE,25730
7
+ linkml_store/api/queries.py,sha256=w0qnNeCH6pC9WTGoEQYd300MF6o0G3atz2YxN3WecAs,2028
8
+ linkml_store/api/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ linkml_store/api/stores/chromadb/__init__.py,sha256=e9BkOPuPnVQKA5PRKDulag59yGNHDP3U2_DnPSrFAKM,132
10
+ linkml_store/api/stores/chromadb/chromadb_collection.py,sha256=RQUZx5oeotkzNihg-dlSevkiTiKY1d9x0bS63HF80W4,4270
11
+ linkml_store/api/stores/chromadb/chromadb_database.py,sha256=dZA3LQE8-ZMhJQOzsUFyxehnKpFF7adR182aggfkaFY,3205
12
+ linkml_store/api/stores/duckdb/__init__.py,sha256=rbQSDgNg-fdvi6-pHGYkJTST4p1qXUZBf9sFSsO3KPk,387
13
+ linkml_store/api/stores/duckdb/duckdb_collection.py,sha256=PGzYdLx1bv5NK0TvEIKpNSQ7f6yiY3vylt_V_KFqqWo,6097
14
+ linkml_store/api/stores/duckdb/duckdb_database.py,sha256=xk2bSeSWofGtPgp56168-4KIX4wJTtm9XgUtiBQOuNA,7194
15
+ linkml_store/api/stores/duckdb/mappings.py,sha256=tDce3W1Apwammhf4LS6cRJ0m4NiJ0eB7vOI_4U5ETY8,148
16
+ linkml_store/api/stores/filesystem/__init__.py,sha256=KjvCjdttwqMHNeGyL-gr59zRz0--HFEWWUNNCJ5hITs,347
17
+ linkml_store/api/stores/filesystem/filesystem_collection.py,sha256=5WmWSIE22UnKm8UkfcpTinfnpgtv_FXcYTlT5vF2yKA,6321
18
+ linkml_store/api/stores/filesystem/filesystem_database.py,sha256=HnHIv1aVtTiFSPY09s40QrMNhn_e-IKCYRXQk1S25Ak,2554
19
+ linkml_store/api/stores/hdf5/__init__.py,sha256=l4cIh3v7P0nPbwGIsfuCMD_serQ8q8c7iuUA9W2Jb4o,97
20
+ linkml_store/api/stores/hdf5/hdf5_collection.py,sha256=mnpLMYehn3PuaIjp2dXrIWu8jh-bdQ84X2Ku83jMdEY,3805
21
+ linkml_store/api/stores/hdf5/hdf5_database.py,sha256=EZbjrpaqiNDEFvoD5dZNcGBXA8z6HRNL81emueTZWNw,2714
22
+ linkml_store/api/stores/mongodb/__init__.py,sha256=OSFCr7RQlDEe-O-Y0P_i912oAMK-L3pC7Cnj7sxlwAk,510
23
+ linkml_store/api/stores/mongodb/mongodb_collection.py,sha256=CCsU1omeWXdb8Wzjt9DlmryBNgbfVbiTNtAJNrO-odI,4970
24
+ linkml_store/api/stores/mongodb/mongodb_database.py,sha256=DKO-lMQzHyf-szVgH4tsP0UA68dlCFGv-oyVuXOIUd0,4003
25
+ linkml_store/api/stores/solr/__init__.py,sha256=aAfnaN9mZOiIDj1NYz0Ll9fZF2gG7UU_vhP4SNCL2d8,36
26
+ linkml_store/api/stores/solr/solr_collection.py,sha256=8GmxErlWFOO0NnJiYo1Q7hegxCsfxaWc79eN7Jn02gA,4723
27
+ linkml_store/api/stores/solr/solr_database.py,sha256=TFjqbY7jAkdrhAchbNg0E-mChSP7ogNwFExslbvX7Yo,2877
28
+ linkml_store/api/stores/solr/solr_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ linkml_store/api/types.py,sha256=3aIQtDFMvsSmjuN5qrR2vNK5sHa6yzD_rEOPA6tHwvg,176
30
+ linkml_store/cli.py,sha256=HIPG-LZDB9Mgue6_KKDiaUpNO90chUCnYOnLbUdFogk,19098
31
+ linkml_store/constants.py,sha256=x4ZmDsfE9rZcL5WpA93uTKrRWzCD6GodYXviVzIvR38,112
32
+ linkml_store/index/__init__.py,sha256=dVrYtsFu7tEsMDaPMIc2LjsM76HoAKQz4uO8roR18Zw,993
33
+ linkml_store/index/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
+ linkml_store/index/implementations/llm_indexer.py,sha256=04cz-UaKlV7WTubHVr0v94XfqbN0N2Nnoud9Z7nETH4,4779
35
+ linkml_store/index/implementations/simple_indexer.py,sha256=KnkFJtXTHnwjhD_D6ZK2rFhBID1dgCedcOVPEWAY2NU,1282
36
+ linkml_store/index/indexer.py,sha256=C64J3-2oCqYXCouNQ4fxw4g7f7Nl2L0WwFf-zrcsogo,4491
37
+ linkml_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ linkml_store/utils/change_utils.py,sha256=O2rvSvgTKB60reLLz9mX5OWykAA_m93bwnUh5ZWa0EY,471
39
+ linkml_store/utils/format_utils.py,sha256=I6rYInqdrOSWK_ydtlgYJ8ArPGP-Q8iQoD4nzrp-ajM,6568
40
+ linkml_store/utils/io.py,sha256=JHUrWDtlZC2jtN_PQZ4ypdGIyYlftZEN3JaCvEPs44w,884
41
+ linkml_store/utils/object_utils.py,sha256=is6T2gruvVKvWD5ZntcAl6Qi3L154FObEho_b_crTuE,2539
42
+ linkml_store/utils/patch_utils.py,sha256=q-h_v68okyruzdPTEHCe0WubbQHKpi1qy5bJ9vFWDo8,4823
43
+ linkml_store/utils/query_utils.py,sha256=HWt46BsGWoIGiNBTtvpXGY6onPRWsQky6eu_9cYqbvo,3440
44
+ linkml_store/utils/sql_utils.py,sha256=TeAhAHXi1GA0f2UVrxbzStwe49Q7fN0mu5WZyfDk-s8,5651
45
+ linkml_store-0.1.9.dist-info/LICENSE,sha256=77mDOslUnalYnuq9xQYZKtIoNEzcH9mIjvWHOKjamnE,1086
46
+ linkml_store-0.1.9.dist-info/METADATA,sha256=6TNxC0HDbb4CGFH1GhDfU1BryD2uGFCi5cRJUj4MZQ8,2421
47
+ linkml_store-0.1.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
48
+ linkml_store-0.1.9.dist-info/entry_points.txt,sha256=6ema3OkAkUK0ux8roEeRPtSW_Tylend5BABf-xRsZiU,53
49
+ linkml_store-0.1.9.dist-info/RECORD,,
@@ -1,42 +0,0 @@
1
- linkml_store/__init__.py,sha256=jlU6WOUAn8cKIhzbTULmBTWpW9gZdEt7q_RI6KZN1bY,118
2
- linkml_store/api/__init__.py,sha256=3CelcFEFz0y3MkQAzhQ9JxHIt1zFk6nYZxSmYTo8YZE,226
3
- linkml_store/api/client.py,sha256=fN6iQONazbSH_FJIPqHzISKoHRC0vi_XudaFVX01l-s,7709
4
- linkml_store/api/collection.py,sha256=rm-C-GZ6leib_uEDPz-a0exVyN5pD08E8cZPsXmCG9I,18460
5
- linkml_store/api/config.py,sha256=9raqXrZ-4U-6DPI2Dnc3O9UVdO91lOAPjdtS82zALSg,3409
6
- linkml_store/api/database.py,sha256=TYq2JQFxV7ZtaRnR-o4Le984mna3yXynrUm6r9pGVsE,17098
7
- linkml_store/api/queries.py,sha256=w0qnNeCH6pC9WTGoEQYd300MF6o0G3atz2YxN3WecAs,2028
8
- linkml_store/api/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- linkml_store/api/stores/chromadb/__init__.py,sha256=uqFsViPH0ckR-mjrttTBNEVu-rp7ub-Za7Muw3BZK8A,46
10
- linkml_store/api/stores/chromadb/chromadb_collection.py,sha256=RQUZx5oeotkzNihg-dlSevkiTiKY1d9x0bS63HF80W4,4270
11
- linkml_store/api/stores/chromadb/chromadb_database.py,sha256=dZA3LQE8-ZMhJQOzsUFyxehnKpFF7adR182aggfkaFY,3205
12
- linkml_store/api/stores/duckdb/__init__.py,sha256=qZExreYUUQmKDZKN-fiLH1DfTYWojUkmkcT2LzrdMH8,213
13
- linkml_store/api/stores/duckdb/duckdb_collection.py,sha256=WLo9q67pRQAhz6ErAEAxTRAGOe77FQ0meHi2schgAeo,5854
14
- linkml_store/api/stores/duckdb/duckdb_database.py,sha256=99jx3B0498Glqbm5QvfK3sIbluN-wzJ8Kqc0teh2MM4,6663
15
- linkml_store/api/stores/duckdb/mappings.py,sha256=S4MWetLpQcxOwwedXrZTqazxdaHIQXXbq4VRq9Ok4B4,123
16
- linkml_store/api/stores/hdf5/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- linkml_store/api/stores/hdf5/hdf5_collection.py,sha256=mnpLMYehn3PuaIjp2dXrIWu8jh-bdQ84X2Ku83jMdEY,3805
18
- linkml_store/api/stores/hdf5/hdf5_database.py,sha256=EZbjrpaqiNDEFvoD5dZNcGBXA8z6HRNL81emueTZWNw,2714
19
- linkml_store/api/stores/mongodb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- linkml_store/api/stores/mongodb/mongodb_collection.py,sha256=sQZa59A0NsW13k6kKPSyo8FZR_h7ebm6FMXfu1NAvYs,4111
21
- linkml_store/api/stores/mongodb/mongodb_database.py,sha256=QAdTi8XYLsdrEvEUUKb9qolCPeEXgfecTQ1bz9GCWDg,3670
22
- linkml_store/api/stores/solr/__init__.py,sha256=aAfnaN9mZOiIDj1NYz0Ll9fZF2gG7UU_vhP4SNCL2d8,36
23
- linkml_store/api/stores/solr/solr_collection.py,sha256=8GmxErlWFOO0NnJiYo1Q7hegxCsfxaWc79eN7Jn02gA,4723
24
- linkml_store/api/stores/solr/solr_database.py,sha256=TFjqbY7jAkdrhAchbNg0E-mChSP7ogNwFExslbvX7Yo,2877
25
- linkml_store/api/stores/solr/solr_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- linkml_store/cli.py,sha256=r6UggDS2iFC5yIhBECwn-5aKmI38SHuYIJ5TEA0-CeM,13667
27
- linkml_store/constants.py,sha256=x4ZmDsfE9rZcL5WpA93uTKrRWzCD6GodYXviVzIvR38,112
28
- linkml_store/index/__init__.py,sha256=k3fq2gzhoBv3_QEu4zMbEEoc0tEOUOcrEjKQVvWfASs,881
29
- linkml_store/index/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- linkml_store/index/implementations/llm_indexer.py,sha256=LymhrQIeik0Qe8P2b3y2Lg7Y0P0OJ8_WjFwv-hbULj8,1069
31
- linkml_store/index/implementations/simple_indexer.py,sha256=CwUBb_GO_JUd-f-KW6R4i26PUV251BNTZ2cE6Qo1fH4,1251
32
- linkml_store/index/indexer.py,sha256=d_QEwJ5qEx2pkNR-QJ9hAn0pyJbhZIIT83GBFKhJA6I,3462
33
- linkml_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- linkml_store/utils/format_utils.py,sha256=lTrNVEywRziCjcrEeUC3hpZZo8yDQYgG-qBanQhBYrI,3081
35
- linkml_store/utils/io.py,sha256=JHUrWDtlZC2jtN_PQZ4ypdGIyYlftZEN3JaCvEPs44w,884
36
- linkml_store/utils/object_utils.py,sha256=is6T2gruvVKvWD5ZntcAl6Qi3L154FObEho_b_crTuE,2539
37
- linkml_store/utils/sql_utils.py,sha256=TeAhAHXi1GA0f2UVrxbzStwe49Q7fN0mu5WZyfDk-s8,5651
38
- linkml_store-0.1.7.dist-info/LICENSE,sha256=77mDOslUnalYnuq9xQYZKtIoNEzcH9mIjvWHOKjamnE,1086
39
- linkml_store-0.1.7.dist-info/METADATA,sha256=aby4QxnuE6G00g38tjZXH4B4-U7qfJKGtJtIx0OH5ew,2064
40
- linkml_store-0.1.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
41
- linkml_store-0.1.7.dist-info/entry_points.txt,sha256=6ema3OkAkUK0ux8roEeRPtSW_Tylend5BABf-xRsZiU,53
42
- linkml_store-0.1.7.dist-info/RECORD,,