Skip to content

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

feat: update tier system to include medium, high, and extra_high options, replacing standard and pro

myhlolif1ea8e4c8840
diff --git a/mineru/backend/hybrid/hybrid_analyze.py b/mineru/backend/hybrid/hybrid_analyze.py
index 8e2c9060..5a4ecd7d 100644
--- a/mineru/backend/hybrid/hybrid_analyze.py
+++ b/mineru/backend/hybrid/hybrid_analyze.py
@@ -1041,8 +1041,8 @@ def _extract_with_local_layout(
local_context_singleton = HybridLocalModelContextSingleton()
local_context = local_context_singleton.get_model(
lang=language,
- # VLM 文本路径只需要本地 layout 与 OCR det,不需要加载 MFR。
- formula_enable=inline_formula_enable and not _ocr_enable,
+ # medium 本地路径会直接执行公式识别;OCR 扫描件也需要加载 MFR。
+ formula_enable=inline_formula_enable,
)
np_images = [np.asarray(pil_image).copy() for pil_image in images_pil_list]
images_layout_res = run_layout_inference(
diff --git a/mineru/cli_old/gradio_app.py b/mineru/cli_old/gradio_app.py
index 4798fe3c..ad0cf6fa 100644
--- a/mineru/cli_old/gradio_app.py
+++ b/mineru/cli_old/gradio_app.py
@@ -239,8 +239,8 @@ STATUS_QUEUED_ON_SERVER = "Queued on server"
STATUS_PROCESSING_ON_SERVER = "Processing on server"
STATUS_QUEUED_LOCALLY_PREFIX = "Queued locally:"
-DEFAULT_GRADIO_TIER = "pro"
-GRADIO_TIER_CHOICES = ("standard", "pro")
+DEFAULT_GRADIO_TIER = "high"
+GRADIO_TIER_CHOICES = ("flash", "medium", "high", "extra_high")
STATUS_STEP_DEFINITIONS = [
("status_step_prepare", STATUS_PREPARING_REQUEST),
("status_step_check", STATUS_CHECKING_SERVER),
@@ -409,9 +409,11 @@ def extract_v1_tier_choices(payload) -> tuple[str, ...]:
def default_v1_gradio_tier(tier_choices: tuple[str, ...]) -> str:
- """选择 Gradio 默认 tier;v1 server 返回顺序即默认优先级。"""
+ """选择 Gradio 默认 tier;优先 high,与 API server 的无 tier 请求默认值保持一致。"""
if not tier_choices:
raise click.ClickException("MinerU v1 API did not advertise any supported tier.")
+ if DEFAULT_GRADIO_TIER in tier_choices:
+ return DEFAULT_GRADIO_TIER
return tier_choices[0]
@@ -593,10 +595,14 @@ def resolve_gradio_runtime_options(tier: str | None) -> ParserRuntimeOptions:
def select_tier_info_key(tier_choice: object) -> str:
"""根据 Gradio tier 选择说明文案的 i18n key。"""
- if tier_choice == "standard":
- return "tier_info_standard"
- if tier_choice == "pro":
- return "tier_info_pro"
+ if tier_choice == "flash":
+ return "tier_info_flash"
+ if tier_choice == "medium":
+ return "tier_info_medium"
+ if tier_choice == "high":
+ return "tier_info_high"
+ if tier_choice == "extra_high":
+ return "tier_info_extra_high"
return "tier_info_default"
@@ -1722,8 +1728,10 @@ def main(ctx,
"max_pages": "Max convert pages",
"tier": "Tier",
"tier_info_default": "Select the parsing tier.",
- "tier_info_standard": "Standard tier uses fast local Hybrid parsing.",
- "tier_info_pro": "Pro tier uses higher quality Hybrid parsing.",
+ "tier_info_flash": "Flash tier uses fast local text extraction.",
+ "tier_info_medium": "Medium tier uses local Hybrid parsing.",
+ "tier_info_high": "High tier uses higher quality Hybrid parsing.",
+ "tier_info_extra_high": "Extra high tier uses maximum-quality Hybrid parsing.",
"convert": "Convert",
"clear": "Clear",
"doc_preview": "Document preview",
@@ -1766,8 +1774,10 @@ def main(ctx,
"max_pages": "最大转换页数",
"tier": "解析 tier",
"tier_info_default": "选择文档解析 tier。",
- "tier_info_standard": "standard 使用快速本地 Hybrid 解析。",
- "tier_info_pro": "pro 使用更高质量的 Hybrid 解析。",
+ "tier_info_flash": "flash 使用快速本地文本提取。",
+ "tier_info_medium": "medium 使用本地 Hybrid 解析。",
+ "tier_info_high": "high 使用更高质量的 Hybrid 解析。",
+ "tier_info_extra_high": "extra_high 使用最高质量的 Hybrid 解析。",
"convert": "转换",
"clear": "清除",
"doc_preview": "文档预览",
diff --git a/mineru/doclib/app.py b/mineru/doclib/app.py
index f0758b58..276e0d71 100644
--- a/mineru/doclib/app.py
+++ b/mineru/doclib/app.py
@@ -120,7 +120,7 @@ def create_app(cfg: Config | None = None) -> FastAPI:
health = get_health()
health.local_mode = local_mode
if local_mode == "managed":
- managed_tier = (await state.config_svc.get("parse_server.local.managed_tier")) or "standard"
+ managed_tier = (await state.config_svc.get("parse_server.local.managed_tier")) or "high"
health.managed_tier = managed_tier
try:
proc, managed_url = start_managed_parse_server(
diff --git a/mineru/doclib/background/parse_server_health.py b/mineru/doclib/background/parse_server_health.py
index e0921b24..b18b6347 100644
--- a/mineru/doclib/background/parse_server_health.py
+++ b/mineru/doclib/background/parse_server_health.py
@@ -234,7 +234,7 @@ class ParseServerHealthCheck:
# refresh config on each cycle (hot-reload)
mode = (await self.config_svc.get("parse_server.local.mode")) or "disabled"
health.local_mode = mode
- managed_tier = (await self.config_svc.get("parse_server.local.managed_tier")) or "standard"
+ managed_tier = (await self.config_svc.get("parse_server.local.managed_tier")) or "high"
desired_managed_tier = cast(Tier, managed_tier)
health.managed_tier = desired_managed_tier
self_hosted_url = await self.config_svc.get("parse_server.local.self_hosted_url")
@@ -318,7 +318,7 @@ class ParseServerHealthCheck:
if count_restart:
health.restart_count += 1
- managed_tier = (await self.config_svc.get("parse_server.local.managed_tier")) or "standard"
+ managed_tier = (await self.config_svc.get("parse_server.local.managed_tier")) or "high"
stop_managed_parse_server(health.managed_proc, timeout_sec=self.stop_timeout_sec, reason=reason)
health.managed_proc = None
health.running_managed_tier = None
diff --git a/mineru/doclib/config_defaults.py b/mineru/doclib/config_defaults.py
index 75ff0e48..b456574e 100644
--- a/mineru/doclib/config_defaults.py
+++ b/mineru/doclib/config_defaults.py
@@ -8,7 +8,7 @@ ConfigSource = Literal["default", "override"]
CONFIG_DEFAULTS: dict[str, str] = {
"parse_server.local.mode": "disabled",
- "parse_server.local.managed_tier": "standard",
+ "parse_server.local.managed_tier": "high",
"parse_server.local.self_hosted_url": "",
"parse_server.local.self_hosted_api_key": "",
# "parse_server.remote.url": "https://mineru.net/api",
diff --git a/mineru/doclib/locators.py b/mineru/doclib/locators.py
index 4eb3add2..12cee1aa 100644
--- a/mineru/doclib/locators.py
+++ b/mineru/doclib/locators.py
@@ -9,7 +9,7 @@ from ..types import Tier
_CURSOR_RE = re.compile(
r"^doc:(?P<short_id>[0-9a-fA-F]+)"
- r"/tier:(?P<tier>flash|standard|pro)"
+ r"/tier:(?P<tier>flash|medium|high|extra_high)"
r"/page:(?P<page_no>[1-9][0-9]*)"
r"(?:/block:(?P<block_no>[1-9][0-9]*)(?:/char:(?P<char_offset>0|[1-9][0-9]*))?)?$"
)
diff --git a/mineru/doclib/server.py b/mineru/doclib/server.py
index fdfbe289..71984db2 100644
--- a/mineru/doclib/server.py
+++ b/mineru/doclib/server.py
@@ -237,7 +237,7 @@ class DoclibServer(AsyncDoclibInterface):
(FILE_STATUS_ACTIVE,),
)
local_mode = (await self.state.config_svc.get("parse_server.local.mode")) or "disabled"
- managed_tier = (await self.state.config_svc.get("parse_server.local.managed_tier")) or "standard"
+ managed_tier = (await self.state.config_svc.get("parse_server.local.managed_tier")) or "high"
self_hosted_url = await self.state.config_svc.get("parse_server.local.self_hosted_url")
remote_url = await self.state.config_svc.get("parse_server.remote.url")
watches = await self.state.config_svc.list_watches()
@@ -848,7 +848,7 @@ class DoclibServer(AsyncDoclibInterface):
)
if value == "managed":
tier = _validate_managed_parse_server_tier(
- (await self.state.config_svc.get("parse_server.local.managed_tier")) or "standard",
+ (await self.state.config_svc.get("parse_server.local.managed_tier")) or "high",
"parse_server.local.managed_tier",
)
_ensure_managed_parse_server_tier_available(tier, key)
@@ -1381,7 +1381,7 @@ class DoclibServer(AsyncDoclibInterface):
_READ_LOCATOR_RE = re.compile(
r"^doc:(?P<short_id>[0-9a-fA-F]+)"
- r"(?:/tier:(?P<tier>flash|standard|pro)"
+ r"(?:/tier:(?P<tier>flash|medium|high|extra_high)"
r"(?:/page:(?P<page_no>[1-9][0-9]*)"
r"(?:/block:(?P<block_no>[1-9][0-9]*)(?:/char:(?P<char_offset>0|[1-9][0-9]*))?)?)?)?$"
)
@@ -1419,7 +1419,7 @@ def _locator_after(locator: _LocatorParts) -> str | None:
if locator.block_no is None:
return None
return (
- _canonical_locator(locator.short_id, locator.tier or "standard", locator) if locator.char_offset is not None else None
+ _canonical_locator(locator.short_id, locator.tier or "high", locator) if locator.char_offset is not None else None
)
@@ -1530,10 +1530,10 @@ def _ensure_managed_parse_server_tier_available(tier: Tier, param: str) -> None:
def _validate_managed_parse_server_tier(value: str, param: str) -> Tier:
- if value not in ("standard", "pro"):
+ if value not in ("flash", "medium", "high", "extra_high"):
raise InvalidRequestError(
"invalid_config_value",
- "parse_server.local.managed_tier must be one of: standard, pro.",
+ "parse_server.local.managed_tier must be one of: flash, medium, high, extra_high.",
param,
)
return cast(Tier, value)
diff --git a/mineru/doclib/services/parse_svc.py b/mineru/doclib/services/parse_svc.py
index a82d884b..8f1194ed 100644
--- a/mineru/doclib/services/parse_svc.py
+++ b/mineru/doclib/services/parse_svc.py
@@ -693,10 +693,10 @@ class ParseService:
if remote and tier == "flash":
raise InvalidRequestError(
"tier_unsupported_for_remote",
- "--remote does not support tier 'flash'; use --tier standard or --tier pro.",
+ "--remote does not support tier 'flash'; use --tier medium, --tier high, or --tier extra_high.",
"tier",
)
- if tier in ("standard", "pro") and ext not in QUALITY_TIER_EXTENSIONS:
+ if tier in ("medium", "high", "extra_high") and ext not in QUALITY_TIER_EXTENSIONS:
raise InvalidRequestError(
"tier_unsupported_for_file_type",
f"Tier '{tier}' is only supported for PDF and image files; '{ext}' files use --tier flash.",
@@ -1323,21 +1323,23 @@ class ParseService:
def _resolve_default_tier(remote: bool = False) -> Tier:
- """Pick the best available tier from health check. ``pro`` > ``standard`` > ``flash``."""
+ """从健康检查中选择最高可用质量 tier,顺序为 extra_high > high > medium。"""
from ..background.parse_server_health import get_health
health = get_health()
supported = health.remote_supported_tiers if remote else health.local_supported_tiers
- for candidate in ("pro", "standard"):
+ for candidate in ("extra_high", "high", "medium"):
if candidate in supported:
return candidate
actions = ["start a local parse-server"]
- if not remote and health.remote_healthy and any(tier in health.remote_supported_tiers for tier in ("pro", "standard")):
+ if not remote and health.remote_healthy and any(
+ tier in health.remote_supported_tiers for tier in ("extra_high", "high", "medium")
+ ):
actions.append("use --remote")
actions.append("explicitly pass --tier flash for text-only preview")
raise ParseFailure(
"quality_tier_unavailable",
- f"No standard or pro engine available. You can {_format_action_list(actions)}.",
+ f"No medium, high, or extra_high engine available. You can {_format_action_list(actions)}.",
)
diff --git a/mineru/doclib/telemetry/constants.py b/mineru/doclib/telemetry/constants.py
index 04c28f9a..a7aebac4 100644
--- a/mineru/doclib/telemetry/constants.py
+++ b/mineru/doclib/telemetry/constants.py
@@ -50,7 +50,19 @@ DIM_STATUS_VALUES = frozenset(
"unsupported",
}
)
-DIM_TIER_VALUES = frozenset({"default", "flash", "standard", "pro", "standard(default)", "pro(default)", "unknown"})
+DIM_TIER_VALUES = frozenset(
+ {
+ "default",
+ "flash",
+ "medium",
+ "high",
+ "extra_high",
+ "medium(default)",
+ "high(default)",
+ "extra_high(default)",
+ "unknown",
+ }
+)
DIM_SERVER_VALUES = frozenset(
{"local(flash)", "local(managed)", "local(self-hosted)", "remote(official)", "remote(custom)", "none", "unknown"}
)
diff --git a/mineru/kit/commands/api_server.py b/mineru/kit/commands/api_server.py
index b2cc5377..6e5675a1 100644
--- a/mineru/kit/commands/api_server.py
+++ b/mineru/kit/commands/api_server.py
@@ -5,14 +5,11 @@ from typing import Literal, Sequence
import typer
from ...parser import api_server as parser_api_server
-from ...parser.tier import PARSER_BACKENDS
-from ...utils.backend_options import DEFAULT_HYBRID_EFFORT, resolve_backend_and_effort
from ...utils.ocr_language import PUBLIC_OCR_LANGUAGES, validate_public_ocr_lang
from ..errors import exit_with_message
-API_SERVER_BACKENDS = tuple(backend for backend in PARSER_BACKENDS if backend != "flash")
API_SERVER_LANGUAGES = PUBLIC_OCR_LANGUAGES
-API_SERVER_TIERS = ("standard", "pro")
+API_SERVER_TIERS = ("flash", "medium", "high", "extra_high")
def _normalize_tier_options(tier: Sequence[str] | str | None) -> list[str]:
@@ -37,25 +34,19 @@ def api_server_cmd(
host: str = "127.0.0.1",
port: int = 8000,
upload_dir: str = "",
- backend: str | None = None,
- tier: Sequence[Literal["standard", "pro"]] | Literal["standard", "pro"] | None = None,
+ tier: Sequence[Literal["flash", "medium", "high", "extra_high"]]
+ | Literal["flash", "medium", "high", "extra_high"]
+ | None = None,
concurrency: int = 1,
url_timeout: int = 60,
max_wait: int = 600,
language: str = "ch",
ocr_mode: Literal["auto", "txt", "ocr"] = "auto",
- effort: Literal["medium", "high", "extra_high"] = DEFAULT_HYBRID_EFFORT,
disable_table: bool = False,
disable_formula: bool = False,
disable_image_analysis: bool = False,
api_key: str | None = None,
) -> None:
- try:
- normalized_backend, normalized_effort = (
- resolve_backend_and_effort(backend, effort) if backend is not None else (None, effort)
- )
- except ValueError as exc:
- exit_with_message("invalid_request", str(exc), "backend")
try:
normalized_language = validate_public_ocr_lang(language)
except ValueError as exc:
@@ -79,11 +70,8 @@ def api_server_cmd(
normalized_language,
"--ocr-mode",
ocr_mode,
- "--effort",
- normalized_effort,
*tier_args,
*(["--upload-dir", upload_dir] if upload_dir else []),
- *(["--backend", normalized_backend] if normalized_backend else []),
*(["--disable-table"] if disable_table else []),
*(["--disable-formula"] if disable_formula else []),
*(["--disable-image-analysis"] if disable_image_analysis else []),
diff --git a/mineru/kit/commands/parse.py b/mineru/kit/commands/parse.py
index 46cd4255..c1e9ccff 100644
--- a/mineru/kit/commands/parse.py
+++ b/mineru/kit/commands/parse.py
@@ -6,7 +6,7 @@ from typing import Literal
from ...parser import MinerUApiParser
from ...parser import parse as local_parse
-from ...utils.backend_options import DEFAULT_HYBRID_EFFORT, LOCAL_HYBRID_EFFORT, resolve_backend_and_effort
+from ...utils.backend_options import DEFAULT_HYBRID_EFFORT, resolve_backend_and_effort
from ...utils.ocr_language import validate_public_ocr_lang
from ..common import (
build_remote_api_url,
@@ -27,7 +27,7 @@ def parse_cmd(
pages: str | None = None,
format: Literal["markdown", "middle_json", "zip"] = "markdown",
verbose: bool = False,
- tier: Literal["flash", "standard", "pro"] | None = None,
+ tier: Literal["flash", "medium", "high", "extra_high"] | None = None,
backend: str | None = None,
remote: bool = False,
remote_url: str | None = None,
@@ -76,8 +76,8 @@ def parse_cmd(
except ValueError as exc:
exit_with_message("invalid_request", str(exc), "backend")
resolved_tier, resolved_backend = effective_local_tier_and_backend(tier, normalized_backend)
- if resolved_tier == "standard":
- normalized_effort = LOCAL_HYBRID_EFFORT
+ if resolved_tier in {"medium", "high", "extra_high"}:
+ normalized_effort = resolved_tier
parse_one = partial(
local_parse,
tier=resolved_tier,
diff --git a/mineru/kit/common.py b/mineru/kit/common.py
index 7307b20f..34160c4a 100644
--- a/mineru/kit/common.py
+++ b/mineru/kit/common.py
@@ -15,7 +15,7 @@ from ..utils.image_payload import validate_image_sidecar_path
SupportedBundle = Literal["pipeline", "vlm", "all"]
KitFormat = Literal["markdown", "middle_json", "zip"]
-LocalTier = Literal["flash", "standard", "pro"]
+LocalTier = Literal["flash", "medium", "high", "extra_high"]
SUPPORTED_SUFFIXES = {
".pdf",
@@ -123,10 +123,10 @@ def effective_local_tier_and_backend(tier: Tier | None, backend: str | None) ->
from ..parser.tier import backend_for_tier, resolve_tier_and_backend
if tier is None and backend is None:
- return "standard", backend_for_tier("standard")
+ return "high", backend_for_tier("high")
resolved_tier, resolved_backend = resolve_tier_and_backend(tier=tier, backend=backend)
if tier is None and backend is None:
- resolved_backend = backend_for_tier("standard")
+ resolved_backend = backend_for_tier("high")
return resolved_tier, resolved_backend
diff --git a/mineru/kit/main.py b/mineru/kit/main.py
index 52d606c6..a1435fce 100644
--- a/mineru/kit/main.py
+++ b/mineru/kit/main.py
@@ -42,7 +42,7 @@ def parse_command(
pages: str | None = typer.Option(None, "-p", "--pages", help="Page range, e.g. '1~5' or 'all'"),
format: str = typer.Option("markdown", "-f", "--format", help="Output format: markdown, middle_json, zip"),
verbose: bool = typer.Option(False, "-v", "--verbose", help="Verbose output"),
- tier: str | None = typer.Option(None, "--tier", help="Parse tier: flash, standard, pro"),
+ tier: str | None = typer.Option(None, "--tier", help="Parse tier: flash, medium, high, extra_high"),
backend: str | None = typer.Option(None, "--backend", help="Expert backend override"),
remote: bool = typer.Option(False, "--remote", help="Use mineru.net official remote parse service"),
remote_url: str | None = typer.Option(None, "--remote-url", help="Use a custom remote parse service URL"),
@@ -80,18 +80,16 @@ def api_server_command(
host: str = typer.Option("127.0.0.1", "--host", help="Server host"),
port: int = typer.Option(8000, "--port", help="Server port"),
upload_dir: str = typer.Option("", "--upload-dir", help="Upload directory"),
- backend: str | None = typer.Option(None, "--backend", help="Expert backend override"),
tier: list[str] | None = typer.Option(
None,
"--tier",
- help="Server tier: standard or pro; repeat to expose multiple tiers (default: standard)",
+ help="Server tier: flash, medium, high, extra_high; repeat to expose multiple tiers",
),
concurrency: int = typer.Option(1, "--concurrency", help="Maximum concurrent parse jobs"),
url_timeout: int = typer.Option(60, "--url-timeout", help="Timeout for URL source downloads"),
max_wait: int = typer.Option(600, "--max-wait", help="Maximum seconds for wait parameter"),
language: str = typer.Option("ch", "--language", help="Hybrid medium OCR language hint; accepted by other efforts for compatibility"),
ocr_mode: str = typer.Option("auto", "--ocr-mode", help="OCR mode: auto, txt, ocr"),
- effort: str = typer.Option(DEFAULT_HYBRID_EFFORT, "--effort", help=HYBRID_EFFORT_HELP),
disable_table: bool = typer.Option(False, "--disable-table", help="Disable table recognition"),
disable_formula: bool = typer.Option(False, "--disable-formula", help="Disable formula recognition"),
disable_image_analysis: bool = typer.Option(False, "--disable-image-analysis", help="Disable image analysis"),
@@ -102,14 +100,12 @@ def api_server_command(
host=host,
port=port,
upload_dir=upload_dir,
- backend=backend,
tier=tier, # type: ignore[arg-type]
concurrency=concurrency,
url_timeout=url_timeout,
max_wait=max_wait,
language=language,
ocr_mode=ocr_mode, # type: ignore[arg-type]
- effort=effort, # type: ignore[arg-type]
disable_table=disable_table,
disable_formula=disable_formula,
disable_image_analysis=disable_image_analysis,
diff --git a/mineru/parser/api_client.py b/mineru/parser/api_client.py
index 42df1f94..23d0398a 100644
--- a/mineru/parser/api_client.py
+++ b/mineru/parser/api_client.py
@@ -20,7 +20,7 @@ from urllib.parse import urlparse
import httpx
-from ..types import PageInfo, Tier
+from ..types import PageInfo, Tier, validate_tier
from ..utils.image_payload import validate_image_sidecar_path
from .base import DocumentParser, ParseResult
@@ -31,12 +31,12 @@ class MinerUApiParser(DocumentParser):
Works with local-server, LAN, and cloud (mineru.net) deployments::
# local deployment — uses ``local`` source, no upload needed
- parser = MinerUApiParser(api_url="http://localhost:8000/api", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000/api", tier="medium")
# cloud (remote)
parser = MinerUApiParser(
api_url="https://mineru.net/api", api_key="sk_...",
- tier="pro",
+ tier="high",
)
result = parser.parse("report.pdf")
@@ -44,7 +44,7 @@ class MinerUApiParser(DocumentParser):
Constructor parameters:
- - ``tier`` → v1 ``tier`` (``"standard"`` / ``"pro"``); ``None`` omits the field
+ - ``tier`` → v1 ``tier`` (``"flash"`` / ``"medium"`` / ``"high"`` / ``"extra_high"``); ``None`` omits the field
- ``page_range`` → per-file v1 ``page_range``
"""
@@ -60,7 +60,7 @@ class MinerUApiParser(DocumentParser):
self._api_key = api_key
self._local = _is_local_network_url(self._base)
self._trust_env = should_trust_env_for_url(self._base)
- self.tier = tier
+ self.tier = validate_tier(tier) if tier is not None else None
# ── DocumentParser interface ─────────────────────────────────────
diff --git a/mineru/parser/api_server.py b/mineru/parser/api_server.py
index 8e8e6b06..ad5f5d55 100644
--- a/mineru/parser/api_server.py
+++ b/mineru/parser/api_server.py
@@ -37,28 +37,20 @@ from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse, StreamingResponse
from pydantic import BaseModel, ConfigDict, Field
-from ..types import Tier
-from ..utils.backend_options import (
- DEFAULT_HYBRID_EFFORT,
- HYBRID_EFFORT_CHOICES,
- HYBRID_EFFORT_HELP,
- LOCAL_HYBRID_EFFORT,
- resolve_backend_and_effort,
-)
+from ..types import Tier, validate_tier
+from ..utils.backend_options import DEFAULT_HYBRID_EFFORT
from ..utils.ocr_language import PUBLIC_OCR_LANGUAGES, validate_public_ocr_lang
from ..version import __version__
from . import parse_async
from .tier import (
- PARSER_BACKENDS,
ParserRuntimeOptions,
TierDependencyError,
ensure_tier_runtime_dependencies,
- resolve_tier_and_backend,
runtime_options_for_tier,
)
-_API_SERVER_BACKENDS = tuple(backend for backend in PARSER_BACKENDS if backend != "flash")
-_API_SERVER_TIERS: tuple[Tier, ...] = ("standard", "pro")
+_API_SERVER_TIERS: tuple[Tier, ...] = ("flash", "medium", "high", "extra_high")
+_DEFAULT_API_SERVER_TIER: Tier = "high"
_API_SERVER_LANGUAGES = PUBLIC_OCR_LANGUAGES
_MANAGED_PARSE_SERVER_ENV = "MINERU_MANAGED_PARSE_SERVER"
logger = logging.getLogger("mineru.parser.api_server")
@@ -1007,7 +999,7 @@ class _JobRecord:
created_at: str = ""
started_at: str | None = None
finished_at: str | None = None
- tier: Tier = "standard"
+ tier: Tier = _DEFAULT_API_SERVER_TIER
output_formats: list[OutputFormat] = None # type: ignore[assignment]
progress: JobProgress | None = None
files: list[JobFileResult] = None # type: ignore[assignment]
@@ -1982,75 +1974,59 @@ def _build_v1_router() -> APIRouter:
_OCR_MODES = ("auto", "txt", "ocr")
-def _resolve_server_tier_and_backend(*, tier: Tier | None, backend: str | None) -> tuple[Tier, str]:
- resolved_tier = tier
- resolved_backend = backend
- if resolved_tier is None and resolved_backend is None:
- resolved_tier = "standard"
- resolved_tier, resolved_backend = resolve_tier_and_backend(tier=resolved_tier, backend=resolved_backend)
- if resolved_backend not in _API_SERVER_BACKENDS:
- raise ValueError(f"Unsupported backend '{resolved_backend}'. Supported backends: {', '.join(_API_SERVER_BACKENDS)}")
- return resolved_tier, resolved_backend
-
-
def _normalize_server_tiers(tier: Tier | list[Tier] | tuple[Tier, ...] | None) -> list[Tier]:
- """规范化 API server 启动 tier 列表,保留用户顺序并拒绝 flash 等未开放 tier。"""
+ """规范化 API server 启动 tier 列表,保留用户顺序并拒绝旧 standard/pro tier。"""
raw_tiers: list[Tier]
if tier is None:
- raw_tiers = ["standard", "pro"]
+ raw_tiers = list(_API_SERVER_TIERS)
elif isinstance(tier, str):
- raw_tiers = [tier]
+ raw_tiers = [validate_tier(tier)]
else:
- raw_tiers = list(tier) or ["standard", "pro"]
+ raw_tiers = [validate_tier(item) for item in list(tier)] or list(_API_SERVER_TIERS)
tiers: list[Tier] = []
for item in raw_tiers:
- if item not in _API_SERVER_TIERS:
- raise ValueError(f"Unsupported tier '{item}'. Supported tiers: {', '.join(_API_SERVER_TIERS)}")
if item not in tiers:
tiers.append(item)
return tiers
-def _runtime_options_for_server_tiers(
- *,
- tiers: list[Tier],
- backend: str | None,
- effort: str,
-) -> dict[Tier, ParserRuntimeOptions]:
- """为每个启动 tier 生成独立 runtime,避免不同 tier job 共享同一个 effort。"""
- if backend is not None and len(tiers) > 1:
- raise ValueError("--backend cannot be combined with multiple --tier values")
- if backend is not None:
- tier = tiers[0]
- resolved_tier, resolved_backend = _resolve_server_tier_and_backend(tier=tier, backend=backend)
- if resolved_tier != tier:
- tiers[0] = resolved_tier
- resolved_backend, resolved_effort = resolve_backend_and_effort(backend, effort)
- if resolved_tier == "standard":
- resolved_effort = LOCAL_HYBRID_EFFORT
- return {
- resolved_tier: ParserRuntimeOptions(tier=resolved_tier, backend=resolved_backend, effort=resolved_effort)
- }
-
+def _runtime_options_for_server_tiers(tiers: list[Tier]) -> dict[Tier, ParserRuntimeOptions]:
+ """为每个启动 tier 生成独立 runtime,API server 只允许 tier 决定 backend/effort。"""
return {tier: runtime_options_for_tier(tier) for tier in tiers}
def _model_ids_and_tiers_for_server_tier(tier: Tier) -> tuple[list[str], list[dict[str, Any]]]:
- if tier == "pro":
+ if tier == "flash":
+ return ["MinerU-Flash"], [
+ {
+ "id": "flash",
+ "description": "Fast local text extraction.",
+ "current_model": "flash",
+ },
+ ]
+ if tier == "medium":
+ return ["Hybrid-Medium", "MinerU-HTML"], [
+ {
+ "id": "medium",
+ "description": "Hybrid medium parsing with local lightweight models.",
+ "current_model": "hybrid-medium",
+ },
+ ]
+ if tier == "extra_high":
return ["MinerU2.5-Pro-2604-1.2B", "MinerU-HTML"], [
{
- "id": "pro",
- "description": "Hybrid high-accuracy parsing.",
+ "id": "extra_high",
+ "description": "Hybrid maximum-accuracy parsing.",
"current_model": "MinerU2.5-Pro-2604-1.2B",
},
]
- return ["Hybrid-Low", "MinerU-HTML"], [
+ return ["MinerU2.5-Pro-2604-1.2B", "MinerU-HTML"], [
{
- "id": "standard",
- "description": "Hybrid medium parsing with local lightweight models.",
- "current_model": "hybrid-medium",
+ "id": "high",
+ "description": "Hybrid high-accuracy parsing.",
+ "current_model": "MinerU2.5-Pro-2604-1.2B",
},
]
@@ -2076,9 +2052,7 @@ def _preflight_tier_dependencies(tier: Tier) -> None:
def _dependency_tier_for_runtime(runtime: ParserRuntimeOptions) -> Tier:
- """根据实际 runtime 判断依赖预检 tier,Hybrid medium 只需要 standard 依赖。"""
- if runtime.backend.startswith("hybrid-") and runtime.effort == LOCAL_HYBRID_EFFORT:
- return "standard"
+ """根据实际 runtime 判断依赖预检 tier。"""
return runtime.tier
@@ -2097,14 +2071,12 @@ def create_app(
*,
upload_dir: str = "",
tier: Tier | list[Tier] | tuple[Tier, ...] | None = None,
- backend: str | None = None,
concurrency: int = 1,
url_timeout: int = 60,
max_wait: int = 600,
api_key: str | None = None,
language: str = "ch",
ocr_mode: str = "auto",
- effort: str = DEFAULT_HYBRID_EFFORT,
table_enable: bool = True,
formula_enable: bool = True,
image_analysis: bool = True,
@@ -2116,11 +2088,8 @@ def create_app(
upload_dir:
Directory for uploaded files and parse artifacts.
tier:
- Server parsing tier. ``"standard"`` selects Hybrid medium;
- ``"pro"`` selects the default Hybrid backend. If ``backend`` is also provided,
- both values must be compatible.
- backend:
- Advanced server backend mode. ``"hybrid-engine"`` exposes local Hybrid parsing.
+ Server parsing tier. ``"flash"`` selects flash parsing; ``"medium"``,
+ ``"high"`` and ``"extra_high"`` map to same-name Hybrid efforts.
concurrency:
Maximum concurrent parse jobs (default 1).
url_timeout:
@@ -2134,9 +2103,6 @@ def create_app(
Hybrid medium OCR language hint; accepted by other efforts for compatibility.
ocr_mode:
PDF OCR/text extraction mode for Hybrid backends.
- effort:
- Hybrid backend effort level. Medium uses local Hybrid processing. High and
- extra_high use progressively stronger VLM-assisted parsing.
table_enable:
Whether table recognition is enabled.
formula_enable:
@@ -2146,14 +2112,10 @@ def create_app(
"""
upload_dir = upload_dir or ""
tier_input = None if tier in ((), []) else tier
- if backend is not None and tier_input is None:
- inferred_tier, _resolved_backend = _resolve_server_tier_and_backend(tier=None, backend=backend)
- server_tiers = [inferred_tier]
- else:
- server_tiers = _normalize_server_tiers(tier_input)
- tier_runtime_options = _runtime_options_for_server_tiers(tiers=server_tiers, backend=backend, effort=effort)
+ server_tiers = _normalize_server_tiers(tier_input)
+ tier_runtime_options = _runtime_options_for_server_tiers(server_tiers)
server_tiers = list(tier_runtime_options)
- default_tier = server_tiers[0]
+ default_tier = _DEFAULT_API_SERVER_TIER if _DEFAULT_API_SERVER_TIER in tier_runtime_options else server_tiers[0]
default_runtime = tier_runtime_options[default_tier]
tier = default_tier
backend = default_runtime.backend
@@ -2261,23 +2223,13 @@ def create_app(
help="Upload directory (default: auto-created temp dir)",
type=click.Path(file_okay=False, writable=True, resolve_path=True),
)
- "--backend",
- default=None,
- type=str,
- help=(
- "Advanced parser backend "
- f"({', '.join(_API_SERVER_BACKENDS)}). "
- f"Defaults from --tier: standard -> hybrid-engine --effort {LOCAL_HYBRID_EFFORT}, pro -> hybrid-engine."
- ),
-)
@click.option(
"--tier",
multiple=True,
- type=click.Choice(["standard", "pro"]),
+ type=click.Choice(list(_API_SERVER_TIERS)),
help=(
"Server parsing tier; repeat to expose multiple tiers. "
- "Defaults to 'standard' and 'pro' when neither --tier nor --backend is provided."
+ "Defaults to flash, medium, high, and extra_high; requests without tier default to high."
),
)
@click.option(
@@ -2311,13 +2263,6 @@ def create_app(
type=click.Choice(_OCR_MODES),
help="PDF OCR/text extraction mode. Applies to hybrid-* backends.",
)
- "--effort",
- default=DEFAULT_HYBRID_EFFORT,
- type=str,
- metavar="[" + "|".join(HYBRID_EFFORT_CHOICES) + "]",
- help=HYBRID_EFFORT_HELP,
-)
@click.option("--disable-table", is_flag=True, help="Disable table recognition.")
@click.option("--disable-formula", is_flag=True, help="Disable formula recognition.")
@click.option("--disable-image-analysis", is_flag=True, help="Disable image analysis for Hybrid backends.")
@@ -2331,14 +2276,12 @@ def main(
host: str,
port: int,
upload_dir: str,
- backend: str | None,
tier: tuple[Tier, ...],
concurrency: int,
url_timeout: int,
max_wait: int,
language: str,
ocr_mode: str,
- effort: str,
disable_table: bool,
disable_formula: bool,
disable_image_analysis: bool,
@@ -2349,14 +2292,12 @@ def main(
application = create_app(
upload_dir=upload_dir,
tier=tier or None,
- backend=backend,
concurrency=concurrency,
url_timeout=url_timeout,
max_wait=max_wait,
api_key=api_key,
language=language,
ocr_mode=ocr_mode,
- effort=effort,
table_enable=not disable_table,
formula_enable=not disable_formula,
image_analysis=not disable_image_analysis,
diff --git a/mineru/parser/tier.py b/mineru/parser/tier.py
index 6f65ea85..50e28a31 100644
--- a/mineru/parser/tier.py
+++ b/mineru/parser/tier.py
@@ -6,17 +6,18 @@ import sys
from dataclasses import dataclass
from importlib import metadata as importlib_metadata
-from ..types import Tier
+from ..types import Tier, validate_tier
from ..utils.backend_options import (
CANONICAL_HYBRID_ENGINE,
LEGACY_PIPELINE_BACKEND_ALIASES,
LEGACY_VLM_BACKEND_ALIASES,
+ LOCAL_HYBRID_EFFORT,
SUPPORTED_BACKENDS,
+ DEFAULT_HYBRID_EFFORT,
effort_for_tier,
is_hybrid_backend,
normalize_backend,
resolve_backend_and_effort,
- validate_effort,
)
__all__ = [
@@ -86,24 +87,29 @@ class ParserRuntimeOptions:
def backend_for_tier(tier: Tier) -> str:
- """Return the local parser backend used for a parser-layer tier fallback."""
+ """返回指定 tier 使用的 parser backend,tier 自身决定质量档位。"""
+ tier = validate_tier(tier)
mapping = {
"flash": "flash",
- "standard": CANONICAL_HYBRID_ENGINE,
- "pro": CANONICAL_HYBRID_ENGINE,
+ "medium": CANONICAL_HYBRID_ENGINE,
+ "high": CANONICAL_HYBRID_ENGINE,
+ "extra_high": CANONICAL_HYBRID_ENGINE,
}
- return mapping.get(tier, CANONICAL_HYBRID_ENGINE)
+ return mapping[tier]
def tier_for_backend(backend: str) -> Tier:
+ """根据旧 backend 专家输入推断等价 tier,仅服务本地 parser 兼容入口。"""
raw_backend = (backend or "").strip()
if raw_backend in LEGACY_PIPELINE_BACKEND_ALIASES:
- return "standard"
+ return "medium"
+ if raw_backend in LEGACY_VLM_BACKEND_ALIASES:
+ return "extra_high"
normalized_backend = normalize_backend(backend)
if normalized_backend == "flash":
return "flash"
if is_hybrid_backend(normalized_backend):
- return "pro"
+ return DEFAULT_HYBRID_EFFORT # type: ignore[return-value]
raise ValueError(f"Unsupported backend '{backend}'. Supported backends: {', '.join(PARSER_BACKENDS)}")
@@ -112,18 +118,24 @@ def _backend_supports_tier(backend: str, tier: Tier) -> bool:
normalized_backend = normalize_backend(backend)
if tier == "flash":
return normalized_backend == "flash"
- if tier == "standard":
+ if tier == "medium":
return raw_backend in LEGACY_PIPELINE_BACKEND_ALIASES or (
is_hybrid_backend(normalized_backend) and raw_backend not in LEGACY_VLM_BACKEND_ALIASES
)
- if tier == "pro":
+ if tier == "high":
+ return (
+ is_hybrid_backend(normalized_backend)
+ and raw_backend not in LEGACY_PIPELINE_BACKEND_ALIASES
+ and raw_backend not in LEGACY_VLM_BACKEND_ALIASES
+ )
+ if tier == "extra_high":
return is_hybrid_backend(normalized_backend) and raw_backend not in LEGACY_PIPELINE_BACKEND_ALIASES
return False
def resolve_tier_and_backend(tier: Tier | None = None, backend: str | None = None) -> tuple[Tier, str]:
- """Resolve public tier and optional expert backend into an executable parser backend."""
- resolved_tier: Tier = tier or "pro"
+ """将公开 tier 和本地专家 backend 解析为可执行 parser backend。"""
+ resolved_tier: Tier = validate_tier(tier) if tier is not None else "high"
if backend:
normalized_backend = normalize_backend(backend)
if tier is None:
@@ -140,14 +152,17 @@ def _effort_for_runtime(
backend: str,
requested_effort: str | None,
raw_backend: str | None,
+ explicit_tier: bool,
) -> str:
- """按 tier 优先级解析 Hybrid effort,并保留旧 backend alias 的兼容覆盖。"""
+ """按 tier 优先解析 Hybrid effort;无 tier 时保留旧 backend/effort 兼容输入。"""
if backend == "flash":
- return validate_effort(requested_effort)
- default_effort = effort_for_tier(tier)
- resolved_backend, resolved_effort = resolve_backend_and_effort(raw_backend or backend, requested_effort or default_effort)
- if tier == "standard" and is_hybrid_backend(resolved_backend):
- return effort_for_tier("standard")
+ return LOCAL_HYBRID_EFFORT
+ if explicit_tier:
+ return effort_for_tier(tier)
+ _resolved_backend, resolved_effort = resolve_backend_and_effort(
+ raw_backend or backend,
+ requested_effort or DEFAULT_HYBRID_EFFORT,
+ )
return resolved_effort
@@ -157,14 +172,19 @@ def resolve_runtime_options(
effort: str | None = None,
) -> ParserRuntimeOptions:
"""统一解析 parser 运行所需的 tier/backend/effort,避免入口各自硬编码映射。"""
+ explicit_tier = tier is not None
resolved_tier, resolved_backend = resolve_tier_and_backend(tier=tier, backend=backend)
- resolved_backend, _ = resolve_backend_and_effort(backend or resolved_backend, effort)
+ if resolved_backend != "flash":
+ resolved_backend, _ = resolve_backend_and_effort(backend or resolved_backend, effort)
resolved_effort = _effort_for_runtime(
tier=resolved_tier,
backend=resolved_backend,
requested_effort=effort,
raw_backend=backend,
+ explicit_tier=explicit_tier,
)
+ if not explicit_tier and resolved_backend != "flash":
+ resolved_tier = validate_tier(resolved_effort)
return ParserRuntimeOptions(tier=resolved_tier, backend=resolved_backend, effort=resolved_effort)
@@ -179,9 +199,10 @@ def runtime_options_for_tier(
def required_modules_for_tier(tier: Tier) -> list[str]:
- if tier == "standard":
+ tier = validate_tier(tier)
+ if tier == "medium":
return list(_STANDARD_REQUIRED_MODULES)
- if tier == "pro":
+ if tier in {"high", "extra_high"}:
return [
*_PRO_REQUIRED_MODULES_COMMON,
*_PRO_REQUIRED_MODULES_BY_PLATFORM.get(sys.platform, []),
diff --git a/mineru/types.py b/mineru/types.py
index 9268a4f3..f0df1be6 100644
--- a/mineru/types.py
+++ b/mineru/types.py
@@ -9,23 +9,34 @@ T = TypeVar("T", bound="_DocElement")
Tier = Literal[
"flash",
- "standard",
- "pro",
+ "medium",
+ "high",
+ "extra_high",
]
TIERS: set[Tier] = {
"flash",
- "standard",
- "pro",
+ "medium",
+ "high",
+ "extra_high",
}
TIER_ORDER: dict[Tier, int] = {
"flash": 0,
- "standard": 1,
- "pro": 2,
+ "medium": 1,
+ "high": 2,
+ "extra_high": 3,
}
+def validate_tier(tier: str | None) -> Tier:
+ """校验公开 tier 取值,保证入口只接受 flash/medium/high/extra_high。"""
+ normalized = (tier or "").strip().lower()
+ if normalized in TIERS:
+ return normalized # type: ignore[return-value]
+ raise ValueError(f"Unsupported tier '{tier}'. Supported tiers: {', '.join(TIERS)}")
+
+
class BlockType:
IMAGE = "image"
IMAGE_BODY = "image_body"
diff --git a/mineru/utils/backend_options.py b/mineru/utils/backend_options.py
index ca96ba6b..d7213768 100644
--- a/mineru/utils/backend_options.py
+++ b/mineru/utils/backend_options.py
@@ -27,8 +27,9 @@ HYBRID_EFFORT_CHOICES: Final[tuple[str, ...]] = (
MAX_HYBRID_EFFORT,
)
HYBRID_EFFORT_BY_TIER: Final[dict[str, str]] = {
- "standard": LOCAL_HYBRID_EFFORT,
- "pro": LAYOUT_HYBRID_EFFORT,
+ LOCAL_HYBRID_EFFORT: LOCAL_HYBRID_EFFORT,
+ LAYOUT_HYBRID_EFFORT: LAYOUT_HYBRID_EFFORT,
+ MAX_HYBRID_EFFORT: MAX_HYBRID_EFFORT,
}
BACKEND_SCHEMA_EXTRA: Final[dict[str, list[str]]] = {"enum": list(PUBLIC_BACKEND_CHOICES)}
HYBRID_EFFORT_SCHEMA_EXTRA: Final[dict[str, list[str]]] = {"enum": list(HYBRID_EFFORT_CHOICES)}
@@ -83,7 +84,7 @@ def validate_effort(effort: str | None) -> str:
def effort_for_tier(tier: str | None) -> str:
- """将公开 tier 映射为 Hybrid 默认 effort,保证 API、Gradio 与 parser 使用同一规则。"""
+ """将公开 tier 映射为 Hybrid effort,保证 API、Gradio 与 parser 使用同一规则。"""
normalized = (tier or "").strip().lower()
if normalized in HYBRID_EFFORT_BY_TIER:
return HYBRID_EFFORT_BY_TIER[normalized]
diff --git a/pyproject.toml b/pyproject.toml
index 25a6de4c..84e7e111 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -90,6 +90,9 @@ standard = [
"torchvision",
"transformers>=4.57.3,<5.0.0",
]
+medium = [
+ "mineru[standard]",
+]
pro = [
"mineru[standard]",
"accelerate>=1.5.1",
@@ -99,6 +102,12 @@ pro = [
"mlx<=0.31.1 ; sys_platform == 'darwin'",
"mlx-vlm>=0.3.3,<0.4 ; sys_platform == 'darwin'",
]
+high = [
+ "mineru[pro]",
+]
+extra_high = [
+ "mineru[pro]",
+]
vlm = [
"torch>=2.6.0,<3",
diff --git a/tests/unittest/test_doclib_app_startup.py b/tests/unittest/test_doclib_app_startup.py
index d001f549..3c590700 100644
--- a/tests/unittest/test_doclib_app_startup.py
+++ b/tests/unittest/test_doclib_app_startup.py
@@ -76,7 +76,7 @@ def test_config_set_managed_mode_preflights_managed_tier_dependencies(monkeypatc
assert payload["error"]["code"] == "parse_server_dependency_missing"
assert payload["error"]["param"] == "parse_server.local.mode"
assert "torch" in payload["error"]["message"]
- assert "pip install 'mineru-next-dev[standard]'" in payload["error"]["message"]
+ assert "pip install 'mineru-next-dev[high]'" in payload["error"]["message"]
assert config_response.json()["value"] == "disabled"
@@ -96,7 +96,7 @@ def test_config_set_managed_tier_preflights_even_when_mode_is_disabled(monkeypat
cfg = PatchedConfig(doclib={"data_dir": str(tmp_path), "sqlite": {"path": str(tmp_path / "doclib.db")}})
with TestClient(doclib_app.create_app(cfg)) as client:
- response = client.put("/api/v1/configs/parse_server.local.managed_tier", json={"value": "pro"})
+ response = client.put("/api/v1/configs/parse_server.local.managed_tier", json={"value": "extra_high"})
config_response = client.get("/api/v1/configs/parse_server.local.managed_tier")
assert response.status_code == 400
@@ -104,8 +104,8 @@ def test_config_set_managed_tier_preflights_even_when_mode_is_disabled(monkeypat
assert payload["error"]["code"] == "parse_server_dependency_missing"
assert payload["error"]["param"] == "parse_server.local.managed_tier"
assert "mlx" in payload["error"]["message"]
- assert "pip install 'mineru-next-dev[pro]'" in payload["error"]["message"]
- assert config_response.json()["value"] == "standard"
+ assert "pip install 'mineru-next-dev[extra_high]'" in payload["error"]["message"]
+ assert config_response.json()["value"] == "high"
def test_background_task_crash_is_logged(caplog: pytest.LogCaptureFixture) -> None:
diff --git a/tests/unittest/test_doclib_cache_semantics.py b/tests/unittest/test_doclib_cache_semantics.py
index e09b75c0..07ed339a 100644
--- a/tests/unittest/test_doclib_cache_semantics.py
+++ b/tests/unittest/test_doclib_cache_semantics.py
@@ -257,7 +257,7 @@ def _text_page(text: str) -> PageInfo:
def test_load_pages_from_done_batches_keeps_newest_page_idx(tmp_path: Path) -> None:
sha256 = "a" * 64
- tier = "standard"
+ tier = "high"
older_page = {"page_idx": 1, "page_size": [100, 100], "para_blocks": []}
older_duplicate = {"page_idx": 2, "page_size": [100, 100], "para_blocks": []}
newer_duplicate = {"page_idx": 2, "page_size": [200, 200], "para_blocks": []}
@@ -279,24 +279,25 @@ def test_load_pages_from_done_batches_keeps_newest_page_idx(tmp_path: Path) -> N
def test_parser_tier_backend_mapping_is_parser_layer_only() -> None:
assert backend_for_tier("flash") == "flash"
- assert backend_for_tier("standard") == "hybrid-engine"
- assert backend_for_tier("pro") == "hybrid-engine"
- assert resolve_tier_and_backend(tier=None) == ("pro", "hybrid-engine")
- assert resolve_tier_and_backend(tier="pro", backend="vlm-auto-engine") == ("pro", "hybrid-engine")
+ assert backend_for_tier("medium") == "hybrid-engine"
+ assert backend_for_tier("high") == "hybrid-engine"
+ assert backend_for_tier("extra_high") == "hybrid-engine"
+ assert resolve_tier_and_backend(tier=None) == ("high", "hybrid-engine")
+ assert resolve_tier_and_backend(tier="extra_high", backend="vlm-auto-engine") == ("extra_high", "hybrid-engine")
def test_managed_api_server_args_use_tier_and_selected_port_for_process_start() -> None:
- assert api_server_args_for_tier("standard", host="127.0.0.1", port=16580) == [
+ assert api_server_args_for_tier("high", host="127.0.0.1", port=16580) == [
"--tier",
- "standard",
+ "high",
"--host",
"127.0.0.1",
"--port",
"16580",
]
- assert api_server_args_for_tier("pro", host="127.0.0.2", port=16581) == [
+ assert api_server_args_for_tier("extra_high", host="127.0.0.2", port=16581) == [
"--tier",
- "pro",
+ "extra_high",
"--host",
"127.0.0.2",
"--port",
@@ -342,7 +343,7 @@ def test_default_tier_error_mentions_remote_when_remote_is_healthy(monkeypatch:
local_healthy=False,
local_supported_tiers=["flash"],
remote_healthy=True,
- remote_supported_tiers=["standard", "pro"],
+ remote_supported_tiers=["high", "extra_high"],
)
monkeypatch.setattr("mineru.doclib.background.parse_server_health.get_health", lambda: health)
@@ -386,7 +387,7 @@ def test_parse_server_health_probe_disables_env_proxy_for_local_urls(monkeypatch
status_code = 200
def json(self) -> dict[str, list[dict[str, str]]]:
- return {"data": [{"id": "standard"}]}
+ return {"data": [{"id": "high"}]}
class _AsyncClient:
def __init__(self, *, timeout: int, trust_env: bool) -> None:
@@ -404,8 +405,8 @@ def test_parse_server_health_probe_disables_env_proxy_for_local_urls(monkeypatch
monkeypatch.setattr("mineru.doclib.background.parse_server_health.httpx.AsyncClient", _AsyncClient)
checker = ParseServerHealthCheck(None, interval_sec=1, probe_timeout_sec=2, startup_grace_sec=3, stop_timeout_sec=4)
- assert asyncio.run(checker._probe("http://127.0.0.1:16580")) == (True, ["standard"])
- assert asyncio.run(checker._probe("https://staging.mineru.org.cn/api")) == (True, ["standard"])
+ assert asyncio.run(checker._probe("http://127.0.0.1:16580")) == (True, ["high"])
+ assert asyncio.run(checker._probe("https://staging.mineru.org.cn/api")) == (True, ["high"])
assert calls == [False, True]
@@ -421,7 +422,7 @@ def test_start_managed_parse_server_selects_port_and_writes_logs(monkeypatch: py
popen_calls.append({"args": args, "kwargs": kwargs})
cmd = args[0]
assert "--tier" in cmd
- assert cmd[cmd.index("--tier") + 1] == "standard"
+ assert cmd[cmd.index("--tier") + 1] == "high"
assert "--host" in cmd
assert cmd[cmd.index("--host") + 1] == "127.0.0.2"
assert "--port" in cmd
@@ -443,7 +444,7 @@ def test_start_managed_parse_server_selects_port_and_writes_logs(monkeypatch: py
monkeypatch.setattr("mineru.doclib.background.parse_server_health.subprocess.Popen", _popen)
proc, url = start_managed_parse_server(
- tier="standard",
+ tier="high",
managed_cfg=ManagedParseServerConfig(host="127.0.0.2", port=16580, port_probe_count=3),
log_cfg=LogConfig(
parse_server_stdout_path=str(parse_stdout_log_path),
@@ -501,7 +502,7 @@ def test_managed_parse_server_restart_writes_stdout_and_stderr_logs(monkeypatch:
class _ConfigSvc:
async def get(self, key: str) -> str:
assert key == "parse_server.local.managed_tier"
- return "standard"
+ return "high"
class _Proc:
pid = 12345
@@ -558,7 +559,7 @@ def test_managed_parse_server_restart_stops_recorded_proc_before_start(monkeypat
class _ConfigSvc:
async def get(self, key: str) -> str:
assert key == "parse_server.local.managed_tier"
- return "standard"
+ return "high"
class _Proc:
pid = 67890
@@ -627,14 +628,14 @@ def test_managed_parse_server_tier_change_detection_triggers_restart(monkeypatch
calls.append((reason, marker or "", count_restart))
monkeypatch.setattr(checker, "_try_restart_managed", _restart)
- health = ParseServerHealth(running_managed_tier="standard")
+ health = ParseServerHealth(running_managed_tier="high")
- restarted = asyncio.run(checker._try_restart_managed_for_tier_change(health, "pro"))
- unchanged = asyncio.run(checker._try_restart_managed_for_tier_change(health, "standard"))
+ restarted = asyncio.run(checker._try_restart_managed_for_tier_change(health, "extra_high"))
+ unchanged = asyncio.run(checker._try_restart_managed_for_tier_change(health, "high"))
assert restarted is True
assert unchanged is False
- assert calls == [("tier-change", "tier change standard->pro", False)]
+ assert calls == [("tier-change", "tier change high->extra_high", False)]
def test_managed_parse_server_tier_change_restart_uses_desired_tier(monkeypatch: pytest.MonkeyPatch) -> None:
@@ -644,7 +645,7 @@ def test_managed_parse_server_tier_change_restart_uses_desired_tier(monkeypatch:
class _ConfigSvc:
async def get(self, key: str) -> str:
assert key == "parse_server.local.managed_tier"
- return "pro"
+ return "extra_high"
class _Proc:
pid = 24680
@@ -656,10 +657,10 @@ def test_managed_parse_server_tier_change_restart_uses_desired_tier(monkeypatch:
events.append("stop")
def _start(*, tier: Tier, managed_cfg: ManagedParseServerConfig, log_cfg: LogConfig | None, marker: str) -> tuple[_Proc, str]:
- assert tier == "pro"
+ assert tier == "extra_high"
assert managed_cfg.host == "127.0.0.2"
assert log_cfg is None
- assert marker == "tier change standard->pro"
+ assert marker == "tier change high->extra_high"
events.append("start")
return _Proc(), "http://127.0.0.2:16582"
@@ -674,20 +675,20 @@ def test_managed_parse_server_tier_change_restart_uses_desired_tier(monkeypatch:
stop_timeout_sec=4,
managed_parse_server=ManagedParseServerConfig(host="127.0.0.2", port=16580, port_probe_count=3),
)
- health = ParseServerHealth(managed_proc=old_proc, running_managed_tier="standard", restart_count=2)
+ health = ParseServerHealth(managed_proc=old_proc, running_managed_tier="high", restart_count=2)
asyncio.run(
checker._try_restart_managed(
health,
reason="tier-change",
- marker="tier change standard->pro",
+ marker="tier change high->extra_high",
count_restart=False,
)
)
assert events == ["stop", "start"]
assert health.managed_proc.pid == 24680
- assert health.running_managed_tier == "pro"
+ assert health.running_managed_tier == "extra_high"
assert health.restart_count == 2
@@ -764,7 +765,7 @@ def test_remote_parse_server_default_url_is_declared_once() -> None:
def test_compaction_uses_configured_data_dir(tmp_path: Path) -> None:
sha256 = "b" * 64
- tier = "standard"
+ tier = "high"
older_page = {"page_idx": 0, "content": "old"}
older_duplicate = {"page_idx": 1, "content": "old"}
newer_duplicate = {"page_idx": 1, "content": "new"}
@@ -790,12 +791,12 @@ def test_compaction_uses_configured_data_dir(tmp_path: Path) -> None:
def test_invalidate_deletes_fts_when_no_done_batches_remain(tmp_path: Path) -> None:
sha256 = "c" * 64
- parses = [{"sha256": sha256, "tier": "standard", "page_range": "1", "status": "done", "done_at": 1000}]
+ parses = [{"sha256": sha256, "tier": "high", "page_range": "1", "status": "done", "done_at": 1000}]
db = _FakeDB(parses=parses, file_row={"sha256": sha256, "status": "active", "filename": "doc.pdf"})
fts = _FakeFTS()
service = ParseService(db=db, fts=fts, config_svc=None, data_dir=str(tmp_path), parse_lock_timeout_sec=1800)
- count = asyncio.run(service.invalidate(sha256, "standard"))
+ count = asyncio.run(service.invalidate(sha256, "high"))
assert count == 1
assert parses[0]["status"] == "superseded"
@@ -806,16 +807,16 @@ def test_invalidate_deletes_fts_when_no_done_batches_remain(tmp_path: Path) -> N
def test_invalidate_rebuilds_fts_from_highest_remaining_done_tier(tmp_path: Path) -> None:
sha256 = "d" * 64
_write_batch(tmp_path, sha256, "flash", "1", 1000, [{"page_idx": 1, "page_size": [100, 100], "para_blocks": []}])
- _write_batch(tmp_path, sha256, "standard", "1", 2000, [{"page_idx": 1, "page_size": [200, 200], "para_blocks": []}])
+ _write_batch(tmp_path, sha256, "high", "1", 2000, [{"page_idx": 1, "page_size": [200, 200], "para_blocks": []}])
parses = [
{"sha256": sha256, "tier": "flash", "page_range": "1", "status": "done", "done_at": 1000},
- {"sha256": sha256, "tier": "standard", "page_range": "1", "status": "done", "done_at": 2000},
+ {"sha256": sha256, "tier": "high", "page_range": "1", "status": "done", "done_at": 2000},
]
db = _FakeDB(parses=parses, file_row={"sha256": sha256, "status": "active", "filename": "doc.pdf"})
fts = _FakeFTS()
service = ParseService(db=db, fts=fts, config_svc=None, data_dir=str(tmp_path), parse_lock_timeout_sec=1800)
- count = asyncio.run(service.invalidate(sha256, "standard"))
+ count = asyncio.run(service.invalidate(sha256, "high"))
assert count == 1
assert fts.deleted == []
@@ -920,7 +921,7 @@ def test_request_parse_explicit_image_ingests_and_queues_parse(tmp_path: Path, m
@pytest.mark.parametrize("ext", ["txt", "html", "docx", "pptx", "xlsx"])
[email protected]("tier", ["standard", "pro"])
[email protected]("tier", ["high", "extra_high"])
def test_request_parse_rejects_quality_tiers_for_non_pdf_image_inputs(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
@@ -1139,7 +1140,7 @@ def test_force_request_reuses_active_and_creates_only_uncovered_parse(tmp_path:
{
"id": 10,
"sha256": sha256,
- "tier": "standard",
+ "tier": "high",
"page_range": "1~5",
"status": "done",
"priority": 0,
@@ -1149,7 +1150,7 @@ def test_force_request_reuses_active_and_creates_only_uncovered_parse(tmp_path:
{
"id": 11,
"sha256": sha256,
- "tier": "standard",
+ "tier": "high",
"page_range": "6~8",
"status": "pending",
"priority": 0,
@@ -1174,7 +1175,7 @@ def test_force_request_reuses_active_and_creates_only_uncovered_parse(tmp_path:
)
service = ParseService(db=db, fts=_FakeFTS(), config_svc=None, data_dir=str(tmp_path), parse_lock_timeout_sec=1800)
- result = asyncio.run(service.request_parse(path, tier="standard", page_range="1~10", force=True))
+ result = asyncio.run(service.request_parse(path, tier="high", page_range="1~10", force=True))
assert isinstance(result, ParseResponse)
assert result.wait_parse_ids == [11, 12]
@@ -1190,11 +1191,11 @@ def test_force_request_reuses_active_and_creates_only_uncovered_parse(tmp_path:
def test_list_parse_records_by_ids_returns_precise_status(tmp_path: Path) -> None:
parses = [
- {"id": 1, "sha256": "f" * 64, "tier": "standard", "page_range": "1~5", "status": "done", "done_at": 1000},
+ {"id": 1, "sha256": "f" * 64, "tier": "high", "page_range": "1~5", "status": "done", "done_at": 1000},
{
"id": 2,
"sha256": "f" * 64,
- "tier": "standard",
+ "tier": "high",
"page_range": "6~10",
"status": "failed",
"error_code": "parse_failed",
@@ -1210,7 +1211,7 @@ def test_list_parse_records_by_ids_returns_precise_status(tmp_path: Path) -> Non
{
"id": 2,
"sha256": "f" * 64,
- "tier": "standard",
+ "tier": "high",
"page_range": "6~10",
"status": "failed",
"done_at": None,
@@ -1221,7 +1222,7 @@ def test_list_parse_records_by_ids_returns_precise_status(tmp_path: Path) -> Non
{
"id": 1,
"sha256": "f" * 64,
- "tier": "standard",
+ "tier": "high",
"page_range": "1~5",
"status": "done",
"done_at": 1000,
@@ -1544,8 +1545,8 @@ def test_search_filters_by_tier_min_tier_and_file_type(tmp_path: Path) -> None:
now = 1000
docs = [
("1" * 64, "flash", "pdf", "flash.pdf", 2),
- ("2" * 64, "standard", "pdf", "standard.pdf", 12),
- ("3" * 64, "pro", "docx", "pro.docx", 23),
+ ("2" * 64, "high", "pdf", "standard.pdf", 12),
+ ("3" * 64, "extra_high", "docx", "pro.docx", 23),
]
for sha256, tier, file_type, filename, page_count in docs:
@@ -1561,16 +1562,16 @@ def test_search_filters_by_tier_min_tier_and_file_type(tmp_path: Path) -> None:
)
await fts.replace(sha256=sha256, tier=tier, text="needle content", title="", author="", filename=filename)
- exact_results, exact_total = await service.search("needle", tier="standard")
- min_results, min_total = await service.search("needle", min_tier="standard")
+ exact_results, exact_total = await service.search("needle", tier="high")
+ min_results, min_total = await service.search("needle", min_tier="high")
type_results, type_total = await service.search("needle", file_type="docx")
assert exact_total == 1
- assert [row["tier"] for row in exact_results] == ["standard"]
+ assert [row["tier"] for row in exact_results] == ["high"]
assert [row["short_id"] for row in exact_results] == ["2" * 7]
assert [row["page_count"] for row in exact_results] == [12]
assert min_total == 2
- assert {row["tier"] for row in min_results} == {"standard", "pro"}
+ assert {row["tier"] for row in min_results} == {"high", "extra_high"}
assert type_total == 1
assert [row["filename"] for row in type_results] == ["pro.docx"]
assert [row["short_id"] for row in type_results] == ["3" * 7]
@@ -1596,7 +1597,7 @@ def test_search_prefers_active_paths_and_falls_back_to_non_active_paths(tmp_path
(sha256, sha256[:7], 10, "pdf", 7 if sha256 == sha_active else 9, now, now),
)
await fts.replace(
- sha256=sha256, tier="standard", text="fallback needle", title="", author="", filename=f"{sha256[0]}.pdf"
+ sha256=sha256, tier="high", text="fallback needle", title="", author="", filename=f"{sha256[0]}.pdf"
)
await db.execute(
@@ -2214,7 +2215,7 @@ def test_doclib_server_list_responses_include_pagination_metadata(tmp_path: Path
)
await db.execute(
"INSERT INTO parses (sha256, tier, page_range, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)",
- (sha256, "standard", "1", "pending", now, now),
+ (sha256, "high", "1", "pending", now, now),
)
await db.execute(
"INSERT INTO scans (path, kind, source, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)",
@@ -2286,12 +2287,12 @@ def test_doclib_server_accepts_short_id_for_sha256_doc_inputs(tmp_path: Path) ->
await db.execute(
"INSERT INTO parses (sha256, tier, page_range, status, privacy, done_at, created_at, updated_at) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
- (sha256, "standard", "1", "done", "local", now, now, now),
+ (sha256, "high", "1", "done", "local", now, now, now),
)
_write_batch(
tmp_path,
sha256,
- "standard",
+ "high",
"1",
now,
ParseResult([_text_page("hello short id")]).to_dict(skip_defaults=True)["pages"],
@@ -2302,13 +2303,13 @@ def test_doclib_server_accepts_short_id_for_sha256_doc_inputs(tmp_path: Path) ->
parses_by_short_id = await server.list_parses(doc_ref=short_id)
parses_by_sha256 = await server.list_parses(doc_ref=sha256)
missing_parses = await server.list_parses(doc_ref="ccccccc")
- content = await server.get_doc_content(short_id, tier="standard", page_range="1")
+ content = await server.get_doc_content(short_id, tier="high", page_range="1")
export_path = tmp_path / "out.md"
exported = await server.export_doc_content(
short_id,
- DocContentExportRequest(tier="standard", page_range="1", output=str(export_path)),
+ DocContentExportRequest(tier="high", page_range="1", output=str(export_path)),
)
- invalidated = await server.invalidate(InvalidateRequest(doc_ref=short_id, tier="standard"))
+ invalidated = await server.invalidate(InvalidateRequest(doc_ref=short_id, tier="high"))
assert doc_by_short_id.sha256 == sha256
assert doc_by_short_id.short_id == short_id
@@ -2353,7 +2354,7 @@ def test_doc_content_invalid_after_cursor_returns_invalid_locator(tmp_path: Path
)
try:
with pytest.raises(InvalidRequestError) as exc_info:
- await server.get_doc_content(short_id, tier="standard", after="invalid-cursor-for-param-test")
+ await server.get_doc_content(short_id, tier="high", after="invalid-cursor-for-param-test")
assert exc_info.value.code == "invalid_locator"
assert exc_info.value.param == "after"
@@ -2691,12 +2692,12 @@ def test_server_status_includes_watch_stats_and_error_summary(tmp_path: Path) ->
)
await db.execute(
"INSERT INTO parses (sha256, tier, page_range, status, privacy, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)",
- (sha_done, "standard", "1", "done", "local", now, now),
+ (sha_done, "high", "1", "done", "local", now, now),
)
await db.execute(
"INSERT INTO parses (sha256, tier, page_range, status, privacy, error_code, created_at, updated_at) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
- (sha_pending, "standard", "1", "failed", "local", "parse_failed", now, now),
+ (sha_pending, "high", "1", "failed", "local", "parse_failed", now, now),
)
for index in range(6):
await db.execute(
@@ -2784,11 +2785,11 @@ def test_forget_path_deletes_file_row_and_filename_fts_without_deleting_doc(tmp_
)
await db.execute(
"INSERT INTO parses (sha256, tier, page_range, status, privacy, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)",
- (sha256, "standard", "1", "done", "local", now, now),
+ (sha256, "high", "1", "done", "local", now, now),
)
await db.execute(
"INSERT INTO fts_contents (sha256, tier, text, filename) VALUES (?, ?, ?, ?)",
- (sha256, "standard", "content", "doc.pdf"),
+ (sha256, "high", "content", "doc.pdf"),
)
await db.execute(
"INSERT INTO files (path, filename, ext, size_bytes, mtime_ms, sha256, status, first_seen_at, updated_at) "
@@ -3126,7 +3127,7 @@ def test_process_doc_writes_cached_image_sidecars(tmp_path: Path) -> None:
def test_load_pages_from_done_batches_keeps_existing_image_sidecar(tmp_path: Path) -> None:
sha256 = "e" * 64
- tier = "standard"
+ tier = "high"
page = _image_page("figures/existing.jpg")
_write_batch(tmp_path, sha256, tier, "1", 1000, ParseResult([page]).to_dict(skip_defaults=True)["pages"])
sidecar = tmp_path / "parsed" / sha256[:2] / sha256 / tier / "images" / "figures" / "existing.jpg"
@@ -3140,7 +3141,7 @@ def test_load_pages_from_done_batches_keeps_existing_image_sidecar(tmp_path: Pat
def test_progressive_markdown_uses_public_image_sidecar_prefix(tmp_path: Path) -> None:
sha256 = "e" * 64
- tier = "standard"
+ tier = "high"
page = _image_page("figures/rendered.jpg")
_write_batch(tmp_path, sha256, tier, "1", 1000, ParseResult([page]).to_dict(skip_defaults=True)["pages"])
image_dir = tmp_path / "parsed" / sha256[:2] / sha256 / tier / "images"
@@ -3178,7 +3179,7 @@ def test_progressive_markdown_uses_public_image_sidecar_prefix(tmp_path: Path) -
def test_doclib_office_image_asset_reads_cached_sidecar(tmp_path: Path) -> None:
sha256 = "f" * 64
- tier = "standard"
+ tier = "high"
image_dir = Path(parse_image_sidecar_dir(str(tmp_path), sha256, tier))
image_path = "figures/office.png"
sidecar = image_dir / image_path
@@ -3203,7 +3204,7 @@ def test_doclib_office_image_asset_reads_cached_sidecar(tmp_path: Path) -> None:
tier=tier,
page_range=None,
after=None,
- locator="doc:fffffff/tier:standard/page:1/block:1",
+ locator="doc:fffffff/tier:high/page:1/block:1",
context=0,
limit=30000,
format="image",
@@ -3222,7 +3223,7 @@ def test_doclib_office_image_asset_reads_cached_sidecar(tmp_path: Path) -> None:
def test_doclib_office_image_asset_transcodes_to_requested_format(tmp_path: Path) -> None:
sha256 = "f" * 64
- tier = "standard"
+ tier = "high"
image_dir = Path(parse_image_sidecar_dir(str(tmp_path), sha256, tier))
image_path = "figures/office.png"
sidecar = image_dir / image_path
@@ -3247,7 +3248,7 @@ def test_doclib_office_image_asset_transcodes_to_requested_format(tmp_path: Path
tier=tier,
page_range=None,
after=None,
- locator="doc:fffffff/tier:standard/page:1/block:1",
+ locator="doc:fffffff/tier:high/page:1/block:1",
context=0,
limit=30000,
format="image",
diff --git a/tests/unittest/test_doclib_interface_contract.py b/tests/unittest/test_doclib_interface_contract.py
index e72139f4..4ef00d8e 100644
--- a/tests/unittest/test_doclib_interface_contract.py
+++ b/tests/unittest/test_doclib_interface_contract.py
@@ -362,7 +362,7 @@ def test_core_doclib_schemas_are_instantiable() -> None:
keywords="a,b",
page_count=3,
is_image_based=0,
- meta_tier="standard",
+ meta_tier="high",
first_seen_at=40,
updated_at=50,
files=[file_info],
@@ -372,7 +372,7 @@ def test_core_doclib_schemas_are_instantiable() -> None:
id=1,
sha256="abc",
short_id="abc",
- tier="standard",
+ tier="high",
page_range="1~2",
status="pending",
priority=10,
@@ -384,7 +384,7 @@ def test_core_doclib_schemas_are_instantiable() -> None:
error_code="parse_failed",
error_msg="failed",
)
- tier_info = TierParseInfo(tier="standard", page_range="1~2", status="pending")
+ tier_info = TierParseInfo(tier="high", page_range="1~2", status="pending")
info = FileInfoResponse(
file=file_info,
doc=doc_info,
@@ -393,7 +393,7 @@ def test_core_doclib_schemas_are_instantiable() -> None:
)
watch = WatchInfo(id=1, path="/tmp", recursive=True, status="active", last_scan_at=100, last_scan_files=3)
exclude_rule = ExcludeRuleInfo(id=2, pattern="*.tmp", hit_count=4)
- parsing_rule = ParsingRuleInfo(id=3, pattern="*.pdf", tier="standard", page_range="1~5", remote=True)
+ parsing_rule = ParsingRuleInfo(id=3, pattern="*.pdf", tier="high", page_range="1~5", remote=True)
watches = WatchListResponse(watches=[watch])
exclude_rules = ExcludeRuleListResponse(rules=[exclude_rule])
parsing_rules = ParsingRuleListResponse(rules=[parsing_rule])
@@ -407,7 +407,7 @@ def test_core_doclib_schemas_are_instantiable() -> None:
last_probe_at=1000,
last_success_at=900,
last_failure_at=800,
- supported_tiers=["standard"],
+ supported_tiers=["high"],
),
remote=RemoteParseServerStatus(
healthy=False,
@@ -422,7 +422,7 @@ def test_core_doclib_schemas_are_instantiable() -> None:
sha256="abc",
short_id="abc",
filename="a.pdf",
- tier="standard",
+ tier="high",
snippet="matched text",
paths=["/tmp/a.pdf"],
)
@@ -432,11 +432,11 @@ def test_core_doclib_schemas_are_instantiable() -> None:
config = ConfigResponse(config={"parse_server.local.mode": "managed"}, sources={"parse_server.local.mode": "override"})
shutdown_response = ShutdownResponse(accepted=True, message="Server shutting down...")
remove_watch_response = RemoveWatchResponse(watch_id=1, removed=True)
- export_request = DocContentExportRequest(tier="standard", output="/tmp/a.md")
+ export_request = DocContentExportRequest(tier="high", output="/tmp/a.md")
remove_exclude_response = RemoveExcludeRuleResponse(rule_id=2, removed=True)
remove_parsing_response = RemoveParsingRuleResponse(rule_id=3, removed=True)
exclude_rule_request = ExcludeRuleRequest(pattern="*.tmp")
- parsing_rule_request = ParsingRuleRequest(pattern="*.pdf", tier="standard", page_range="1~5")
+ parsing_rule_request = ParsingRuleRequest(pattern="*.pdf", tier="high", page_range="1~5")
error_info = ErrorInfo(type="invalid_request_error", code="file_not_found", message="missing", param="path")
error_response = ErrorResponse(error=error_info)
@@ -487,7 +487,7 @@ def test_core_doclib_schemas_are_instantiable() -> None:
assert remove_exclude_response.rule_id == 2
assert remove_parsing_response.rule_id == 3
assert exclude_rule_request.pattern == "*.tmp"
- assert parsing_rule_request.tier == "standard"
+ assert parsing_rule_request.tier == "high"
assert error_response.error.code == "file_not_found"
diff --git a/tests/unittest/test_doclib_locators.py b/tests/unittest/test_doclib_locators.py
index 91168f2b..a1037097 100644
--- a/tests/unittest/test_doclib_locators.py
+++ b/tests/unittest/test_doclib_locators.py
@@ -5,15 +5,15 @@ from mineru.doclib.locators import block_char_ref, block_ref, locator_for_block,
def test_doclib_locator_helpers_use_public_one_based_numbers() -> None:
assert locator_for_block(1, 3) == "page:1/block:3"
- assert page_ref("ab12cd3", "standard", 1) == "doc:ab12cd3/tier:standard/page:1"
- assert block_ref("ab12cd3", "standard", 1, 3) == "doc:ab12cd3/tier:standard/page:1/block:3"
- assert block_char_ref("ab12cd3", "standard", 1, 3, 0) == "doc:ab12cd3/tier:standard/page:1/block:3/char:0"
+ assert page_ref("ab12cd3", "high", 1) == "doc:ab12cd3/tier:high/page:1"
+ assert block_ref("ab12cd3", "high", 1, 3) == "doc:ab12cd3/tier:high/page:1/block:3"
+ assert block_char_ref("ab12cd3", "high", 1, 3, 0) == "doc:ab12cd3/tier:high/page:1/block:3/char:0"
def test_parse_content_cursor_supports_page_block_and_char_refs() -> None:
- page = parse_content_cursor("doc:ab12cd3/tier:standard/page:5")
- block = parse_content_cursor("doc:ab12cd3/tier:standard/page:5/block:18")
- char = parse_content_cursor("doc:ab12cd3/tier:standard/page:5/block:18/char:32784")
+ page = parse_content_cursor("doc:ab12cd3/tier:high/page:5")
+ block = parse_content_cursor("doc:ab12cd3/tier:high/page:5/block:18")
+ char = parse_content_cursor("doc:ab12cd3/tier:high/page:5/block:18/char:32784")
assert page.page_no == 5
assert page.block_no is None
@@ -26,6 +26,6 @@ def test_content_cursor_rejects_zero_based_public_numbers() -> None:
with pytest.raises(ValueError):
locator_for_block(0, 1)
with pytest.raises(ValueError):
- parse_content_cursor("doc:ab12cd3/tier:standard/page:0")
+ parse_content_cursor("doc:ab12cd3/tier:high/page:0")
with pytest.raises(ValueError):
- parse_content_cursor("doc:ab12cd3/tier:standard/page:1/block:0")
+ parse_content_cursor("doc:ab12cd3/tier:high/page:1/block:0")
diff --git a/tests/unittest/test_doclib_progressive_reading.py b/tests/unittest/test_doclib_progressive_reading.py
index 8169f6f0..01bc321e 100644
--- a/tests/unittest/test_doclib_progressive_reading.py
+++ b/tests/unittest/test_doclib_progressive_reading.py
@@ -44,7 +44,7 @@ def test_content_page_range_rejects_empty_available_subset() -> None:
def test_paginated_page_boundary_truncation_suggests_pages_only() -> None:
pages = [_page(index, f"page {index + 1}") for index in range(10)]
- rendered = _render_progressive_markdown(pages, short_id="ab12cd3", tier="standard", after=None, limit=40, add_markers=False)
+ rendered = _render_progressive_markdown(pages, short_id="ab12cd3", tier="high", after=None, limit=40, add_markers=False)
next_request = _next_content_request(
rendered=rendered,
request_page_range="1~10",
@@ -62,7 +62,7 @@ def test_paginated_page_boundary_truncation_suggests_pages_only() -> None:
def test_paginated_long_single_page_truncation_keeps_pages_with_after() -> None:
pages = [_page(6, "word " * 100)]
- rendered = _render_progressive_markdown(pages, short_id="ab12cd3", tier="standard", after=None, limit=40, add_markers=False)
+ rendered = _render_progressive_markdown(pages, short_id="ab12cd3", tier="high", after=None, limit=40, add_markers=False)
next_request = _next_content_request(
rendered=rendered,
request_page_range="7~10",
@@ -72,7 +72,7 @@ def test_paginated_long_single_page_truncation_keeps_pages_with_after() -> None:
)
assert rendered.truncated is True
- assert rendered.content_ranges[-1].end.startswith("doc:ab12cd3/tier:standard/page:7/block:1/char:")
+ assert rendered.content_ranges[-1].end.startswith("doc:ab12cd3/tier:high/page:7/block:1/char:")
assert next_request is not None
assert next_request.page_range == "7~10"
assert next_request.after == rendered.content_ranges[-1].end
@@ -82,7 +82,7 @@ def test_non_paginated_truncation_can_use_after_only() -> None:
rendered = _render_progressive_markdown(
[_page(0, "block 1", "block 2", "block 3")],
short_id="ab12cd3",
- tier="standard",
+ tier="high",
after=None,
limit=15,
add_markers=False,
@@ -105,7 +105,7 @@ def test_non_contiguous_pages_suggest_after_last_requested_page() -> None:
rendered = _render_progressive_markdown(
[_page(0, "page 1"), _page(4, "page 5"), _page(19, "page 20"), _page(24, "page 25")],
short_id="ab12cd3",
- tier="standard",
+ tier="high",
after=None,
limit=30000,
add_markers=False,
@@ -126,7 +126,7 @@ def test_truncated_false_can_still_have_next_request() -> None:
rendered = _render_progressive_markdown(
[_page(index, f"page {index + 1}") for index in range(10)],
short_id="ab12cd3",
- tier="standard",
+ tier="high",
after=None,
limit=30000,
add_markers=False,
@@ -153,8 +153,8 @@ def test_paginated_next_request_is_never_after_only() -> None:
"content_ranges": [
ContentRange(
page_range="7",
- start="doc:ab12cd3/tier:standard/page:7/block:1/char:0",
- end="doc:ab12cd3/tier:standard/page:7/block:1/char:40",
+ start="doc:ab12cd3/tier:high/page:7/block:1/char:0",
+ end="doc:ab12cd3/tier:high/page:7/block:1/char:40",
)
],
"truncated": True,
diff --git a/tests/unittest/test_doclib_telemetry_core.py b/tests/unittest/test_doclib_telemetry_core.py
index c0f5f080..46407d1c 100644
--- a/tests/unittest/test_doclib_telemetry_core.py
+++ b/tests/unittest/test_doclib_telemetry_core.py
@@ -244,7 +244,7 @@ def test_parse_route_records_request_finished_and_duration_metrics(tmp_path) ->
async def request_parse(self, *args, **kwargs) -> dict:
return {
"sha256": "abc",
- "tier": "standard",
+ "tier": "high",
"page_range": "1",
"status": "pending",
"cache_hit": False,
@@ -261,7 +261,7 @@ def test_parse_route_records_request_finished_and_duration_metrics(tmp_path) ->
await telemetry.initialize()
server = DoclibServer(SimpleNamespace(parse_svc=_ParseService(), telemetry_svc=telemetry))
- await server.ensure_parse(ParseRequest(path="/tmp/a.pdf", tier="standard"))
+ await server.ensure_parse(ParseRequest(path="/tmp/a.pdf", tier="high"))
body = await telemetry.preview_body()
metric_names = {metric["name"] for metric in body["metrics"]}
@@ -273,7 +273,7 @@ def test_parse_route_records_request_finished_and_duration_metrics(tmp_path) ->
"caller": "unknown",
"source": "unknown",
"status": "queued",
- "tier": "standard",
+ "tier": "high",
}
asyncio.run(_run())
@@ -499,7 +499,7 @@ def test_parse_wait_observation_uses_parse_rows_for_tier_and_pages_bucket(tmp_pa
)
await db.execute(
"INSERT INTO parses (sha256, tier, page_range, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)",
- ("sha", "standard", "1~3", "done", now, now),
+ ("sha", "high", "1~3", "done", now, now),
)
row = await db.fetchone("SELECT id FROM parses WHERE sha256=?", ("sha",))
@@ -523,7 +523,7 @@ def test_parse_wait_observation_uses_parse_rows_for_tier_and_pages_bucket(tmp_pa
"pages_bucket": "2_5",
"source": "unknown",
"status": "succeeded",
- "tier": "standard",
+ "tier": "high",
}
assert by_name["parse.wait_duration_bucket.count"]["dimensions"]["bucket"] == "1_5s"
diff --git a/tests/unittest/test_kit_commands.py b/tests/unittest/test_kit_commands.py
index 390914ae..bb2d11c7 100644
--- a/tests/unittest/test_kit_commands.py
+++ b/tests/unittest/test_kit_commands.py
@@ -257,44 +257,14 @@ def test_models_show_and_verify(tmp_path: Path, monkeypatch: Any) -> None:
assert "vlm: ok" in verify_result.output
-def test_api_server_omits_tier_when_backend_only(monkeypatch: Any) -> None:
- seen: dict[str, Any] = {}
-
- def _fake_main(*, args: list[str], prog_name: str, standalone_mode: bool) -> None:
- seen["args"] = args
- seen["prog_name"] = prog_name
- seen["standalone_mode"] = standalone_mode
-
- monkeypatch.setattr(api_server.parser_api_server.main, "main", _fake_main)
-
- result = runner.invoke(app, ["api-server", "--backend", "hybrid-engine", "--effort", "high"])
+def test_api_server_rejects_backend_and_effort_options() -> None:
+ backend_result = runner.invoke(app, ["api-server", "--backend", "hybrid-engine"])
+ effort_result = runner.invoke(app, ["api-server", "--effort", "high"])
- assert result.exit_code == 0
- assert "--backend" in seen["args"]
- assert "hybrid-engine" in seen["args"]
- assert "--effort" in seen["args"]
- assert "high" in seen["args"]
- assert "--tier" not in seen["args"]
-
-
-def test_api_server_normalizes_backend_alias(monkeypatch: Any) -> None:
- seen: dict[str, Any] = {}
-
- def _fake_main(*, args: list[str], prog_name: str, standalone_mode: bool) -> None:
- """记录 mineru-kit api-server 转发给底层 Click 命令的参数。"""
- seen["args"] = args
- seen["prog_name"] = prog_name
- seen["standalone_mode"] = standalone_mode
-
- monkeypatch.setattr(api_server.parser_api_server.main, "main", _fake_main)
-
- result = runner.invoke(app, ["api-server", "--backend", "hybrid-auto-engine"])
-
- assert result.exit_code == 0
- assert "--backend" in seen["args"]
- assert "hybrid-engine" in seen["args"]
- assert "hybrid-auto-engine" not in seen["args"]
- assert "--tier" not in seen["args"]
+ assert backend_result.exit_code != 0
+ assert "--backend" in backend_result.output
+ assert effort_result.exit_code != 0
+ assert "--effort" in effort_result.output
def test_api_server_forwards_repeated_tiers(monkeypatch: Any) -> None:
@@ -308,14 +278,14 @@ def test_api_server_forwards_repeated_tiers(monkeypatch: Any) -> None:
monkeypatch.setattr(api_server.parser_api_server.main, "main", _fake_main)
- result = runner.invoke(app, ["api-server", "--tier", "standard", "--tier", "pro"])
+ result = runner.invoke(app, ["api-server", "--tier", "medium", "--tier", "extra_high"])
assert result.exit_code == 0
assert seen["prog_name"] == "mineru-kit api-server"
assert seen["standalone_mode"] is False
assert [seen["args"][index + 1] for index, item in enumerate(seen["args"]) if item == "--tier"] == [
- "standard",
- "pro",
+ "medium",
+ "extra_high",
]
@@ -323,7 +293,7 @@ def test_api_server_without_tier_lets_parser_api_apply_all_tier_default(monkeypa
seen: dict[str, Any] = {}
def _fake_main(*, args: list[str], prog_name: str, standalone_mode: bool) -> None:
- """记录 mineru-kit api-server 默认参数,确认不再强制单 standard tier。"""
+ """记录 mineru-kit api-server 默认参数,确认不再强制单 high tier。"""
seen["args"] = args
seen["prog_name"] = prog_name
seen["standalone_mode"] = standalone_mode
@@ -575,16 +545,21 @@ def test_parse_rejects_removed_ch_lite_language(tmp_path: Path) -> None:
def test_gradio_tier_selection_derives_v1_runtime() -> None:
from mineru.cli_old import gradio_app
- assert gradio_app.resolve_gradio_runtime_options("standard").as_kwargs() == {
- "tier": "standard",
+ assert gradio_app.resolve_gradio_runtime_options("medium").as_kwargs() == {
+ "tier": "medium",
"backend": "hybrid-engine",
"effort": "medium",
}
- assert gradio_app.resolve_gradio_runtime_options("pro").as_kwargs() == {
- "tier": "pro",
+ assert gradio_app.resolve_gradio_runtime_options("high").as_kwargs() == {
+ "tier": "high",
"backend": "hybrid-engine",
"effort": "high",
}
+ assert gradio_app.resolve_gradio_runtime_options("extra_high").as_kwargs() == {
+ "tier": "extra_high",
+ "backend": "hybrid-engine",
+ "effort": "extra_high",
+ }
def test_gradio_extracts_supported_tiers_from_v1_tiers_payload() -> None:
@@ -592,22 +567,24 @@ def test_gradio_extracts_supported_tiers_from_v1_tiers_payload() -> None:
payload = {
"data": [
- {"id": "pro"},
+ {"id": "flash"},
+ {"id": "extra_high"},
{"id": "experimental"},
- {"id": "standard"},
- {"id": "pro"},
+ {"id": "medium"},
+ {"id": "high"},
+ {"id": "extra_high"},
]
}
- assert gradio_app.extract_v1_tier_choices(payload) == ("pro", "standard")
- assert gradio_app.default_v1_gradio_tier(("pro", "standard")) == "pro"
+ assert gradio_app.extract_v1_tier_choices(payload) == ("flash", "extra_high", "medium", "high")
+ assert gradio_app.default_v1_gradio_tier(("flash", "extra_high", "medium", "high")) == "high"
def test_gradio_rejects_v1_tiers_payload_without_supported_tiers() -> None:
from mineru.cli_old import gradio_app
with pytest.raises(click.ClickException, match="did not advertise any supported tier"):
- gradio_app.extract_v1_tier_choices({"data": [{"id": "flash"}, {"id": "experimental"}]})
+ gradio_app.extract_v1_tier_choices({"data": [{"id": "experimental"}]})
def test_gradio_persists_v1_parse_result_for_preview_and_download(
diff --git a/tests/unittest/test_parser_api_contract.py b/tests/unittest/test_parser_api_contract.py
index 4e1c0d43..ea246ec2 100644
--- a/tests/unittest/test_parser_api_contract.py
+++ b/tests/unittest/test_parser_api_contract.py
@@ -21,7 +21,6 @@ import mineru.parser.tier as parser_tier
from mineru.parser import _build_parser, parse, parse_async
from mineru.parser.api_client import MinerUApiParser, _pages_from_middle_json, _parse_result_from_job, should_trust_env_for_url
from mineru.parser.api_server import (
- _API_SERVER_BACKENDS,
_API_SERVER_LANGUAGES,
CreateJobRequest,
FileParseInfo,
@@ -124,10 +123,13 @@ def test_validate_effort_rejects_low_and_maps_legacy_backends() -> None:
)
assert HYBRID_EFFORT_CHOICES == ("medium", "high", "extra_high")
- assert effort_for_tier("standard") == "medium"
- assert effort_for_tier("pro") == "high"
+ assert effort_for_tier("medium") == "medium"
+ assert effort_for_tier("high") == "high"
+ assert effort_for_tier("extra_high") == "extra_high"
with pytest.raises(ValueError, match="Unsupported effort 'low'"):
validate_effort("low")
+ with pytest.raises(ValueError, match="Unsupported tier 'standard'"):
+ effort_for_tier("standard")
assert resolve_backend_and_effort("vlm-engine", "medium") == ("hybrid-engine", "extra_high")
assert resolve_backend_and_effort("pipeline", "extra_high") == ("hybrid-engine", "medium")
@@ -136,23 +138,35 @@ def test_tier_runtime_options_map_hybrid_effort() -> None:
"""校验 tier 到 Hybrid runtime 参数的共享映射,避免 API/Gradio 分叉维护。"""
from mineru.parser.tier import runtime_options_for_tier
- assert runtime_options_for_tier("standard").as_kwargs() == {
- "tier": "standard",
+ assert runtime_options_for_tier("flash").as_kwargs() == {
+ "tier": "flash",
+ "backend": "flash",
+ "effort": "medium",
+ }
+ assert runtime_options_for_tier("medium").as_kwargs() == {
+ "tier": "medium",
"backend": "hybrid-engine",
"effort": "medium",
}
- assert runtime_options_for_tier("pro").as_kwargs() == {
- "tier": "pro",
+ assert runtime_options_for_tier("high").as_kwargs() == {
+ "tier": "high",
"backend": "hybrid-engine",
"effort": "high",
}
+ assert runtime_options_for_tier("extra_high").as_kwargs() == {
+ "tier": "extra_high",
+ "backend": "hybrid-engine",
+ "effort": "extra_high",
+ }
+ with pytest.raises(ValueError, match="Unsupported tier 'standard'"):
+ runtime_options_for_tier("standard")
def test_api_client_builds_file_page_range_without_options(tmp_path: Path) -> None:
pdf = tmp_path / "demo.pdf"
pdf.write_bytes(b"%PDF-1.7\n")
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
payload = parser._build_payload(pdf, "1,3~5")
assert payload["output_formats"] == ["middle_json", "images"]
@@ -164,21 +178,27 @@ def test_api_client_uses_tier_without_backend_semantics(tmp_path: Path) -> None:
pdf = tmp_path / "demo.pdf"
pdf.write_bytes(b"%PDF-1.7\n")
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="pro")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="extra_high")
payload = parser._build_payload(pdf, "")
- assert payload["tier"] == "pro"
+ assert payload["tier"] == "extra_high"
assert not hasattr(parser, "backend")
[email protected]("tier", ["standard", "pro"])
+def test_api_client_rejects_old_tier_names(tier: str) -> None:
+ with pytest.raises(ValueError, match=f"Unsupported tier '{tier}'"):
+ MinerUApiParser(api_url="http://localhost:8000", tier=tier) # type: ignore[arg-type]
+
+
def test_api_client_uses_json_format_for_staging_compat() -> None:
- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="pro")
+ parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="extra_high")
assert parser._output_formats() == ["json"]
def test_api_client_downloads_image_sidecars_and_preserves_pdf_mapping(monkeypatch: pytest.MonkeyPatch) -> None:
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
middle_json = {
"schema_version": "1.0.0",
"_pdf_retained_page_indices": [0, 2],
@@ -206,7 +226,7 @@ def test_api_client_downloads_image_sidecars_and_preserves_pdf_mapping(monkeypat
def test_api_client_accepts_remote_pdf_info_json(monkeypatch: pytest.MonkeyPatch) -> None:
- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="standard")
+ parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="high")
middle_json = {
"_backend": "hybrid",
"_version_name": "remote",
@@ -233,7 +253,7 @@ def test_api_client_accepts_remote_pdf_info_json(monkeypatch: pytest.MonkeyPatch
def test_async_api_client_accepts_remote_pdf_info_json(monkeypatch: pytest.MonkeyPatch) -> None:
- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="standard")
+ parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="high")
middle_json = {
"_backend": "hybrid",
"pdf_info": [{"page_idx": 0, "page_size": [100, 200]}],
@@ -271,7 +291,7 @@ def test_api_client_rejects_unsafe_image_sidecar_paths(
monkeypatch: pytest.MonkeyPatch,
image_path: str,
) -> None:
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
middle_json = {"schema_version": "1.0.0", "pages": [{"page_idx": 0}]}
image_ref = {"path": image_path, "file_id": "file-image", "bytes": 11}
@@ -296,7 +316,7 @@ def test_api_client_rejects_unsafe_image_sidecar_paths(
def test_async_api_client_rejects_unsafe_image_sidecar_paths(monkeypatch: pytest.MonkeyPatch) -> None:
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
middle_json = {"schema_version": "1.0.0", "pages": [{"page_idx": 0}]}
image_ref = {"path": "../escape.png", "file_id": "file-image", "bytes": 11}
@@ -400,14 +420,14 @@ def test_api_client_omits_page_range_when_unspecified(tmp_path: Path) -> None:
pdf = tmp_path / "demo.pdf"
pdf.write_bytes(b"%PDF-1.7\n")
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
payload = parser._build_payload(pdf, "")
assert payload["files"] == [{"source": {"type": "local", "path": str(pdf)}}]
def test_api_client_surfaces_failed_job_error() -> None:
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
with pytest.raises(Exception, match="upstream failed"):
_parse_result_from_job(
@@ -422,7 +442,7 @@ def test_api_client_surfaces_failed_job_error() -> None:
def test_api_client_surfaces_failed_file_error_when_job_has_no_top_level_error() -> None:
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
with pytest.raises(api_client._V1APIError) as exc_info:
_parse_result_from_job(
@@ -450,7 +470,7 @@ def test_api_client_surfaces_failed_file_error_when_job_has_no_top_level_error()
def test_api_client_rejects_missing_middle_json_output() -> None:
- parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")
+ parser = MinerUApiParser(api_url="http://localhost:8000", tier="high")
with pytest.raises(Exception, match="did not return middle_json output"):
_parse_result_from_job(
@@ -536,7 +556,7 @@ def test_local_parse_server_rejects_callback(tmp_path: Path, monkeypatch: pytest
def test_create_app_does_not_read_runtime_settings_from_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
_stub_api_server_dependency_preflight(monkeypatch)
- monkeypatch.setenv("MINERU_TIER", "pro")
+ monkeypatch.setenv("MINERU_TIER", "extra_high")
monkeypatch.setenv("MINERU_BACKEND", "hybrid-auto-engine")
monkeypatch.setenv("MINERU_CONCURRENCY", "9")
monkeypatch.setenv("MINERU_URL_TIMEOUT", "99")
@@ -550,14 +570,14 @@ def test_create_app_does_not_read_runtime_settings_from_env(tmp_path: Path, monk
app = create_app(upload_dir=str(tmp_path))
- assert app.state.tier == "standard"
+ assert app.state.tier == "high"
assert app.state.backend == "hybrid-engine"
assert app.state.concurrency == 1
assert app.state.url_timeout == 60
assert app.state.max_wait == 600
assert app.state.language == "ch"
assert app.state.ocr_mode == "auto"
- assert app.state.effort == "medium"
+ assert app.state.effort == "high"
assert app.state.table_enable is True
assert app.state.formula_enable is True
assert app.state.image_analysis is True
@@ -658,7 +678,7 @@ def test_api_server_rendered_outputs_store_image_sidecars(
request = CreateJobRequest.model_validate(
{
"files": [{"source": {"type": "local", "path": str(source)}}],
- "tier": "standard",
+ "tier": "high",
"output_formats": [output_format],
}
)
@@ -723,7 +743,7 @@ def test_api_server_middle_json_preserves_backend_for_client_rendering(
request = CreateJobRequest.model_validate(
{
"files": [{"source": {"type": "local", "path": str(source)}}],
- "tier": "standard",
+ "tier": "high",
"output_formats": ["middle_json"],
}
)
@@ -790,7 +810,7 @@ def test_api_server_sanitizes_surrogates_in_text_outputs(
request = CreateJobRequest.model_validate(
{
"files": [{"source": {"type": "local", "path": str(source)}}],
- "tier": "standard",
+ "tier": "high",
"output_formats": ["markdown", "middle_json", "content_list", "structured_content"],
}
)
@@ -844,7 +864,7 @@ def test_api_server_logs_traceback_when_job_file_fails(
request = CreateJobRequest.model_validate(
{
"files": [{"source": {"type": "local", "path": str(source)}}],
- "tier": "standard",
+ "tier": "high",
"output_formats": ["middle_json"],
}
)
@@ -911,76 +931,102 @@ def test_api_contract_uses_parser_version_not_backend_version() -> None:
def test_api_server_tier_selects_compatible_backend(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
_stub_api_server_dependency_preflight(monkeypatch)
- pro_app = create_app(upload_dir=str(tmp_path / "pro"), tier="pro")
- standard_app = create_app(upload_dir=str(tmp_path / "standard"), tier="standard")
-
- assert pro_app.state.tier == "pro"
- assert pro_app.state.backend == "hybrid-engine"
- assert [tier["id"] for tier in pro_app.state.tiers] == ["pro"]
- assert standard_app.state.tier == "standard"
- assert standard_app.state.backend == "hybrid-engine"
- assert standard_app.state.effort == "medium"
- assert [tier["id"] for tier in standard_app.state.tiers] == ["standard"]
+ flash_app = create_app(upload_dir=str(tmp_path / "flash"), tier="flash")
+ medium_app = create_app(upload_dir=str(tmp_path / "medium"), tier="medium")
+ high_app = create_app(upload_dir=str(tmp_path / "high"), tier="high")
+ extra_high_app = create_app(upload_dir=str(tmp_path / "extra_high"), tier="extra_high")
+
+ assert flash_app.state.tier == "flash"
+ assert flash_app.state.backend == "flash"
+ assert [tier["id"] for tier in flash_app.state.tiers] == ["flash"]
+ assert medium_app.state.tier == "medium"
+ assert medium_app.state.backend == "hybrid-engine"
+ assert medium_app.state.effort == "medium"
+ assert [tier["id"] for tier in medium_app.state.tiers] == ["medium"]
+ assert high_app.state.tier == "high"
+ assert high_app.state.backend == "hybrid-engine"
+ assert high_app.state.effort == "high"
+ assert [tier["id"] for tier in high_app.state.tiers] == ["high"]
+ assert extra_high_app.state.tier == "extra_high"
+ assert extra_high_app.state.backend == "hybrid-engine"
+ assert extra_high_app.state.effort == "extra_high"
+ assert [tier["id"] for tier in extra_high_app.state.tiers] == ["extra_high"]
def test_api_server_defaults_to_all_quality_tiers(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
_stub_api_server_dependency_preflight(monkeypatch)
app = create_app(upload_dir=str(tmp_path))
- assert app.state.tier == "standard"
- assert app.state.default_tier == "standard"
+ assert app.state.tier == "high"
+ assert app.state.default_tier == "high"
assert app.state.backend == "hybrid-engine"
- assert app.state.effort == "medium"
- assert [tier["id"] for tier in app.state.tiers] == ["standard", "pro"]
- assert app.state.tier_runtime_options["standard"].as_kwargs() == {
- "tier": "standard",
+ assert app.state.effort == "high"
+ assert [tier["id"] for tier in app.state.tiers] == ["flash", "medium", "high", "extra_high"]
+ assert app.state.tier_runtime_options["flash"].as_kwargs() == {
+ "tier": "flash",
+ "backend": "flash",
+ "effort": "medium",
+ }
+ assert app.state.tier_runtime_options["medium"].as_kwargs() == {
+ "tier": "medium",
"backend": "hybrid-engine",
"effort": "medium",
}
- assert app.state.tier_runtime_options["pro"].as_kwargs() == {
- "tier": "pro",
+ assert app.state.tier_runtime_options["high"].as_kwargs() == {
+ "tier": "high",
"backend": "hybrid-engine",
"effort": "high",
}
+ assert app.state.tier_runtime_options["extra_high"].as_kwargs() == {
+ "tier": "extra_high",
+ "backend": "hybrid-engine",
+ "effort": "extra_high",
+ }
def test_api_server_multi_tier_state_and_metadata(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
- """校验同一个 API server 可发布多个 tier,并保留 standard 作为默认 tier。"""
+ """校验同一个 API server 可发布多个 tier,并在包含 high 时以 high 作为默认 tier。"""
_stub_api_server_dependency_preflight(monkeypatch)
- app = create_app(upload_dir=str(tmp_path), tier=["standard", "pro"])
+ app = create_app(upload_dir=str(tmp_path), tier=["medium", "high", "extra_high"])
- assert app.state.tier == "standard"
- assert app.state.default_tier == "standard"
+ assert app.state.tier == "high"
+ assert app.state.default_tier == "high"
assert app.state.backend == "hybrid-engine"
- assert app.state.effort == "medium"
- assert [tier["id"] for tier in app.state.tiers] == ["standard", "pro"]
- assert app.state.model_ids == ["Hybrid-Low", "MinerU-HTML", "MinerU2.5-Pro-2604-1.2B"]
- assert app.state.tier_runtime_options["standard"].as_kwargs() == {
- "tier": "standard",
+ assert app.state.effort == "high"
+ assert [tier["id"] for tier in app.state.tiers] == ["medium", "high", "extra_high"]
+ assert app.state.model_ids == ["Hybrid-Medium", "MinerU-HTML", "MinerU2.5-Pro-2604-1.2B"]
+ assert app.state.tier_runtime_options["medium"].as_kwargs() == {
+ "tier": "medium",
"backend": "hybrid-engine",
"effort": "medium",
}
- assert app.state.tier_runtime_options["pro"].as_kwargs() == {
- "tier": "pro",
+ assert app.state.tier_runtime_options["high"].as_kwargs() == {
+ "tier": "high",
"backend": "hybrid-engine",
"effort": "high",
}
+ assert app.state.tier_runtime_options["extra_high"].as_kwargs() == {
+ "tier": "extra_high",
+ "backend": "hybrid-engine",
+ "effort": "extra_high",
+ }
def test_api_server_multi_tier_http_metadata(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""校验 /v1/tiers 与 /v1/models 返回启动时声明的全部 tier 能力。"""
_stub_api_server_dependency_preflight(monkeypatch)
- app = create_app(upload_dir=str(tmp_path), tier=["standard", "pro"])
+ app = create_app(upload_dir=str(tmp_path), tier=["flash", "medium", "high", "extra_high"])
with TestClient(app) as client:
tiers_response = client.get("/v1/tiers")
models_response = client.get("/v1/models")
assert tiers_response.status_code == 200
- assert [tier["id"] for tier in tiers_response.json()["data"]] == ["standard", "pro"]
+ assert [tier["id"] for tier in tiers_response.json()["data"]] == ["flash", "medium", "high", "extra_high"]
assert models_response.status_code == 200
assert [model["id"] for model in models_response.json()["data"]] == [
- "Hybrid-Low",
+ "MinerU-Flash",
+ "Hybrid-Medium",
"MinerU-HTML",
"MinerU2.5-Pro-2604-1.2B",
]
@@ -1001,7 +1047,7 @@ def test_api_server_multi_tier_jobs_use_requested_tier_runtime(
monkeypatch.setattr("mineru.parser.api_server.parse_async", fake_parse_async)
source = tmp_path / "demo.pdf"
source.write_bytes(b"%PDF-1.7\n")
- app = create_app(upload_dir=str(tmp_path / "api"), tier=["standard", "pro"])
+ app = create_app(upload_dir=str(tmp_path / "api"), tier=["medium", "high"])
with TestClient(app) as client:
default_response = client.post(
@@ -1012,23 +1058,23 @@ def test_api_server_multi_tier_jobs_use_requested_tier_runtime(
"wait": 5,
},
)
- pro_response = client.post(
+ medium_response = client.post(
"/v1/parse/jobs",
json={
"files": [{"source": {"type": "local", "path": str(source)}}],
- "tier": "pro",
+ "tier": "medium",
"output_formats": ["middle_json"],
"wait": 5,
},
)
assert default_response.status_code == 200
- assert default_response.json()["tier"] == "standard"
- assert pro_response.status_code == 200
- assert pro_response.json()["tier"] == "pro"
+ assert default_response.json()["tier"] == "high"
+ assert medium_response.status_code == 200
+ assert medium_response.json()["tier"] == "medium"
assert [(call["tier"], call["backend"], call["effort"]) for call in calls] == [
- ("standard", "hybrid-engine", "medium"),
- ("pro", "hybrid-engine", "high"),
+ ("high", "hybrid-engine", "high"),
+ ("medium", "hybrid-engine", "medium"),
]
@@ -1039,23 +1085,23 @@ def test_api_server_single_tier_rejects_unavailable_tier(
_stub_api_server_dependency_preflight(monkeypatch)
source = tmp_path / "demo.pdf"
source.write_bytes(b"%PDF-1.7\n")
- app = create_app(upload_dir=str(tmp_path / "api"), tier="standard")
+ app = create_app(upload_dir=str(tmp_path / "api"), tier="high")
with TestClient(app) as client:
response = client.post(
"/v1/parse/jobs",
json={
"files": [{"source": {"type": "local", "path": str(source)}}],
- "tier": "pro",
+ "tier": "extra_high",
"wait": 0,
},
)
assert response.status_code == 400
- assert "Tier 'pro' not available in this server" in response.text
+ assert "Tier 'extra_high' not available in this server" in response.text
-def test_api_server_preflights_standard_tier_dependencies(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
+def test_api_server_preflights_medium_tier_dependencies(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
imported_modules: list[str] = []
def fake_import_module(module_name: str):
@@ -1064,7 +1110,7 @@ def test_api_server_preflights_standard_tier_dependencies(monkeypatch: pytest.Mo
monkeypatch.setattr(importlib, "import_module", fake_import_module)
- create_app(upload_dir=str(tmp_path), tier="standard")
+ create_app(upload_dir=str(tmp_path), tier="medium")
assert imported_modules == [
"ftfy",
@@ -1076,7 +1122,9 @@ def test_api_server_preflights_standard_tier_dependencies(monkeypatch: pytest.Mo
]
-def test_api_server_preflights_pro_tier_dependencies_for_platform(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
+def test_api_server_preflights_extra_high_tier_dependencies_for_platform(
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
+) -> None:
imported_modules: list[str] = []
def fake_import_module(module_name: str):
@@ -1086,7 +1134,7 @@ def test_api_server_preflights_pro_tier_dependencies_for_platform(monkeypatch: p
monkeypatch.setattr(importlib, "import_module", fake_import_module)
monkeypatch.setattr(parser_tier.sys, "platform", "darwin")
- create_app(upload_dir=str(tmp_path), tier="pro")
+ create_app(upload_dir=str(tmp_path), tier="extra_high")
assert imported_modules == [
"ftfy",
@@ -1110,8 +1158,8 @@ def test_api_server_preflight_rejects_missing_tier_dependency(monkeypatch: pytes
monkeypatch.setattr(importlib, "import_module", fake_import_module)
monkeypatch.setattr(parser_tier.importlib_metadata, "packages_distributions", lambda: {"mineru": ["mineru"]})
- with pytest.raises(api_server.ParseServerStartupError, match="tier 'standard'.*torch.*mineru\\[standard\\]"):
- create_app(upload_dir=str(tmp_path), tier="standard")
+ with pytest.raises(api_server.ParseServerStartupError, match="tier 'medium'.*torch.*mineru\\[medium\\]"):
+ create_app(upload_dir=str(tmp_path), tier="medium")
def test_api_server_cli_reports_dependency_preflight_without_traceback(monkeypatch: pytest.MonkeyPatch) -> None:
@@ -1124,50 +1172,23 @@ def test_api_server_cli_reports_dependency_preflight_without_traceback(monkeypat
monkeypatch.setattr(parser_tier.importlib_metadata, "packages_distributions", lambda: {"mineru": ["mineru-next-dev"]})
monkeypatch.setattr(parser_tier.sys, "platform", "darwin")
- result = runner.invoke(main, ["--tier", "pro"])
+ result = runner.invoke(main, ["--tier", "extra_high"])
assert result.exit_code == 1
assert result.output == (
- "Error: Parse server cannot start for tier 'pro'; missing runtime dependencies: mlx. "
+ "Error: Parse server cannot start for tier 'extra_high'; missing runtime dependencies: mlx. "
"Install optional dependencies for this tier in the same Python environment as MinerU, "
- "for example: pip install 'mineru-next-dev[pro]'.\n"
+ "for example: pip install 'mineru-next-dev[extra_high]'.\n"
)
assert "Traceback" not in result.output
-def test_api_server_maps_legacy_pipeline_backend_to_standard_hybrid_medium(
- tmp_path: Path, monkeypatch: pytest.MonkeyPatch
-) -> None:
- _stub_api_server_dependency_preflight(monkeypatch)
- app = create_app(upload_dir=str(tmp_path), backend="pipeline")
-
- assert app.state.tier == "standard"
- assert app.state.backend == "hybrid-engine"
- assert app.state.effort == "medium"
-
-
-def test_api_server_allows_compatible_tier_and_explicit_backend(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
- _stub_api_server_dependency_preflight(monkeypatch)
- app = create_app(upload_dir=str(tmp_path), tier="pro", backend="vlm-auto-engine")
-
- assert app.state.tier == "pro"
- assert app.state.backend == "hybrid-engine"
- assert app.state.effort == "extra_high"
- assert [tier["id"] for tier in app.state.tiers] == ["pro"]
-
-
-def test_api_server_explicit_backend_infers_tier(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
- _stub_api_server_dependency_preflight(monkeypatch)
- app = create_app(upload_dir=str(tmp_path), backend="hybrid-auto-engine")
-
- assert app.state.tier == "pro"
- assert app.state.backend == "hybrid-engine"
- assert [tier["id"] for tier in app.state.tiers] == ["pro"]
-
+def test_api_server_create_app_rejects_backend_and_effort_parameters(tmp_path: Path) -> None:
+ with pytest.raises(TypeError, match="backend"):
+ create_app(upload_dir=str(tmp_path / "backend"), backend="pipeline") # type: ignore[call-arg]
-def test_api_server_rejects_bare_vlm_backend(tmp_path: Path) -> None:
- with pytest.raises(ValueError, match="Unsupported backend"):
- create_app(upload_dir=str(tmp_path), backend="vlm")
+ with pytest.raises(TypeError, match="effort"):
+ create_app(upload_dir=str(tmp_path / "effort"), effort="high") # type: ignore[call-arg]
def test_build_parser_forwards_effort_to_hybrid_parser(tmp_path: Path) -> None:
@@ -1340,33 +1361,13 @@ def test_pdf_hybrid_parser_passes_call_mode_to_backend_resolver(monkeypatch: pyt
assert backends == ["sync-backend", "async-backend"]
-def test_api_server_accepts_public_parser_backend_values(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
- from mineru.utils.backend_options import HTTP_CLIENT_BACKEND_CHOICES, LOCAL_BACKEND_CHOICES, normalize_backend
-
- assert _API_SERVER_BACKENDS == LOCAL_BACKEND_CHOICES + HTTP_CLIENT_BACKEND_CHOICES
-
- _stub_api_server_dependency_preflight(monkeypatch)
- assert "pipeline" not in _API_SERVER_BACKENDS
- assert "vlm" not in _API_SERVER_BACKENDS
- assert "vlm-engine" not in _API_SERVER_BACKENDS
- assert "vlm-http-client" not in _API_SERVER_BACKENDS
- assert "hybrid" not in _API_SERVER_BACKENDS
-
- for backend in _API_SERVER_BACKENDS:
- app = create_app(upload_dir=str(tmp_path / backend), backend=backend)
- expected_backend = normalize_backend(backend)
-
- assert app.state.backend == expected_backend
- assert app.state.tier == "pro"
-
-
def test_api_server_stores_parser_runtime_options(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
_stub_api_server_dependency_preflight(monkeypatch)
app = create_app(
upload_dir=str(tmp_path),
+ tier="medium",
language="en",
ocr_mode="ocr",
- effort="high",
table_enable=False,
formula_enable=False,
image_analysis=False,
@@ -1388,9 +1389,11 @@ def test_api_server_rejects_removed_ch_lite_language(tmp_path: Path) -> None:
def test_api_server_cli_exposes_parser_runtime_options() -> None:
option_names = {name for param in main.params for name in param.opts}
+ assert "--tier" in option_names
+ assert "--backend" not in option_names
assert "--language" in option_names
assert "--ocr-mode" in option_names
- assert "--effort" in option_names
+ assert "--effort" not in option_names
assert "--disable-table" in option_names
assert "--disable-formula" in option_names
assert "--disable-image-analysis" in option_names
@@ -1410,37 +1413,16 @@ def test_api_server_cli_exposes_parser_runtime_options() -> None:
)
-def test_api_server_cli_accepts_backend_alias(monkeypatch: pytest.MonkeyPatch) -> None:
- seen: dict[str, str] = {}
+def test_api_server_cli_rejects_backend_and_effort_options() -> None:
+ backend_result = runner.invoke(main, ["--backend", "hybrid-engine"])
+ effort_result = runner.invoke(main, ["--effort", "high"])
- def _fake_run(server) -> None:
- """记录 Click CLI 创建出的应用配置,避免测试启动真实 uvicorn 服务。"""
- seen["backend"] = server.config.app.state.backend
- seen["host"] = server.config.host
- seen["port"] = str(server.config.port)
-
- monkeypatch.setattr("uvicorn.Server.run", _fake_run)
-
- result = runner.invoke(main, ["--backend", "hybrid-auto-engine", "--host", "0.0.0.0", "--port", "15981"])
-
- assert result.exit_code == 0
- assert seen == {"backend": "hybrid-engine", "host": "0.0.0.0", "port": "15981"}
-
-
-def test_api_server_cli_maps_legacy_vlm_backend_to_hybrid_extra_high(monkeypatch: pytest.MonkeyPatch) -> None:
- seen: dict[str, str] = {}
-
- def _fake_run(server) -> None:
- """记录 legacy VLM backend 进入 CLI 后的实际 parser 配置。"""
- seen["backend"] = server.config.app.state.backend
- seen["effort"] = server.config.app.state.effort
-
- monkeypatch.setattr("uvicorn.Server.run", _fake_run)
-
- result = runner.invoke(main, ["--backend", "vlm-http-client", "--host", "0.0.0.0", "--port", "15983"])
-
- assert result.exit_code == 0
- assert seen == {"backend": "hybrid-http-client", "effort": "extra_high"}
+ assert backend_result.exit_code != 0
+ assert "No such option" in backend_result.output
+ assert "--backend" in backend_result.output
+ assert effort_result.exit_code != 0
+ assert "No such option" in effort_result.output
+ assert "--effort" in effort_result.output
def test_api_server_cli_defaults_to_all_quality_tiers(monkeypatch: pytest.MonkeyPatch) -> None:
@@ -1460,9 +1442,9 @@ def test_api_server_cli_defaults_to_all_quality_tiers(monkeypatch: pytest.Monkey
assert result.exit_code == 0
assert seen == {
- "tiers": ["standard", "pro"],
- "default_tier": "standard",
- "effort_by_tier": {"standard": "medium", "pro": "high"},
+ "tiers": ["flash", "medium", "high", "extra_high"],
+ "default_tier": "high",
+ "effort_by_tier": {"flash": "medium", "medium": "medium", "high": "high", "extra_high": "extra_high"},
}
@@ -1479,18 +1461,18 @@ def test_api_server_cli_accepts_repeated_tier_list(monkeypatch: pytest.MonkeyPat
monkeypatch.setattr("uvicorn.Server.run", _fake_run)
- result = runner.invoke(main, ["--tier", "standard", "--tier", "pro", "--host", "0.0.0.0", "--port", "15984"])
+ result = runner.invoke(main, ["--tier", "medium", "--tier", "extra_high", "--host", "0.0.0.0", "--port", "15984"])
assert result.exit_code == 0
assert seen == {
- "tiers": ["standard", "pro"],
- "default_tier": "standard",
- "effort_by_tier": {"standard": "medium", "pro": "high"},
+ "tiers": ["medium", "extra_high"],
+ "default_tier": "medium",
+ "effort_by_tier": {"medium": "medium", "extra_high": "extra_high"},
}
-def test_api_server_cli_rejects_flash_in_tier_list() -> None:
- result = runner.invoke(main, ["--tier", "standard", "--tier", "flash"])
+def test_api_server_cli_rejects_old_tier_names() -> None:
+ result = runner.invoke(main, ["--tier", "standard"])
assert result.exit_code != 0
assert "Invalid value for '--tier'" in result.output
@@ -1518,19 +1500,19 @@ def test_api_server_cli_rejects_removed_ch_lite_language() -> None:
assert "Language ch_lite not supported" in result.output
-def test_api_server_cli_rejects_unknown_backend() -> None:
- result = runner.invoke(main, ["--backend", "vlm"])
-
- assert result.exit_code != 0
- assert "Unsupported backend" in result.output
-
-
-def test_api_server_cli_help_hides_backend_aliases() -> None:
+def test_api_server_cli_help_exposes_tier_only_runtime_selection() -> None:
result = runner.invoke(main, ["--help"])
normalized_output = result.output.replace("-\n ", "-")
assert result.exit_code == 0
- assert "hybrid-engine" in normalized_output
+ assert "--tier" in normalized_output
+ assert "flash" in normalized_output
+ assert "medium" in normalized_output
+ assert "high" in normalized_output
+ assert "extra_high" in normalized_output
+ assert "--backend" not in normalized_output
+ assert "--effort" not in normalized_output
+ assert "hybrid-engine" not in normalized_output
assert "pipeline" not in normalized_output
assert "vlm-engine" not in normalized_output
assert "vlm-http-client" not in normalized_output
@@ -1538,14 +1520,5 @@ def test_api_server_cli_help_hides_backend_aliases() -> None:
assert "vlm-auto-engine" not in normalized_output
-def test_api_server_cli_effort_help_matches_gradio_copy() -> None:
- """校验 api server 的 effort 帮助文案与 Gradio 英文提示保持一致。"""
- effort_option = next(param for param in main.params if "--effort" in param.opts)
-
- assert effort_option.help == (
- "Higher effort improves parsing quality but may be slower; medium is the fastest local Hybrid mode."
- )
-
-
def test_api_server_public_exports_are_runtime_entrypoints_only() -> None:
assert set(api_server.__all__) == {"create_app", "main"}