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

@@ -4,13 +4,17 @@ import sys
4
4
  from enum import Enum
5
5
  from io import StringIO
6
6
  from pathlib import Path
7
- from typing import Any, Dict, List, Union
7
+ from typing import Any, Dict, List, Optional, Union
8
8
 
9
9
  import yaml
10
10
  from pydantic import BaseModel
11
11
 
12
12
 
13
13
  class Format(Enum):
14
+ """
15
+ Supported generic file formats for loading and rendering objects.
16
+ """
17
+
14
18
  JSON = "json"
15
19
  JSONL = "jsonl"
16
20
  YAML = "yaml"
@@ -22,6 +26,10 @@ def load_objects(file_path: Union[str, Path], format: Union[Format, str] = None)
22
26
  """
23
27
  Load objects from a file in JSON, JSONLines, YAML, CSV, or TSV format.
24
28
 
29
+ >>> load_objects("tests/input/test_data/data.csv")
30
+ [{'id': '1', 'name': 'John', 'age': '30'},
31
+ {'id': '2', 'name': 'Alice', 'age': '25'}, {'id': '3', 'name': 'Bob', 'age': '35'}]
32
+
25
33
  :param file_path: The path to the file.
26
34
  :param format: The format of the file. Can be a Format enum or a string value.
27
35
  :return: A list of dictionaries representing the loaded objects.
@@ -57,10 +65,23 @@ def load_objects(file_path: Union[str, Path], format: Union[Format, str] = None)
57
65
  return objs
58
66
 
59
67
 
60
- def render_output(data: List[Dict[str, Any]], format: Union[Format, str] = Format.YAML) -> str:
68
+ def render_output(data: Union[List[Dict[str, Any]], Dict[str, Any]], format: Union[Format, str] = Format.YAML) -> str:
61
69
  """
62
70
  Render output data in JSON, JSONLines, YAML, CSV, or TSV format.
63
71
 
72
+ >>> print(render_output([{"a": 1, "b": 2}, {"a": 3, "b": 4}], Format.JSON))
73
+ [
74
+ {
75
+ "a": 1,
76
+ "b": 2
77
+ },
78
+ {
79
+ "a": 3,
80
+ "b": 4
81
+ }
82
+ ]
83
+
84
+
64
85
  :param data: The data to be rendered.
65
86
  :param format: The desired output format. Can be a Format enum or a string value.
66
87
  :return: The rendered output as a string.
@@ -91,3 +112,32 @@ def render_output(data: List[Dict[str, Any]], format: Union[Format, str] = Forma
91
112
  return output.getvalue()
92
113
  else:
93
114
  raise ValueError(f"Unsupported output format: {format}")
115
+
116
+
117
+ def guess_format(path: str) -> Optional[Format]:
118
+ """
119
+ Guess the format of a file based on its extension.
120
+
121
+ >>> guess_format("data.json")
122
+ <Format.JSON: 'json'>
123
+ >>> guess_format("data.jsonl")
124
+ <Format.JSONL: 'jsonl'>
125
+ >>> guess_format("data.yaml")
126
+ <Format.YAML: 'yaml'>
127
+ >>> assert not guess_format("data")
128
+
129
+ :param path: The path to the file.
130
+ :return: The guessed format.
131
+ """
132
+ if path.endswith(".json"):
133
+ return Format.JSON
134
+ elif path.endswith(".jsonl"):
135
+ return Format.JSONL
136
+ elif path.endswith(".yaml") or path.endswith(".yml"):
137
+ return Format.YAML
138
+ elif path.endswith(".tsv"):
139
+ return Format.TSV
140
+ elif path.endswith(".csv"):
141
+ return Format.CSV
142
+ else:
143
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkml-store
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: linkml-store
5
5
  License: MIT
6
6
  Author: Author 1
@@ -27,6 +27,7 @@ Requires-Dist: click
27
27
  Requires-Dist: duckdb (>=0.10.1,<0.11.0)
28
28
  Requires-Dist: duckdb-engine (>=0.11.2)
29
29
  Requires-Dist: h5py ; extra == "h5py"
30
+ Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
30
31
  Requires-Dist: linkml ; extra == "validation"
31
32
  Requires-Dist: linkml-runtime (>=1.7.5,<2.0.0)
32
33
  Requires-Dist: linkml_map ; extra == "map"
@@ -53,3 +54,5 @@ There is also experimental support for vector-based indexing using OpenAI test e
53
54
  The goals of this project are to provide high level access to data stored in heterogeneous databases,
54
55
  with optional schema management using LinkML.
55
56
 
57
+ See [these slides](https://docs.google.com/presentation/d/e/2PACX-1vSgtWUNUW0qNO_ZhMAGQ6fYhlXZJjBNMYT0OiZz8DDx8oj7iG9KofRs6SeaMXBBOICGknoyMG2zaHnm/embed?start=false&loop=false&delayms=3000) for more details
58
+
@@ -0,0 +1,45 @@
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=0Cs_0xW3NDUI6UJFtVvWd_XsGVLryMyh1SPrQhH4taU,8474
4
+ linkml_store/api/collection.py,sha256=Nxauj22Vh38RaT6Hhwyn5j1_SXoHDf-EaoIy1osnIKo,24010
5
+ linkml_store/api/config.py,sha256=VTtv42Vgnn3vKEERIOrtXjQDz4YHTJnm5pvvUnshqyA,3573
6
+ linkml_store/api/database.py,sha256=OASaP8lbGIIJnrjTDDHq4ROzKrND8cizHauKMNFZaNo,24876
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=poKh6g9-sXA8Wl6B9-mxJqk9biJ0IK7_xz2iGG_U79g,6060
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=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
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=wMaZb9B3PZ5lCDfj8kOrVnUJQ0O0lrP4PrcpEwAhEOI,4698
24
+ linkml_store/api/stores/mongodb/mongodb_database.py,sha256=QAdTi8XYLsdrEvEUUKb9qolCPeEXgfecTQ1bz9GCWDg,3670
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/cli.py,sha256=oMz13ndmFm3QCxg1ILPo0mlwtMgfd-tERXmW2LM7jzU,15871
30
+ linkml_store/constants.py,sha256=x4ZmDsfE9rZcL5WpA93uTKrRWzCD6GodYXviVzIvR38,112
31
+ linkml_store/index/__init__.py,sha256=dVrYtsFu7tEsMDaPMIc2LjsM76HoAKQz4uO8roR18Zw,993
32
+ linkml_store/index/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ linkml_store/index/implementations/llm_indexer.py,sha256=04cz-UaKlV7WTubHVr0v94XfqbN0N2Nnoud9Z7nETH4,4779
34
+ linkml_store/index/implementations/simple_indexer.py,sha256=KnkFJtXTHnwjhD_D6ZK2rFhBID1dgCedcOVPEWAY2NU,1282
35
+ linkml_store/index/indexer.py,sha256=C64J3-2oCqYXCouNQ4fxw4g7f7Nl2L0WwFf-zrcsogo,4491
36
+ 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/io.py,sha256=JHUrWDtlZC2jtN_PQZ4ypdGIyYlftZEN3JaCvEPs44w,884
39
+ linkml_store/utils/object_utils.py,sha256=is6T2gruvVKvWD5ZntcAl6Qi3L154FObEho_b_crTuE,2539
40
+ 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,,
@@ -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,,