@@ -81,7 +81,7 @@ def extract_resource_package(
8181 source : Union [os .PathLike , IO , str , bytes , raw_nodes .URI ]
8282) -> Tuple [dict , str , pathlib .Path ]:
8383 """extract a zip source to BIOIMAGEIO_CACHE_PATH"""
84- source , source_name , root = resolve_rdf_source (source )
84+ src , source_name , root = resolve_rdf_source (source )
8585 if isinstance (root , bytes ):
8686 raise NotImplementedError ("package source was bytes" )
8787
@@ -123,7 +123,7 @@ def extract_resource_package(
123123 warnings .warn (f"Could not remove download { download } due to { e } " )
124124
125125 assert isinstance (package_path , pathlib .Path )
126- return source , source_name , package_path
126+ return src , source_name , package_path
127127
128128
129129def load_raw_resource_description (
@@ -292,7 +292,7 @@ def get_resource_package_content_wo_rdf(
292292 raw_rd : Union [GenericRawRD , raw_nodes .URI , str , pathlib .Path ],
293293 * ,
294294 weights_priority_order : Optional [Sequence [str ]] = None , # model only
295- ) -> Tuple [GenericRawNode , Dict [str , Union [pathlib .PurePath , raw_nodes .URI ]]]:
295+ ) -> Tuple [raw_nodes . ResourceDescription , Dict [str , Union [pathlib .PurePath , raw_nodes .URI ]]]:
296296 """
297297 Args:
298298 raw_rd: raw resource description
@@ -305,25 +305,27 @@ def get_resource_package_content_wo_rdf(
305305 keyed by file names.
306306 Important note: the serialized rdf.yaml is not included.
307307 """
308- if not isinstance (raw_rd , raw_nodes .ResourceDescription ):
309- raw_rd = load_raw_resource_description (raw_rd )
308+ if isinstance (raw_rd , raw_nodes .ResourceDescription ):
309+ r_rd = raw_rd
310+ else :
311+ r_rd = load_raw_resource_description (raw_rd )
310312
311- sub_spec = _get_spec_submodule (raw_rd .type , raw_rd .format_version )
312- if raw_rd .type == "model" :
313+ sub_spec = _get_spec_submodule (r_rd .type , r_rd .format_version )
314+ if r_rd .type == "model" :
313315 filter_kwargs = dict (weights_priority_order = weights_priority_order )
314316 else :
315317 filter_kwargs = {}
316318
317- raw_rd = sub_spec .utils .filter_resource_description (raw_rd , ** filter_kwargs )
319+ r_rd = sub_spec .utils .filter_resource_description (r_rd , ** filter_kwargs )
318320
319- content : Dict [str , Union [pathlib .PurePath , raw_nodes .URI , str ]] = {}
320- raw_rd = RawNodePackageTransformer (content , raw_rd .root_path ).transform (raw_rd )
321+ content : Dict [str , Union [pathlib .PurePath , raw_nodes .URI ]] = {}
322+ r_rd = RawNodePackageTransformer (content , r_rd .root_path ).transform (r_rd )
321323 assert "rdf.yaml" not in content
322- return raw_rd , content
324+ return r_rd , content
323325
324326
325327def get_resource_package_content (
326- raw_rd : Union [GenericRawNode , raw_nodes .URI , str , pathlib .Path ],
328+ raw_rd : Union [raw_nodes . ResourceDescription , raw_nodes .URI , str , pathlib .Path ],
327329 * ,
328330 weights_priority_order : Optional [Sequence [str ]] = None , # model only
329331) -> Dict [str , Union [str , pathlib .PurePath , raw_nodes .URI ]]:
@@ -343,7 +345,5 @@ def get_resource_package_content(
343345 "without yaml"
344346 )
345347
346- content : Dict [str , Union [str , pathlib .PurePath , raw_nodes .URI ]]
347- raw_rd , content = get_resource_package_content_wo_rdf (raw_rd , weights_priority_order = weights_priority_order )
348- content ["rdf.yaml" ] = serialize_raw_resource_description (raw_rd )
349- return content
348+ r_rd , content = get_resource_package_content_wo_rdf (raw_rd , weights_priority_order = weights_priority_order )
349+ return {** content , ** {"rdf.yaml" : serialize_raw_resource_description (r_rd )}}
0 commit comments