Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docling/datamodel/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
28 changes: 28 additions & 0 deletions tests/test_settings_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading