Validation error for subsequent call of `load_description`
Closed this issue · 3 comments
thodkatz commented
v0.5.3.1
Issue
import bioimageio.spec as spec
path1 = 'https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_descriptions/models/unet2d_nuclei_broad/bioimageio.yaml'
path2 = 'https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_descriptions/models/unet2d_multi_tensor/v0_4.bioimageio.yaml'
model1 = spec.load_description(path1) # valid (ModelDescr)
model2 = spec.load_description(path2) # invalid (InvalidDescr)
but if we change the order,
import bioimageio.spec as spec
path1 = 'https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_descriptions/models/unet2d_nuclei_broad/bioimageio.yaml'
path2 = 'https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_descriptions/models/unet2d_multi_tensor/v0_4.bioimageio.yaml'
model2 = spec.load_description(path2) # valid (ModelDescr)
model1 = spec.load_description(path1) # invalid (InvalidDescr)
and the validation error was based on the known_files
e.g. weights for onnx, torchscript...
so, it isn't based on the validity of each model, and there seems to be a leak between loads.
The actual issue
# 1st call
load_description(path1, know_files = None):
...
context = validation_context_var.get().replace(
root=opened.original_root,
file_name=opened.original_file_name,
perform_io_checks=perform_io_checks,
known_files=known_files)
...
return descr
# 2nd call
load_description(path1, know_files = None):
...
# attempt to replace the previous context var with a new one, but know_files is None
context = validation_context_var.get().replace(
root=opened.original_root,
file_name=opened.original_file_name,
perform_io_checks=perform_io_checks,
known_files=known_files)
# the replaced context will have the previous known_files (1st call), no update, thus validation will fail
...
return descr
thodkatz commented
I will attempt to push a PR to resolve the issue :)
FynnBe commented
try if you can reproduce the issue with the latest main, because I thought I fixed the issue that was reported in #619 already
thodkatz commented
Yep, I missed this update, indeed is the same issue :)