1616from .algorithm_allowlist import ensure_algorithm_in_allowlist
1717from .contracts import (
1818 ExplainerAdapter ,
19+ ExplainerCapability ,
1920 ExplanationOutputSpace ,
2021 MethodFamily ,
2122 explainer_output_kind ,
@@ -113,14 +114,29 @@ def check_explainer_visualiser_semantic_compat(
113114 * ,
114115 task_kind : TaskKind | None = None ,
115116) -> None :
116- capability = explainer_capability (explainer , task_kind = task_kind )
117+ # Resolve the explainer's capability lazily: only a visualiser that
118+ # actually declares supported method families / output spaces gives us
119+ # something to check. With nothing to check (e.g. no visualisers), we must
120+ # not force method-family resolution (reading the explainer's
121+ # ``algorithm_registry``) for no reason.
122+ capability : ExplainerCapability | None = None
117123
118124 for configured in visualisers :
119125 visualiser = configured .visualiser
120126 supported_method_families = _enum_frozenset (
121127 getattr (type (visualiser ), "supported_method_families" , frozenset ()),
122128 MethodFamily ,
123129 )
130+ supported_output_spaces = _enum_frozenset (
131+ getattr (type (visualiser ), "supported_output_spaces" , frozenset ()),
132+ ExplanationOutputSpace ,
133+ )
134+ if not supported_method_families and not supported_output_spaces :
135+ continue
136+
137+ if capability is None :
138+ capability = explainer_capability (explainer , task_kind = task_kind )
139+
124140 if supported_method_families and not (
125141 capability .method_families & supported_method_families
126142 ):
@@ -131,10 +147,6 @@ def check_explainer_visualiser_semantic_compat(
131147 f"{ sorted (f .value for f in supported_method_families )} ."
132148 )
133149
134- supported_output_spaces = _enum_frozenset (
135- getattr (type (visualiser ), "supported_output_spaces" , frozenset ()),
136- ExplanationOutputSpace ,
137- )
138150 if not supported_output_spaces :
139151 continue
140152 if capability .candidate_output_spaces & supported_output_spaces :
0 commit comments