Skip to content

Commit 7760611

Browse files
committed
expose limiting loaded weight formats
1 parent 7edc944 commit 7760611

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

bioimageio/core/resource_io/io_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def load_resource_description(
4040

4141
raw_rd = load_raw_resource_description(source, update_to_format="latest")
4242

43-
if weights_priority_order is not None:
43+
if raw_rd.type == "model" and weights_priority_order is not None:
4444
for wf in weights_priority_order:
4545
if wf in raw_rd.weights:
4646
raw_rd.weights = {wf: raw_rd.weights[wf]}

bioimageio/core/resource_tests.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def test_model(
3131
3232
Returns summary dict with "error" and "traceback" key; summary["error"] is None if no errors were encountered.
3333
"""
34-
model = load_resource_description(model_rdf)
34+
model = load_resource_description(
35+
model_rdf, weights_priority_order=None if weight_format is None else [weight_format]
36+
)
3537
if isinstance(model, Model):
3638
return test_resource(model, weight_format=weight_format, devices=devices, decimal=decimal)
3739
else:
@@ -91,7 +93,9 @@ def test_resource(
9193
tb: Optional = None
9294

9395
try:
94-
rd = load_resource_description(model_rdf)
96+
rd = load_resource_description(
97+
model_rdf, weights_priority_order=None if weight_format is None else [weight_format]
98+
)
9599
except Exception as e:
96100
error = str(e)
97101
tb = traceback.format_tb(e.__traceback__)
@@ -161,7 +165,9 @@ def debug_model(
161165
expected: Optional = None
162166
diff: Optional = None
163167

164-
model = load_resource_description(model_rdf)
168+
model = load_resource_description(
169+
model_rdf, weights_priority_order=None if weight_format is None else [weight_format]
170+
)
165171
if not isinstance(model, Model):
166172
raise ValueError(f"Not a bioimageio.model: {model_rdf}")
167173

0 commit comments

Comments
 (0)