diff --git a/docling/datamodel/settings.py b/docling/datamodel/settings.py index cea7747548..b246c6cc57 100644 --- a/docling/datamodel/settings.py +++ b/docling/datamodel/settings.py @@ -52,7 +52,7 @@ class DebugSettings(BaseModel): class InferenceSettings(BaseModel): - compile_torch_models: bool = True + compile_torch_models: bool = sys.platform != "win32" class AppSettings(BaseSettings): diff --git a/tests/test_settings_load.py b/tests/test_settings_load.py index 5e760eecb8..0867d1ba3f 100644 --- a/tests/test_settings_load.py +++ b/tests/test_settings_load.py @@ -54,6 +54,34 @@ def test_compile_model_defaults_from_settings(monkeypatch): assert TransformersVlmEngineOptions().compile_model is True +def test_compile_model_defaults_to_false_on_windows(monkeypatch): + import importlib + import sys + + import docling.datamodel.settings as settings_module + from docling.datamodel.object_detection_engine_options import ( + TransformersObjectDetectionEngineOptions, + ) + + monkeypatch.delenv("DOCLING_INFERENCE_COMPILE_TORCH_MODELS", raising=False) + original_platform = sys.platform + monkeypatch.setattr(sys, "platform", "win32") + importlib.reload(settings_module) + + try: + assert settings_module.settings.inference.compile_torch_models is False + assert TransformersObjectDetectionEngineOptions().compile_model is False + + monkeypatch.setenv("DOCLING_INFERENCE_COMPILE_TORCH_MODELS", "True") + importlib.reload(settings_module) + assert settings_module.settings.inference.compile_torch_models is True + assert TransformersObjectDetectionEngineOptions().compile_model is True + finally: + monkeypatch.setattr(sys, "platform", original_platform) + monkeypatch.delenv("DOCLING_INFERENCE_COMPILE_TORCH_MODELS", raising=False) + importlib.reload(settings_module) + + def test_scoped_settings_restores_state(): import importlib