Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

Fix Python 3.10 CI compatibility and minimum Torch version

myhloli6e5e881827aa
diff --git a/.github/workflows/transformers5.yml b/.github/workflows/transformers5.yml
index 4e5b7c67..822a505e 100644
--- a/.github/workflows/transformers5.yml
+++ b/.github/workflows/transformers5.yml
@@ -30,7 +30,7 @@ jobs:
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
transformers: ['5.10.1', '5.14.0', '5.16.1']
include:
- - {os: ubuntu-latest, python: '3.10', transformers: '5.10.1', torch: '2.6.0', torchvision: '0.21.0'}
+ - {os: ubuntu-latest, python: '3.10', transformers: '5.10.1', torch: '2.7.0', torchvision: '0.22.0'}
- {os: windows-latest, python: '3.12', transformers: '5.10.1'}
- {os: windows-latest, python: '3.12', transformers: '5.16.1'}
- {os: macos-latest, python: '3.12', transformers: '5.10.1'}
diff --git a/mineru/doclib/telemetry/payload.py b/mineru/doclib/telemetry/payload.py
index 727666d2..71bf0666 100644
--- a/mineru/doclib/telemetry/payload.py
+++ b/mineru/doclib/telemetry/payload.py
@@ -7,7 +7,7 @@ import json
import os
import platform
import sys
-from datetime import UTC, datetime
+from datetime import datetime, timezone
from importlib import metadata
from pathlib import Path
from typing import Any
@@ -26,7 +26,8 @@ def dimensions_hash(dimensions: dict[str, str]) -> str:
def utc_iso_from_ms(value_ms: int) -> str:
- return datetime.fromtimestamp(value_ms / 1000, tz=UTC).isoformat(timespec="milliseconds").replace("+00:00", "Z")
+ """使用 Python 3.10 支持的 UTC 时区,保留毫秒精度和 Z 后缀。"""
+ return datetime.fromtimestamp(value_ms / 1000, tz=timezone.utc).isoformat(timespec="milliseconds").replace("+00:00", "Z")
def compact_json_bytes(payload: dict[str, Any]) -> bytes:
diff --git a/pyproject.toml b/pyproject.toml
index a1c66f0b..e6246a3e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -91,7 +91,8 @@ test = [
]
torch = [
"six>=1.17.0,<2",
- "torch>=2.6.0,<3",
+ # Transformers 5.10.1 导入模型时需要 Torch 2.7 新增的 float8_e8m0fnu。
+ "torch>=2.7.0,<3",
"torchvision",
"transformers>=5.10.1,<6",
"accelerate>=1.5.1",
diff --git a/tests/unittest/test_kit_gradio.py b/tests/unittest/test_kit_gradio.py
index 9c3800b4..47ed0a67 100644
--- a/tests/unittest/test_kit_gradio.py
+++ b/tests/unittest/test_kit_gradio.py
@@ -553,12 +553,17 @@ def test_gradio_router_preserves_remote_flash_results_errors_and_cancellation(fa
routed = GradioArtifactClient(primary, local_flash=local)
callback = Mock()
request = routed.parse_file(Path("report.pdf"), tier="flash", page_range="1-2", ocr_mode="ocr", status_callback=callback)
- if failure is None:
- assert asyncio.run(request) is result
- else:
- with pytest.raises(type(failure)) as error:
- asyncio.run(request)
- assert error.value is failure
+
+ async def check_request() -> None:
+ """在协程内检查透传,避免 Python 3.10 的 Task 边界重建取消异常。"""
+ if failure is None:
+ assert await request is result
+ else:
+ with pytest.raises(type(failure)) as error:
+ await request
+ assert error.value is failure
+
+ asyncio.run(check_request())
primary.parse_file.assert_awaited_once_with(
Path("report.pdf"), tier="flash", page_range="1-2", ocr_mode="ocr", status_callback=callback
)