@@ -97,6 +97,7 @@ def _replace_relative_paths_for_remote_source(
97
97
def load_raw_resource_description (
98
98
source : Union [dict , os .PathLike , IO , str , bytes , raw_nodes .URI , RawResourceDescription ],
99
99
update_to_current_format : bool = True ,
100
+ update_to_format : Optional [str ] = None ,
100
101
) -> RawResourceDescription :
101
102
"""load a raw python representation from a BioImage.IO resource description file (RDF).
102
103
Use `load_resource_description` for a more convenient representation.
@@ -105,14 +106,17 @@ def load_raw_resource_description(
105
106
source: resource description file (RDF)
106
107
update_to_current_format: if True (default) attempt auto-conversion to latest format version
107
108
(most bioimageio.core functionality expects the latest format version for each resource)
109
+ update_to_format: update resource to specific major.minor format version; ignoring patch version.
108
110
109
111
Returns:
110
112
raw BioImage.IO resource
111
113
"""
112
114
if isinstance (source , RawResourceDescription ):
113
115
return source
114
116
115
- raw_rd = spec .load_raw_resource_description (source , update_to_current_format = update_to_current_format )
117
+ raw_rd = spec .load_raw_resource_description (
118
+ source , update_to_current_format = update_to_current_format , update_to_format = update_to_format
119
+ )
116
120
raw_rd = _replace_relative_paths_for_remote_source (raw_rd , raw_rd .root_path )
117
121
return raw_rd
118
122
@@ -136,7 +140,7 @@ def load_resource_description(
136
140
if isinstance (source , ResourceDescription ):
137
141
return source
138
142
139
- raw_rd = load_raw_resource_description (source , update_to_current_format = True )
143
+ raw_rd = load_raw_resource_description (source , update_to_format = "latest" )
140
144
141
145
if weights_priority_order is not None :
142
146
for wf in weights_priority_order :
@@ -188,6 +192,7 @@ def export_resource_package(
188
192
compression_level : int = 1 ,
189
193
output_path : Optional [os .PathLike ] = None ,
190
194
update_to_current_format : bool = False ,
195
+ update_to_format : Optional [str ] = None ,
191
196
weights_priority_order : Optional [Sequence [Union [str ]]] = None ,
192
197
) -> pathlib .Path :
193
198
"""Package a BioImage.IO resource as a zip file.
@@ -199,13 +204,16 @@ def export_resource_package(
199
204
See https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile
200
205
output_path: file path to write package to
201
206
update_to_current_format: If True attempt auto-conversion to latest format version.
207
+ update_to_format: update resource to specific major.minor format version; ignoring patch version.
202
208
weights_priority_order: If given only the first weights format present in the model is included.
203
209
If none of the prioritized weights formats is found all are included.
204
210
205
211
Returns:
206
212
path to zipped BioImage.IO package in BIOIMAGEIO_CACHE_PATH or 'output_path'
207
213
"""
208
- raw_rd = load_raw_resource_description (source , update_to_current_format = update_to_current_format )
214
+ raw_rd = load_raw_resource_description (
215
+ source , update_to_current_format = update_to_current_format , update_to_format = update_to_format
216
+ )
209
217
package_content = get_local_resource_package_content (raw_rd , weights_priority_order )
210
218
if output_path is None :
211
219
package_path = _get_tmp_package_path (raw_rd , weights_priority_order )
0 commit comments