Skip to content

Commit d947dc2

Browse files
authored
Release v0.1.4(#147)
* skip torch unit test Signed-off-by: JaredforReal <w13431838023@gmail.com> * release v0.1.4 Signed-off-by: JaredforReal <w13431838023@gmail.com> * update unit test Signed-off-by: JaredforReal <w13431838023@gmail.com> --------- Signed-off-by: JaredforReal <w13431838023@gmail.com>
1 parent f168a52 commit d947dc2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

glmocr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import importlib
66
from typing import TYPE_CHECKING
77

8-
__version__ = "0.1.3"
8+
__version__ = "0.1.4"
99
__author__ = "ZHIPUAI"
1010

1111
__all__ = [

glmocr/tests/test_unit.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ def test_config_to_dict(self):
2828
class TestLayoutDeviceUnit:
2929
"""Unit tests for layout device selection and config plumbing (mocked)."""
3030

31+
@staticmethod
32+
def _require_layout_runtime():
33+
"""Require optional self-hosted layout deps, otherwise skip tests."""
34+
torch = pytest.importorskip(
35+
"torch", reason="layout device unit tests require optional selfhosted deps"
36+
)
37+
pytest.importorskip(
38+
"transformers",
39+
reason="layout device unit tests require optional selfhosted deps",
40+
)
41+
return torch
42+
3143
def test_layout_config_device_default_is_none(self):
3244
"""LayoutConfig.device defaults to None (auto-select)."""
3345
from glmocr.config import LayoutConfig
@@ -89,6 +101,7 @@ def test_from_env_layout_device_kwarg(self, monkeypatch):
89101

90102
def _mock_detector(self, device_val):
91103
"""Create a PPDocLayoutDetector with mocked model, ready for start()."""
104+
self._require_layout_runtime()
92105
from glmocr.config import LayoutConfig
93106
from glmocr.layout.layout_detector import PPDocLayoutDetector
94107

@@ -143,7 +156,7 @@ def test_detector_device_selection_explicit_cuda(self):
143156

144157
def test_detector_device_selection_auto_fallback_cpu(self):
145158
"""When config.device=None and CUDA unavailable, auto-selects CPU."""
146-
import torch
159+
torch = self._require_layout_runtime()
147160

148161
det, mock_model, mock_proc = self._mock_detector(None)
149162

@@ -164,7 +177,7 @@ def test_detector_device_selection_auto_fallback_cpu(self):
164177

165178
def test_detector_device_selection_auto_cuda(self):
166179
"""When config.device=None and CUDA available, auto-selects cuda:{cuda_visible_devices}."""
167-
import torch
180+
torch = self._require_layout_runtime()
168181
from glmocr.config import LayoutConfig
169182
from glmocr.layout.layout_detector import PPDocLayoutDetector
170183

0 commit comments

Comments
 (0)