File tree Expand file tree Collapse file tree 6 files changed +12
-33
lines changed Expand file tree Collapse file tree 6 files changed +12
-33
lines changed Original file line number Diff line number Diff line change 11{
2- "version": "0.4.9post3 "
2+ "version": "0.4.9post4 "
33}
Original file line number Diff line number Diff line change @@ -106,8 +106,6 @@ def resolve_rdf_source(
106106 # source is bioimageio id or bioimageio nickname
107107 source = bioimageio_rdf_source
108108 elif re .fullmatch (DOI_REGEX , source ): # turn doi into url
109- import requests # not available in pyodide
110-
111109 zenodo_prefix = "10.5281/zenodo."
112110 zenodo_record_api = "https://zenodo.org/api/records"
113111 zenodo_sandbox_prefix = "10.5072/zenodo."
@@ -136,23 +134,7 @@ def resolve_rdf_source(
136134
137135 record_id = record_id .split ("/" )[- 1 ]
138136
139- response = requests .get (f"{ zenodo_record_api } /{ record_id } " )
140- if not response .ok :
141- raise RuntimeError (response .status_code )
142-
143- zenodo_record = response .json ()
144- for rdf_name in RDF_NAMES :
145- for f in zenodo_record ["files" ]:
146- if f ["key" ] == rdf_name :
147- source = f ["links" ]["self" ]
148- break
149- else :
150- continue
151-
152- break
153- else :
154- raise ValidationError (f"No RDF found; looked for { RDF_NAMES } " )
155-
137+ source = f"{ zenodo_record_api } /{ record_id } /files/rdf.yaml/content"
156138 else :
157139 # resolve doi
158140 # todo: make sure the resolved url points to a rdf.yaml or a zipped package
Original file line number Diff line number Diff line change @@ -87,8 +87,13 @@ def __truediv__(self, other):
8787
8888 @property
8989 def parent (self ):
90- path_parent = pathlib .PurePosixPath (self .path ).parent .as_posix ()
91- return dataclasses .replace (self , path = path_parent , uri_string = None )
90+ path = pathlib .PurePosixPath (self .path )
91+ if self .authority == "zenodo.org" and self .path .startswith ("/api/records/" ) and self .path .endswith ("/content" ):
92+ parent_path = (path .parent .parent / "content" ).as_posix ()
93+ else :
94+ parent_path = path .parent .as_posix ()
95+
96+ return dataclasses .replace (self , path = parent_path , uri_string = None )
9297
9398 def __post_init__ (self ):
9499 uri_string = self .uri_string # should be InitVar, see comment at definition above
Original file line number Diff line number Diff line change 1111from bioimageio .spec .model import format_version , raw_nodes
1212from bioimageio .spec .shared import yaml
1313
14- SKIP_ZENODO = True
14+ SKIP_ZENODO = False
1515SKIP_ZENODO_REASON = "zenodo api changes"
1616
1717
@@ -46,14 +46,6 @@ def test_validate_model_as_url():
4646 )["error" ]
4747
4848
49- @pytest .mark .skipif (SKIP_ZENODO , reason = SKIP_ZENODO_REASON )
50- def test_validate_model_as_zenodo_sandbox_doi ():
51- from bioimageio .spec .commands import validate
52-
53- doi = "10.5281/zenodo.5744489"
54- assert not validate (doi , update_format = False , update_format_inner = False )["error" ]
55-
56-
5749@pytest .mark .skipif (SKIP_ZENODO , reason = SKIP_ZENODO_REASON )
5850def test_validate_model_as_zenodo_doi ():
5951 from bioimageio .spec .commands import validate
Original file line number Diff line number Diff line change 44
55from bioimageio .spec .shared import yaml
66
7- SKIP_ZENODO = True
7+ SKIP_ZENODO = False
88SKIP_ZENODO_REASON = "zenodo api changes"
99
1010
Original file line number Diff line number Diff line change 66from bioimageio .spec .model .v0_4 import raw_nodes as raw_nodes_m04
77from bioimageio .spec .shared import yaml
88
9- SKIP_ZENODO = True
9+ SKIP_ZENODO = False
1010SKIP_ZENODO_REASON = "zenodo api changes"
1111
1212
You can’t perform that action at this time.
0 commit comments