linkml-store 0.1.8__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.

@@ -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.8
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"
@@ -28,6 +29,7 @@ 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"
30
31
  Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
32
+ Requires-Dist: jsonlines (>=4.0.0,<5.0.0)
31
33
  Requires-Dist: linkml ; extra == "validation"
32
34
  Requires-Dist: linkml-runtime (>=1.7.5,<2.0.0)
33
35
  Requires-Dist: linkml_map ; extra == "map"
@@ -35,6 +37,7 @@ Requires-Dist: llm ; extra == "llm"
35
37
  Requires-Dist: matplotlib ; extra == "analytics"
36
38
  Requires-Dist: pandas (>=2.2.1) ; extra == "analytics"
37
39
  Requires-Dist: plotly ; extra == "analytics"
40
+ Requires-Dist: pyarrow ; extra == "pyarrow"
38
41
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
39
42
  Requires-Dist: pymongo ; extra == "mongodb"
40
43
  Requires-Dist: pystow (>=0.5.4,<0.6.0)
@@ -1,32 +1,33 @@
1
1
  linkml_store/__init__.py,sha256=jlU6WOUAn8cKIhzbTULmBTWpW9gZdEt7q_RI6KZN1bY,118
2
2
  linkml_store/api/__init__.py,sha256=3CelcFEFz0y3MkQAzhQ9JxHIt1zFk6nYZxSmYTo8YZE,226
3
- linkml_store/api/client.py,sha256=0Cs_0xW3NDUI6UJFtVvWd_XsGVLryMyh1SPrQhH4taU,8474
4
- linkml_store/api/collection.py,sha256=Nxauj22Vh38RaT6Hhwyn5j1_SXoHDf-EaoIy1osnIKo,24010
3
+ linkml_store/api/client.py,sha256=YGji1WJp9j3W0yTqSbcPHmz7jjUXalnQXeWvJLyQNyE,8592
4
+ linkml_store/api/collection.py,sha256=7ZPSs8LnmPI_-dYkZoTM87BE2gglRnU2p4XQhv4DYuU,27470
5
5
  linkml_store/api/config.py,sha256=VTtv42Vgnn3vKEERIOrtXjQDz4YHTJnm5pvvUnshqyA,3573
6
- linkml_store/api/database.py,sha256=OASaP8lbGIIJnrjTDDHq4ROzKrND8cizHauKMNFZaNo,24876
6
+ linkml_store/api/database.py,sha256=9H-bj4_v_iJ5iQm_uaoR4_LefZknmbod--tOqD5mYmE,25730
7
7
  linkml_store/api/queries.py,sha256=w0qnNeCH6pC9WTGoEQYd300MF6o0G3atz2YxN3WecAs,2028
8
8
  linkml_store/api/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  linkml_store/api/stores/chromadb/__init__.py,sha256=e9BkOPuPnVQKA5PRKDulag59yGNHDP3U2_DnPSrFAKM,132
10
10
  linkml_store/api/stores/chromadb/chromadb_collection.py,sha256=RQUZx5oeotkzNihg-dlSevkiTiKY1d9x0bS63HF80W4,4270
11
11
  linkml_store/api/stores/chromadb/chromadb_database.py,sha256=dZA3LQE8-ZMhJQOzsUFyxehnKpFF7adR182aggfkaFY,3205
12
12
  linkml_store/api/stores/duckdb/__init__.py,sha256=rbQSDgNg-fdvi6-pHGYkJTST4p1qXUZBf9sFSsO3KPk,387
13
- linkml_store/api/stores/duckdb/duckdb_collection.py,sha256=poKh6g9-sXA8Wl6B9-mxJqk9biJ0IK7_xz2iGG_U79g,6060
13
+ linkml_store/api/stores/duckdb/duckdb_collection.py,sha256=PGzYdLx1bv5NK0TvEIKpNSQ7f6yiY3vylt_V_KFqqWo,6097
14
14
  linkml_store/api/stores/duckdb/duckdb_database.py,sha256=xk2bSeSWofGtPgp56168-4KIX4wJTtm9XgUtiBQOuNA,7194
15
15
  linkml_store/api/stores/duckdb/mappings.py,sha256=tDce3W1Apwammhf4LS6cRJ0m4NiJ0eB7vOI_4U5ETY8,148
