@@ -50,19 +50,28 @@ class ModelType:
5050 PYTORCH = "pytorch"
5151
5252
53- # Default model types (enabled by default, user can override via --allowed-model-types)
54- def _is_module_available (module_name : str ) -> bool :
55- return importlib .util .find_spec (module_name ) is not None
53+ def detect_installed_frameworks () -> list [str ]:
54+ """Detect which ML frameworks are installed and importable.
5655
56+ XGBoost and Keras are always available (core dependencies). Other frameworks are
57+ checked via importlib.util.find_spec() which is fast and has no side effects.
58+ """
59+ available = [ModelType .XGBOOST , ModelType .KERAS ] # Always available (core dependencies)
5760
58- DEFAULT_MODEL_TYPES = [
59- ModelType .XGBOOST ,
60- ModelType .CATBOOST ,
61- ModelType .LIGHTGBM ,
62- ModelType .KERAS ,
63- ]
64- if _is_module_available ("torch" ):
65- DEFAULT_MODEL_TYPES .append (ModelType .PYTORCH )
61+ _OPTIONAL_FRAMEWORKS = [
62+ ("catboost" , ModelType .CATBOOST ),
63+ ("lightgbm" , ModelType .LIGHTGBM ),
64+ ("torch" , ModelType .PYTORCH ),
65+ ]
66+ for module_name , model_type in _OPTIONAL_FRAMEWORKS :
67+ if importlib .util .find_spec (module_name ) is not None :
68+ available .append (model_type )
69+
70+ return available
71+
72+
73+ # Default model types (auto-detected from installed packages, user can override via --allowed-model-types)
74+ DEFAULT_MODEL_TYPES = detect_installed_frameworks ()
6675
6776# Task-compatible model types based on data layout
6877# Maps DataLayout enum to compatible model types
0 commit comments