File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
tests/prediction_pipeline Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ import dataclasses
2+
3+ import pytest
4+
5+ from bioimageio .core .prediction_pipeline ._processing import KNOWN_PROCESSING
6+ from bioimageio .core .prediction_pipeline ._utils import FIXED
7+
8+ try :
9+ from typing import get_args
10+ except ImportError :
11+ from typing_extensions import get_args # type: ignore
12+
13+
14+ @pytest .mark .parametrize (
15+ "proc" ,
16+ list (KNOWN_PROCESSING ["pre" ].values ()) + list (KNOWN_PROCESSING ["post" ].values ()),
17+ )
18+ def test_no_req_measures_for_mode_fixed (proc ):
19+ # check if mode=fixed is valid for this proc
20+ for f in dataclasses .fields (proc ):
21+ if f .name == "mode" :
22+ break
23+ else :
24+ raise AttributeError ("Processing is missing mode attribute" )
25+ # mode is always annotated as literals (or literals of literals)
26+ valid_modes = get_args (f .type )
27+ for inner in get_args (f .type ):
28+ valid_modes += get_args (inner )
29+
30+ if FIXED not in valid_modes :
31+ return
32+
33+ # we might be missing required kwargs. These have marshmallow.missing value as default
34+ # and raise a TypeError is in __post_init__()
35+ proc .__post_init__ = lambda self : None # ignore missing kwargs
36+
37+ proc_instance = proc (tensor_name = "tensor_name" , mode = FIXED )
38+ req_measures = proc_instance .get_required_measures ()
39+ assert not req_measures
You can’t perform that action at this time.
0 commit comments