16
- linkml_store/api/stores/filesystem/__init__.py,sha256=rbQSDgNg-fdvi6-pHGYkJTST4p1qXUZBf9sFSsO3KPk,387
17
- linkml_store/api/stores/filesystem/filesystem_collection.py,sha256=vIM8y71YNdjBsSUl02wXMdl6EY3QYjMCT5MzRI7pO04,5905
18
- linkml_store/api/stores/filesystem/filesystem_database.py,sha256=d-394QD565bHqJ2FzZjMZrFw8HY-v7k8bE2cxy24k-8,1098
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
19
  linkml_store/api/stores/hdf5/__init__.py,sha256=l4cIh3v7P0nPbwGIsfuCMD_serQ8q8c7iuUA9W2Jb4o,97
20
20
  linkml_store/api/stores/hdf5/hdf5_collection.py,sha256=mnpLMYehn3PuaIjp2dXrIWu8jh-bdQ84X2Ku83jMdEY,3805
21
21
  linkml_store/api/stores/hdf5/hdf5_database.py,sha256=EZbjrpaqiNDEFvoD5dZNcGBXA8z6HRNL81emueTZWNw,2714
22
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=wMaZb9B3PZ5lCDfj8kOrVnUJQ0O0lrP4PrcpEwAhEOI,4698
24
- linkml_store/api/stores/mongodb/mongodb_database.py,sha256=QAdTi8XYLsdrEvEUUKb9qolCPeEXgfecTQ1bz9GCWDg,3670
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
25
  linkml_store/api/stores/solr/__init__.py,sha256=aAfnaN9mZOiIDj1NYz0Ll9fZF2gG7UU_vhP4SNCL2d8,36
26
26
  linkml_store/api/stores/solr/solr_collection.py,sha256=8GmxErlWFOO0NnJiYo1Q7hegxCsfxaWc79eN7Jn02gA,4723
27
27
  linkml_store/api/stores/solr/solr_database.py,sha256=TFjqbY7jAkdrhAchbNg0E-mChSP7ogNwFExslbvX7Yo,2877
28
28
  linkml_store/api/stores/solr/solr_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- linkml_store/cli.py,sha256=oMz13ndmFm3QCxg1ILPo0mlwtMgfd-tERXmW2LM7jzU,15871
29
+ linkml_store/api/types.py,sha256=3aIQtDFMvsSmjuN5qrR2vNK5sHa6yzD_rEOPA6tHwvg,176
30
+ linkml_store/cli.py,sha256=HIPG-LZDB9Mgue6_KKDiaUpNO90chUCnYOnLbUdFogk,19098
30
31
  linkml_store/constants.py,sha256=x4ZmDsfE9rZcL5WpA93uTKrRWzCD6GodYXviVzIvR38,112
31
32
  linkml_store/index/__init__.py,sha256=dVrYtsFu7tEsMDaPMIc2LjsM76HoAKQz4uO8roR18Zw,993
32
33
  linkml_store/index/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -34,12 +35,15 @@ linkml_store/index/implementations/llm_indexer.py,sha256=04cz-UaKlV7WTubHVr0v94X
34
35
  linkml_store/index/implementations/simple_indexer.py,sha256=KnkFJtXTHnwjhD_D6ZK2rFhBID1dgCedcOVPEWAY2NU,1282
35
36
  linkml_store/index/indexer.py,sha256=C64J3-2oCqYXCouNQ4fxw4g7f7Nl2L0WwFf-zrcsogo,4491
36
37
  linkml_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
- linkml_store/utils/format_utils.py,sha256=18qmWVUr6ceOuvPROcNZ7mCBXpZyj3_cy1gNcpIqZC4,4352
38
+ linkml_store/utils/change_utils.py,sha256=O2rvSvgTKB60reLLz9mX5OWykAA_m93bwnUh5ZWa0EY,471
39
+ linkml_store/utils/format_utils.py,sha256=I6rYInqdrOSWK_ydtlgYJ8ArPGP-Q8iQoD4nzrp-ajM,6568
38
40
  linkml_store/utils/io.py,sha256=JHUrWDtlZC2jtN_PQZ4ypdGIyYlftZEN3JaCvEPs44w,884
39
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
40
44
  linkml_store/utils/sql_utils.py,sha256=TeAhAHXi1GA0f2UVrxbzStwe49Q7fN0mu5WZyfDk-s8,5651
41
- linkml_store-0.1.8.dist-info/LICENSE,sha256=77mDOslUnalYnuq9xQYZKtIoNEzcH9mIjvWHOKjamnE,1086
42
- linkml_store-0.1.8.dist-info/METADATA,sha256=EN8yT2duWya5DiUQKHx99XAjCqJfYOw2_XTQiltTLzo,2311
43
- linkml_store-0.1.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
44
- linkml_store-0.1.8.dist-info/entry_points.txt,sha256=6ema3OkAkUK0ux8roEeRPtSW_Tylend5BABf-xRsZiU,53
45
- linkml_store-0.1.8.dist-info/RECORD,,
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,,