1111from .base import Link
1212
1313
14+ DEFAULT_VERSION = "v4"
15+
16+
1417class Collection :
1518 """
1619 A collection of metadata nodes that can be saved to
@@ -141,7 +144,7 @@ def save(self, path, individual_files=False, include_empty_properties=False):
141144 output_paths .append (file_path )
142145 return output_paths
143146
144- def load (self , * paths ):
147+ def load (self , * paths , version = DEFAULT_VERSION ):
145148 """
146149 Load openMINDS metadata from one or more JSON-LD files.
147150
@@ -152,6 +155,9 @@ def load(self, *paths):
152155 (but without descending into subdirectories)
153156
154157 2) one or more JSON-LD files, which will all be loaded.
158+
159+ By default, openMINDS v4 will be used.
160+ If the JSON-LD files use a different openMINDS version, specify it with the `version` argument.
155161 """
156162 if len (paths ) == 1 and os .path .isdir (paths [0 ]):
157163 data_dir = paths [0 ]
@@ -168,10 +174,6 @@ def load(self, *paths):
168174 with open (path , "r" ) as fp :
169175 data = json .load (fp )
170176 if "@graph" in data :
171- if data ["@context" ]["@vocab" ].startswith ("https://openminds.ebrains.eu/" ):
172- version = "v3"
173- else :
174- version = "latest"
175177 for item in data ["@graph" ]:
176178 if "@type" in item :
177179 cls = lookup_type (item ["@type" ], version = version )
@@ -245,4 +247,3 @@ def sort_nodes_for_upload(self):
245247 newly_sorted .append (node_id )
246248 unsorted -= set (newly_sorted )
247249 return [self .nodes [node_id ] for node_id in sorted ]
248-
0 commit comments