Skip to content

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

feat: remove legacy formula and table options from CLI and API

myhloli642ba0b177ea
diff --git a/docs/en/usage/cli_tools.md b/docs/en/usage/cli_tools.md
index 2bd1c867..f5e67219 100644
--- a/docs/en/usage/cli_tools.md
+++ b/docs/en/usage/cli_tools.md
@@ -20,8 +20,6 @@ Options:
-u, --url TEXT OpenAI-compatible backend URL passed through to the server when using http-client
-s, --start INTEGER Starting page number for parsing (0-based)
-e, --end INTEGER Ending page number for parsing (0-based)
- -f, --formula BOOLEAN Enable formula parsing (default: enabled)
- -t, --table BOOLEAN Enable table parsing (default: enabled)
--image-analysis BOOLEAN Enable image/chart analysis for hybrid
backend. Hybrid low and medium efforts
automatically disable image/chart analysis
@@ -111,19 +109,11 @@ Here are the environment variables and their descriptions:
* Used to specify configuration file path
* defaults to `mineru.json` in user directory, can specify other configuration file paths through environment variables.
-- `MINERU_FORMULA_ENABLE`:
- * Used to enable formula parsing
- * defaults to `true`, can be set to `false` through environment variables to disable formula parsing.
-
- `MINERU_FORMULA_CH_SUPPORT`:
* Used to enable Chinese formula parsing optimization (experimental feature)
* Default is `false`, can be set to `true` via environment variable to enable Chinese formula parsing optimization.
* Only effective for local Hybrid model execution.
-- `MINERU_TABLE_ENABLE`:
- * Used to enable table parsing
- * Default is `true`, can be set to `false` via environment variable to disable table parsing.
-
- `MINERU_TABLE_MERGE_ENABLE`:
* Used to enable table merging functionality
* Default is `true`, can be set to `false` via environment variable to disable table merging functionality.
diff --git a/docs/next/cli/mineru-kit-api-server.md b/docs/next/cli/mineru-kit-api-server.md
index 9c17f117..837c9263 100644
--- a/docs/next/cli/mineru-kit-api-server.md
+++ b/docs/next/cli/mineru-kit-api-server.md
@@ -68,7 +68,7 @@ api-server 启动时应优先使用 `--tier`:
```bash
mineru-kit api-server --tier medium --port 16580
mineru-kit api-server --tier high --port 15982
-mineru-kit api-server --tier high --effort high --language en --ocr-mode ocr --disable-table
+mineru-kit api-server --tier high --language en --ocr-mode ocr --disable-image-analysis
```
`--tier` 会选择该 tier 的默认 backend。高级部署者可以同时传 `--tier` 和 `--backend`,用于选择具体实现;如果二者不兼容,启动应报错。
@@ -94,7 +94,7 @@ mineru-kit api-server --tier high --effort high --language en --ocr-mode ocr --d
- language
- ocr-mode
- effort
-- disable-table / disable-formula / disable-image-analysis
+- disable-image-analysis
- concurrency
- upload-dir
- url-timeout
diff --git a/docs/next/cli/mineru-kit-parse.md b/docs/next/cli/mineru-kit-parse.md
index ecbb48a6..26e92b5f 100644
--- a/docs/next/cli/mineru-kit-parse.md
+++ b/docs/next/cli/mineru-kit-parse.md
@@ -142,10 +142,10 @@ remote 模式通过以下参数进入:
| 分组 | 示例 |
|------|------|
| 文档参数 | pages、language、ocr-mode |
-| local 模式 | tier、backend、effort、disable-* |
+| local 模式 | tier、backend、effort、disable-image-analysis |
| remote 模式 | remote、remote-url、api-key |
| 输出控制 | format、output |
-local 模式的 `language`、`ocr-mode`、`effort`、`disable-table`、`disable-formula`、`disable-image-analysis` 与 `mineru-kit api-server` 保持一致。
+local 模式的 `language`、`ocr-mode`、`effort`、`disable-image-analysis` 与 `mineru-kit api-server` 保持一致。
完整决策背景见 [ADR-0016](../decisions/0016-mineru-kit-parse-command.md)。
diff --git a/docs/next/decisions/0016-mineru-kit-parse-command.md b/docs/next/decisions/0016-mineru-kit-parse-command.md
index 8bae54ad..b8b5501d 100644
--- a/docs/next/decisions/0016-mineru-kit-parse-command.md
+++ b/docs/next/decisions/0016-mineru-kit-parse-command.md
@@ -117,11 +117,9 @@ mineru-kit parse <input...> -o <output> [flags]
- `--language`
- `--ocr-mode`
- `--effort`
-- `--disable-table`
-- `--disable-formula`
- `--disable-image-analysis`
-不再以新设计暴露旧式命名,如 `--lang`、`--method`、`--table`、`--formula`、`--image-analysis`。
+不再以新设计暴露旧式命名,如 `--lang`、`--method`、`--image-analysis`。
### 7. 输出规则
diff --git a/docs/next/decisions/0017-mineru-kit-api-server-command.md b/docs/next/decisions/0017-mineru-kit-api-server-command.md
index e42999e5..d3acd921 100644
--- a/docs/next/decisions/0017-mineru-kit-api-server-command.md
+++ b/docs/next/decisions/0017-mineru-kit-api-server-command.md
@@ -86,8 +86,6 @@ backend 不是普通 API 协议层字段。
- `--language`
- `--ocr-mode`
- `--effort`
-- `--disable-table`
-- `--disable-formula`
- `--disable-image-analysis`
- `--concurrency`
- `--upload-dir`
diff --git a/docs/next/middle-json/envelope.md b/docs/next/middle-json/envelope.md
index 00a5aa72..75797985 100644
--- a/docs/next/middle-json/envelope.md
+++ b/docs/next/middle-json/envelope.md
@@ -88,8 +88,6 @@
|------|------|------|
| `ocr_enabled` | bool | 是否启用 OCR。 |
| `vlm_ocr_enabled` | bool | Hybrid 中 VLM OCR 是否启用。 |
-| `formula_enabled` | bool | 是否启用公式识别。 |
-| `table_enabled` | bool | 是否启用表格识别。 |
| `image_analysis` | bool | 是否启用图片分析。 |
features 是开放字典。新增字段不破坏 schema。
diff --git a/docs/next/sdk/parser.md b/docs/next/sdk/parser.md
index 24787f04..e878563f 100644
--- a/docs/next/sdk/parser.md
+++ b/docs/next/sdk/parser.md
@@ -57,8 +57,6 @@ def parse(
backend: str | None = None,
language: str = "ch",
ocr_mode: str | None = None,
- disable_table: bool = False,
- disable_formula: bool = False,
disable_image_analysis: bool = False,
server_url: str | None = None,
page_range: str = "",
@@ -71,12 +69,12 @@ async def parse_async(...) -> ParseResult: ...
- `tier` 是面向用户的质量档位。
- `backend` 是高级参数;显式传入时覆盖 `tier`。
-- `language`、`ocr_mode`、`disable_table`、`disable_formula`、`disable_image_analysis` 与 `mineru-kit api-server` 启动参数保持一致。
+- `language`、`ocr_mode`、`disable_image_analysis` 与 `mineru-kit api-server` 启动参数保持一致。
- `page_range` 使用与 CLI/API 一致的页码表达。
- `server_url` 只用于需要委托 VLM/remote backend 的情况,不能触发隐式远端上传。
- 返回值始终是 `ParseResult`。
-`method`、`lang`、`table_enable`、`formula_enable`、`image_analysis` 仅作为兼容参数保留;新增实现和文档应使用 `ocr_mode`、`language` 和 `disable_*`。
+`method`、`lang`、`image_analysis` 仅作为兼容参数保留;新增实现和文档应使用 `ocr_mode`、`language` 和 `disable_image_analysis`。
`mineru-kit api-server` 内部应复用 `parse_async()`,避免在 server 层重复维护 parser dispatch 和 tier/backend 兼容规则。
diff --git a/docs/zh/usage/cli_tools.md b/docs/zh/usage/cli_tools.md
index 53a5e5e4..8c3538d3 100644
--- a/docs/zh/usage/cli_tools.md
+++ b/docs/zh/usage/cli_tools.md
@@ -20,8 +20,6 @@ Options:
-u, --url TEXT 当使用 http-client 时,传给服务端后端的 OpenAI 兼容地址
-s, --start INTEGER 开始解析的页码(从 0 开始)
-e, --end INTEGER 结束解析的页码(从 0 开始)
- -f, --formula BOOLEAN 是否启用公式解析(默认开启)
- -t, --table BOOLEAN 是否启用表格解析(默认开启)
--image-analysis BOOLEAN 是否启用 hybrid 的图片/图表分析;Hybrid
low 和 medium 强度会自动关闭图片/图表分析(默认开启)
--client-side-output-generation BOOLEAN
@@ -102,19 +100,11 @@ MinerU命令行工具的某些参数存在相同功能的环境变量配置,
* 用于指定配置文件路径
* 默认为用户目录下的`mineru.json`,可通过环境变量指定其他配置文件路径。
-- `MINERU_FORMULA_ENABLE`:
- * 用于启用公式解析
- * 默认为`true`,可通过环境变量设置为`false`来禁用公式解析。
-
- `MINERU_FORMULA_CH_SUPPORT`:
* 用于启用中文公式解析优化(实验性功能)
* 默认为`false`,可通过环境变量设置为`true`来启用中文公式解析优化。
* 仅对本地 Hybrid 模型执行生效。
-- `MINERU_TABLE_ENABLE`:
- * 用于启用表格解析
- * 默认为`true`,可通过环境变量设置为`false`来禁用表格解析。
-
- `MINERU_TABLE_MERGE_ENABLE`:
* 用于启用表格合并功能
* 默认为`true`,可通过环境变量设置为`false`来禁用表格合并功能。
diff --git a/mineru/backend/hybrid/hybrid_analyze.py b/mineru/backend/hybrid/hybrid_analyze.py
index 5a4ecd7d..0e6843bd 100644
--- a/mineru/backend/hybrid/hybrid_analyze.py
+++ b/mineru/backend/hybrid/hybrid_analyze.py
@@ -24,7 +24,7 @@ from ...utils.backend_options import (
MAX_HYBRID_EFFORT,
validate_effort,
)
-from ...utils.config_reader import get_device, get_processing_window_size, get_table_enable
+from ...utils.config_reader import get_device, get_processing_window_size
from ...utils.enum_class import ImageType
from ...utils.image_payload import ImagePayloadCache
from ...utils.model_utils import clean_memory, clean_vram, crop_img, get_vram
@@ -152,6 +152,12 @@ def _load_vlm_runtime() -> dict[str, Any]:
}
+def _discard_legacy_formula_table_kwargs(kwargs: dict[str, object]) -> None:
+ """丢弃旧公式/表格开关,避免兼容参数继续影响 Hybrid analyzer 行为。"""
+ for key in ("inline_formula_enable", "formula_enable", "table_enable"):
+ kwargs.pop(key, None)
+
+
def _is_hybrid_ocr_det_candidate(block: dict[str, Any]) -> bool:
"""判断 Hybrid 文本类块是否需要 OCR det 生成行级视觉信息。"""
return (block.get("type") or block.get("label")) in NOT_EXTRACT_TYPES
@@ -641,11 +647,6 @@ def _build_high_layout_blocks(
return blocks_list
-def _is_medium_table_enabled() -> bool:
- """读取 Hybrid medium 的表格开关,复用 Hybrid 当前通过环境变量传入的表格配置。"""
- return get_table_enable(os.getenv("MINERU_VLM_TABLE_ENABLE", "True").lower() == "true")
-
-
def _normalize_medium_content(value: Any) -> str:
"""将 medium 本地模型输出的文本字段规范成 Hybrid block 可消费的字符串。"""
if isinstance(value, list):
@@ -724,15 +725,9 @@ def _run_medium_formula_recognition(
local_context: HybridLocalModelContext,
images_layout_res: list[list[dict[str, Any]]],
np_images: list[np.ndarray],
- formula_enable: bool,
batch_ratio: int,
) -> list[list[dict[str, Any]]]:
"""执行 Hybrid medium 的本地公式识别,并返回供 OCR det 遮罩使用的公式框。"""
- if not formula_enable:
- for layout_res in images_layout_res:
- layout_res[:] = [item for item in layout_res if item.get("label") != "inline_formula"]
- return [[] for _ in images_layout_res]
-
images_mfd_res = []
for layout_res in images_layout_res:
page_formula_res = []
@@ -965,9 +960,6 @@ def _apply_medium_table_recognition(
batch_ratio: int,
) -> None:
"""执行 Hybrid medium 的本地表格识别,结果写回 layout table 项的 html 字段。"""
- if not _is_medium_table_enabled():
- return
-
table_items = _collect_medium_table_items(images_layout_res, np_images, lang_list)
if not table_items:
return
@@ -1033,7 +1025,6 @@ def _prune_medium_empty_ocr_text_blocks(images_layout_res: list[list[dict[str, A
def _extract_with_local_layout(
images_pil_list: list[Image.Image],
language: str | None,
- inline_formula_enable: bool,
_ocr_enable: bool,
batch_ratio: int,
) -> tuple[list[list[dict[str, Any]]], HybridLocalModelContext]:
@@ -1042,7 +1033,7 @@ def _extract_with_local_layout(
local_context = local_context_singleton.get_model(
lang=language,
# medium 本地路径会直接执行公式识别;OCR 扫描件也需要加载 MFR。
- formula_enable=inline_formula_enable,
+ formula_enable=True,
)
np_images = [np.asarray(pil_image).copy() for pil_image in images_pil_list]
images_layout_res = run_layout_inference(
@@ -1055,7 +1046,6 @@ def _extract_with_local_layout(
local_context,
images_layout_res,
np_images,
- inline_formula_enable,
batch_ratio,
)
clean_vram(local_context.device, vram_threshold=8)
@@ -1191,7 +1181,6 @@ def _process_ocr_and_formulas(
images_pil_list: list[Image.Image],
model_list: list[list[dict[str, Any]]],
language: str | None,
- inline_formula_enable: bool,
_ocr_enable: bool,
batch_ratio: int = 1,
*,
@@ -1202,7 +1191,6 @@ def _process_ocr_and_formulas(
# 遍历model_list,对文本块截图交由OCR识别
# 根据_ocr_enable决定ocr只开det还是det+rec
- # 根据inline_formula_enable决定是使用mfd和ocr结合的方式,还是纯ocr方式
# 将PIL图片转换为numpy数组
np_images = [np.asarray(pil_image).copy() for pil_image in images_pil_list]
@@ -1212,26 +1200,23 @@ def _process_ocr_and_formulas(
local_context_singleton = HybridLocalModelContextSingleton()
local_context = local_context_singleton.get_model(
lang=language,
- formula_enable=inline_formula_enable,
+ formula_enable=True,
)
if images_layout_res is None:
# 没有外部复用的 layout 时,按旧逻辑为公式和标题拆分补跑一次本地 layout。
- layout_images = _mask_image_regions(np_images, model_list) if inline_formula_enable else np_images
+ layout_images = _mask_image_regions(np_images, model_list)
images_layout_res = _predict_layout_for_title_split(local_context, layout_images, batch_ratio)
- if inline_formula_enable:
- images_mfd_res = _build_inline_formula_inputs(images_layout_res)
- # 公式识别
- inline_formula_list = run_mfr_inference(
- local_context.mfr_model.batch_predict,
- images_mfd_res,
- np_images,
- batch_size=batch_ratio * MFR_BASE_BATCH_SIZE,
- interline_enable=True,
- )
- else:
- inline_formula_list = [[] for _ in range(len(images_pil_list))]
+ images_mfd_res = _build_inline_formula_inputs(images_layout_res)
+ # 公式识别
+ inline_formula_list = run_mfr_inference(
+ local_context.mfr_model.batch_predict,
+ images_mfd_res,
+ np_images,
+ batch_size=batch_ratio * MFR_BASE_BATCH_SIZE,
+ interline_enable=True,
+ )
mfd_res = []
for page_inline_formula_list in inline_formula_list:
@@ -1276,7 +1261,6 @@ def _extract_high_with_local_layout(
predictor: Any,
images_pil_list: list[Image.Image],
language: str | None,
- inline_formula_enable: bool,
_ocr_enable: bool,
batch_ratio: int,
) -> tuple[list[list[dict[str, Any]]], HybridLocalModelContext]:
@@ -1285,7 +1269,7 @@ def _extract_high_with_local_layout(
local_context = local_context_singleton.get_model(
lang=language,
# VLM 文本路径只需要本地 layout 与 OCR det,不需要加载 MFR。
- formula_enable=inline_formula_enable and not _ocr_enable,
+ formula_enable=not _ocr_enable,
)
np_images = [np.asarray(pil_image).copy() for pil_image in images_pil_list]
images_layout_res = _predict_layout_for_title_split(local_context, np_images, batch_ratio)
@@ -1310,7 +1294,6 @@ def _extract_high_with_local_layout(
images_pil_list,
window_model_list,
language,
- inline_formula_enable,
False,
batch_ratio=batch_ratio,
local_context=local_context,
@@ -1323,7 +1306,6 @@ async def _aio_extract_high_with_local_layout(
predictor: Any,
images_pil_list: list[Image.Image],
language: str | None,
- inline_formula_enable: bool,
_ocr_enable: bool,
batch_ratio: int,
) -> tuple[list[list[dict[str, Any]]], HybridLocalModelContext]:
@@ -1331,7 +1313,7 @@ async def _aio_extract_high_with_local_layout(
local_context_singleton = HybridLocalModelContextSingleton()
local_context = local_context_singleton.get_model(
lang=language,
- formula_enable=inline_formula_enable,
+ formula_enable=not _ocr_enable,
)
np_images = [np.asarray(pil_image).copy() for pil_image in images_pil_list]
images_layout_res = await asyncio.to_thread(
@@ -1363,7 +1345,6 @@ async def _aio_extract_high_with_local_layout(
images_pil_list,
window_model_list,
language,
- inline_formula_enable,
False,
batch_ratio,
local_context=local_context,
@@ -1562,7 +1543,6 @@ def doc_analyze(
] = "transformers",
parse_method: str = "auto",
language: str = "ch",
- inline_formula_enable: bool = True,
model_path: str | None = None,
server_url: str | None = None,
effort: Literal["medium", "high", "extra_high"] = DEFAULT_HYBRID_EFFORT,
@@ -1572,6 +1552,7 @@ def doc_analyze(
**kwargs: object,
) -> tuple[list[PageInfo], list[list[dict[str, Any]]], bool]:
client_side_output_generation = bool(kwargs.pop("client_side_output_generation", False))
+ _discard_legacy_formula_table_kwargs(kwargs)
effort = validate_effort(effort)
image_analysis = image_analysis if effort == MAX_HYBRID_EFFORT else False
if effort == LOCAL_HYBRID_EFFORT:
@@ -1618,7 +1599,6 @@ def doc_analyze(
window_model_list, local_context = _extract_with_local_layout(
images_pil_list,
language,
- inline_formula_enable,
_ocr_enable,
batch_ratio,
)
@@ -1628,7 +1608,6 @@ def doc_analyze(
predictor,
images_pil_list,
language,
- inline_formula_enable,
_ocr_enable,
batch_ratio,
)
@@ -1656,7 +1635,6 @@ def doc_analyze(
images_pil_list,
window_model_list,
language,
- inline_formula_enable,
False,
batch_ratio=batch_ratio,
)
@@ -1728,7 +1706,6 @@ async def aio_doc_analyze(
] = "transformers",
parse_method: str = "auto",
language: str = "ch",
- inline_formula_enable: bool = True,
model_path: str | None = None,
server_url: str | None = None,
effort: Literal["medium", "high", "extra_high"] = DEFAULT_HYBRID_EFFORT,
@@ -1738,6 +1715,7 @@ async def aio_doc_analyze(
**kwargs: object,
) -> tuple[list[PageInfo], list[list[dict[str, Any]]], bool]:
client_side_output_generation = bool(kwargs.pop("client_side_output_generation", False))
+ _discard_legacy_formula_table_kwargs(kwargs)
effort = validate_effort(effort)
image_analysis = image_analysis if effort == MAX_HYBRID_EFFORT else False
if effort == LOCAL_HYBRID_EFFORT:
@@ -1785,7 +1763,6 @@ async def aio_doc_analyze(
_extract_with_local_layout,
images_pil_list,
language,
- inline_formula_enable,
_ocr_enable,
batch_ratio,
)
@@ -1795,7 +1772,6 @@ async def aio_doc_analyze(
predictor,
images_pil_list,
language,
- inline_formula_enable,
_ocr_enable,
batch_ratio,
)
@@ -1825,7 +1801,6 @@ async def aio_doc_analyze(
images_pil_list,
window_model_list,
language,
- inline_formula_enable,
False,
batch_ratio=batch_ratio,
)
diff --git a/mineru/backend/hybrid/model_output_to_middle_json.py b/mineru/backend/hybrid/model_output_to_middle_json.py
index b31b7e23..d18b263c 100644
--- a/mineru/backend/hybrid/model_output_to_middle_json.py
+++ b/mineru/backend/hybrid/model_output_to_middle_json.py
@@ -2,11 +2,9 @@
from __future__ import annotations
-import os
from typing import Any
from ...types import Block, BlockType, PageInfo
-from ...utils.config_reader import get_table_enable
from ...utils.hash_utils import bytes_md5
from ...utils.image_payload import ImagePayloadCache
from ...utils.pdf_document import PDFPage
@@ -174,9 +172,7 @@ def finalize_middle_json_from_preproc(pages: list[PageInfo], effort: str = DEFAU
auto_merge_vertical_by_det=effort in {LOCAL_HYBRID_EFFORT, LAYOUT_HYBRID_EFFORT},
)
- table_enable = get_table_enable(os.getenv("MINERU_VLM_TABLE_ENABLE", "True").lower() == "true")
- if table_enable:
- cross_page_table_merge(pages)
+ cross_page_table_merge(pages)
apply_title_leveling_to_pdf_info(pages)
_normalize_split_title_blocks(pages)
diff --git a/mineru/cli_old/api_client.py b/mineru/cli_old/api_client.py
index c0ec35e8..5132ea51 100644
--- a/mineru/cli_old/api_client.py
+++ b/mineru/cli_old/api_client.py
@@ -788,8 +788,6 @@ def build_parse_request_form_data(
lang_list: Sequence[str],
backend: str,
parse_method: str,
- formula_enable: bool,
- table_enable: bool,
server_url: Optional[str],
start_page_id: int,
end_page_id: Optional[int],
@@ -811,8 +809,6 @@ def build_parse_request_form_data(
"backend": backend,
"parse_method": parse_method,
"effort": effort,
- "formula_enable": str(formula_enable).lower(),
- "table_enable": str(table_enable).lower(),
"image_analysis": str(image_analysis).lower(),
"return_md": str(return_md).lower(),
"return_middle_json": str(return_middle_json).lower(),
diff --git a/mineru/cli_old/api_request.py b/mineru/cli_old/api_request.py
index 544c2dd4..753d9740 100644
--- a/mineru/cli_old/api_request.py
+++ b/mineru/cli_old/api_request.py
@@ -39,8 +39,6 @@ class ParseRequestOptions:
backend: str
effort: str
parse_method: str
- formula_enable: bool
- table_enable: bool
image_analysis: bool
server_url: Optional[str]
return_md: bool
@@ -149,14 +147,6 @@ async def parse_request_form(
""",
),
] = "auto",
- formula_enable: Annotated[
- bool,
- Form(description="Enable formula parsing."),
- ] = True,
- table_enable: Annotated[
- bool,
- Form(description="Enable table parsing."),
- ] = True,
image_analysis: Annotated[
bool,
Form(
@@ -249,8 +239,6 @@ async def parse_request_form(
backend=backend,
effort=effort,
parse_method=validate_parse_method(parse_method),
- formula_enable=formula_enable,
- table_enable=table_enable,
image_analysis=image_analysis,
server_url=server_url,
return_md=return_md,
diff --git a/mineru/cli_old/client.py b/mineru/cli_old/client.py
index 202e9525..31c76b9a 100644
--- a/mineru/cli_old/client.py
+++ b/mineru/cli_old/client.py
@@ -604,8 +604,6 @@ def build_request_form_data(
lang: str,
backend: str,
method: str,
- formula_enable: bool,
- table_enable: bool,
server_url: Optional[str],
start_page_id: int,
end_page_id: Optional[int],
@@ -621,8 +619,6 @@ def build_request_form_data(
lang_list=[lang],
backend=backend,
parse_method=method,
- formula_enable=formula_enable,
- table_enable=table_enable,
image_analysis=image_analysis,
effort=effort,
server_url=server_url,
@@ -855,8 +851,6 @@ async def run_orchestrated_cli(
api_url: Optional[str],
start_page_id: int,
end_page_id: Optional[int],
- formula_enable: bool,
- table_enable: bool,
image_analysis: bool = True,
effort: str = DEFAULT_HYBRID_EFFORT,
client_side_output_generation: bool = False,
@@ -917,8 +911,6 @@ async def run_orchestrated_cli(
lang=lang,
backend=backend,
method=method,
- formula_enable=formula_enable,
- table_enable=table_enable,
image_analysis=image_analysis,
effort=effort,
server_url=server_url,
@@ -1073,22 +1065,6 @@ async def run_orchestrated_cli(
default=None,
help="The ending page for PDF parsing, beginning from 0.",
)
- "-f",
- "--formula",
- "formula_enable",
- type=bool,
- default=True,
- help="Enable formula parsing. Default is True. ",
-)
- "-t",
- "--table",
- "table_enable",
- type=bool,
- default=True,
- help="Enable table parsing. Default is True. ",
-)
@click.option(
"--image-analysis",
"image_analysis",
@@ -1115,8 +1091,6 @@ def main(
server_url: Optional[str],
start_page_id: int,
end_page_id: Optional[int],
- formula_enable: bool,
- table_enable: bool,
image_analysis: bool,
client_side_output_generation: bool,
) -> None:
@@ -1132,8 +1106,6 @@ def main(
api_url=api_url,
start_page_id=start_page_id,
end_page_id=end_page_id,
- formula_enable=formula_enable,
- table_enable=table_enable,
image_analysis=image_analysis,
client_side_output_generation=client_side_output_generation,
extra_cli_args=tuple(ctx.args),
diff --git a/mineru/cli_old/common.py b/mineru/cli_old/common.py
index 90f2736c..60c5ce75 100644
--- a/mineru/cli_old/common.py
+++ b/mineru/cli_old/common.py
@@ -361,7 +361,6 @@ def _process_hybrid(
pdf_bytes_list: list[bytes],
h_lang_list: list[str],
parse_method: str,
- inline_formula_enable: bool,
backend: str,
f_draw_layout_bbox: bool,
f_draw_span_bbox: bool,
@@ -395,7 +394,6 @@ def _process_hybrid(
backend=backend,
parse_method=parse_method,
language=lang,
- inline_formula_enable=inline_formula_enable,
server_url=server_url,
page_index_map=page_index_map_list[idx] if page_index_map_list is not None else None,
image_cache=image_cache,
@@ -435,7 +433,6 @@ async def _async_process_hybrid(
pdf_bytes_list: list[bytes],
h_lang_list: list[str],
parse_method: str,
- inline_formula_enable: bool,
backend: str,
f_draw_layout_bbox: bool,
f_draw_span_bbox: bool,
@@ -469,7 +466,6 @@ async def _async_process_hybrid(
backend=backend,
parse_method=parse_method,
language=lang,
- inline_formula_enable=inline_formula_enable,
server_url=server_url,
page_index_map=page_index_map_list[idx] if page_index_map_list is not None else None,
image_cache=image_cache,
@@ -570,8 +566,6 @@ def do_parse(
p_lang_list: list[str],
backend: str = DEFAULT_BACKEND,
parse_method: str = "auto",
- formula_enable: bool = True,
- table_enable: bool = True,
server_url: str | None = None,
f_draw_layout_bbox: bool = True,
f_draw_span_bbox: bool = True,
@@ -621,16 +615,12 @@ def do_parse(
if backend == "engine" and effort != LOCAL_HYBRID_EFFORT:
backend = get_vlm_engine(inference_engine="auto", is_async=False)
- os.environ["MINERU_VLM_TABLE_ENABLE"] = str(table_enable)
- os.environ["MINERU_VLM_FORMULA_ENABLE"] = "true"
-
_process_hybrid(
output_dir,
pdf_file_names,
pdf_bytes_list,
p_lang_list,
parse_method,
- formula_enable,
backend,
f_draw_layout_bbox,
f_draw_span_bbox,
@@ -659,8 +649,6 @@ async def aio_do_parse(
p_lang_list: list[str],
backend: str = DEFAULT_BACKEND,
parse_method: str = "auto",
- formula_enable: bool = True,
- table_enable: bool = True,
server_url: str | None = None,
f_draw_layout_bbox: bool = True,
f_draw_span_bbox: bool = True,
@@ -712,16 +700,12 @@ async def aio_do_parse(
if backend == "engine" and effort != LOCAL_HYBRID_EFFORT:
backend = get_vlm_engine(inference_engine="auto", is_async=True)
- os.environ["MINERU_VLM_TABLE_ENABLE"] = str(table_enable)
- os.environ["MINERU_VLM_FORMULA_ENABLE"] = "true"
-
await _async_process_hybrid(
output_dir,
pdf_file_names,
pdf_bytes_list,
p_lang_list,
parse_method,
- formula_enable,
backend,
f_draw_layout_bbox,
f_draw_span_bbox,
diff --git a/mineru/cli_old/fast_api.py b/mineru/cli_old/fast_api.py
index 4d49d75c..91207954 100644
--- a/mineru/cli_old/fast_api.py
+++ b/mineru/cli_old/fast_api.py
@@ -147,8 +147,6 @@ class AsyncParseTask:
parse_method: str
effort: str
lang_list: list[str]
- formula_enable: bool
- table_enable: bool
image_analysis: bool
server_url: Optional[str]
return_md: bool
@@ -835,8 +833,6 @@ async def run_parse_job(
backend=request_options.backend,
parse_method=request_options.parse_method,
effort=request_options.effort,
- formula_enable=request_options.formula_enable,
- table_enable=request_options.table_enable,
image_analysis=request_options.image_analysis,
server_url=request_options.server_url,
f_draw_layout_bbox=False,
@@ -891,8 +887,6 @@ async def create_async_parse_task(
parse_method=request_options.parse_method,
effort=request_options.effort,
lang_list=request_options.lang_list,
- formula_enable=request_options.formula_enable,
- table_enable=request_options.table_enable,
image_analysis=request_options.image_analysis,
server_url=request_options.server_url,
return_md=request_options.return_md,
diff --git a/mineru/kit/commands/api_server.py b/mineru/kit/commands/api_server.py
index 6e5675a1..7ac5b123 100644
--- a/mineru/kit/commands/api_server.py
+++ b/mineru/kit/commands/api_server.py
@@ -42,8 +42,6 @@ def api_server_cmd(
max_wait: int = 600,
language: str = "ch",
ocr_mode: Literal["auto", "txt", "ocr"] = "auto",
- disable_table: bool = False,
- disable_formula: bool = False,
disable_image_analysis: bool = False,
api_key: str | None = None,
) -> None:
@@ -72,8 +70,6 @@ def api_server_cmd(
ocr_mode,
*tier_args,
*(["--upload-dir", upload_dir] if upload_dir else []),
- *(["--disable-table"] if disable_table else []),
- *(["--disable-formula"] if disable_formula else []),
*(["--disable-image-analysis"] if disable_image_analysis else []),
*(["--api-key", api_key] if api_key else []),
],
diff --git a/mineru/kit/commands/parse.py b/mineru/kit/commands/parse.py
index c1e9ccff..9740009a 100644
--- a/mineru/kit/commands/parse.py
+++ b/mineru/kit/commands/parse.py
@@ -35,8 +35,6 @@ def parse_cmd(
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,
) -> None:
if not inputs:
@@ -85,8 +83,6 @@ def parse_cmd(
language=normalized_language,
ocr_mode=ocr_mode,
effort=normalized_effort,
- disable_table=disable_table,
- disable_formula=disable_formula,
disable_image_analysis=disable_image_analysis,
page_range=pages or "",
)
diff --git a/mineru/kit/main.py b/mineru/kit/main.py
index a1435fce..ad026f65 100644
--- a/mineru/kit/main.py
+++ b/mineru/kit/main.py
@@ -50,8 +50,6 @@ def parse_command(
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"),
) -> None:
"""Parse files or directories into markdown, middle JSON, or zip outputs."""
@@ -69,8 +67,6 @@ def parse_command(
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,
)
@@ -90,8 +86,6 @@ def api_server_command(
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"),
- 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"),
api_key: str | None = typer.Option(None, "--api-key", help="Optional fixed API key"),
) -> None:
@@ -106,8 +100,6 @@ def api_server_command(
max_wait=max_wait,
language=language,
ocr_mode=ocr_mode, # type: ignore[arg-type]
- disable_table=disable_table,
- disable_formula=disable_formula,
disable_image_analysis=disable_image_analysis,
api_key=api_key,
)
diff --git a/mineru/parser/__init__.py b/mineru/parser/__init__.py
index e1ea483a..74b7349a 100644
--- a/mineru/parser/__init__.py
+++ b/mineru/parser/__init__.py
@@ -55,14 +55,10 @@ def _build_parser(
language: str = "ch",
ocr_mode: str = "auto",
effort: str = DEFAULT_HYBRID_EFFORT,
- disable_table: bool = False,
- disable_formula: bool = False,
disable_image_analysis: bool = False,
server_url: str | None = None,
method: str | None = None,
lang: str | None = None,
- table_enable: bool | None = None,
- formula_enable: bool | None = None,
image_analysis: bool | None = None,
) -> DocumentParser:
path = Path(path)
@@ -70,8 +66,6 @@ def _build_parser(
runtime = resolve_runtime_options(tier=tier, backend=backend, effort=effort)
resolved_ocr_mode = method or ocr_mode
resolved_language = lang or language
- resolved_table_enable = (not disable_table) if table_enable is None else table_enable
- resolved_formula_enable = (not disable_formula) if formula_enable is None else formula_enable
resolved_image_analysis = (not disable_image_analysis) if image_analysis is None else image_analysis
if suffix in _OFFICE_SUFFIXES:
@@ -92,8 +86,6 @@ def _build_parser(
backend=runtime.backend,
method=resolved_ocr_mode,
lang=resolved_language,
- formula_enable=resolved_formula_enable,
- table_enable=resolved_table_enable,
server_url=server_url,
image_analysis=resolved_image_analysis,
effort=runtime.effort,
@@ -112,15 +104,11 @@ def parse(
language: str = "ch",
ocr_mode: str = "auto",
effort: str = DEFAULT_HYBRID_EFFORT,
- disable_table: bool = False,
- disable_formula: bool = False,
disable_image_analysis: bool = False,
server_url: str | None = None,
page_range: str = "",
method: str | None = None,
lang: str | None = None,
- table_enable: bool | None = None,
- formula_enable: bool | None = None,
image_analysis: bool | None = None,
) -> ParseResult:
parser = _build_parser(
@@ -130,14 +118,10 @@ def parse(
language=language,
ocr_mode=ocr_mode,
effort=effort,
- disable_table=disable_table,
- disable_formula=disable_formula,
disable_image_analysis=disable_image_analysis,
server_url=server_url,
method=method,
lang=lang,
- table_enable=table_enable,
- formula_enable=formula_enable,
image_analysis=image_analysis,
)
return parser.parse(path, page_range=page_range)
@@ -151,15 +135,11 @@ async def parse_async(
language: str = "ch",
ocr_mode: str = "auto",
effort: str = DEFAULT_HYBRID_EFFORT,
- disable_table: bool = False,
- disable_formula: bool = False,
disable_image_analysis: bool = False,
server_url: str | None = None,
page_range: str = "",
method: str | None = None,
lang: str | None = None,
- table_enable: bool | None = None,
- formula_enable: bool | None = None,
image_analysis: bool | None = None,
) -> ParseResult:
parser = _build_parser(
@@ -169,14 +149,10 @@ async def parse_async(
language=language,
ocr_mode=ocr_mode,
effort=effort,
- disable_table=disable_table,
- disable_formula=disable_formula,
disable_image_analysis=disable_image_analysis,
server_url=server_url,
method=method,
lang=lang,
- table_enable=table_enable,
- formula_enable=formula_enable,
image_analysis=image_analysis,
)
return await parser.parse_async(path, page_range=page_range)
diff --git a/mineru/parser/api_server.py b/mineru/parser/api_server.py
index ad5f5d55..551c310a 100644
--- a/mineru/parser/api_server.py
+++ b/mineru/parser/api_server.py
@@ -1261,8 +1261,6 @@ async def _run_job(
server_backend: str,
language: str,
ocr_mode: str,
- table_enable: bool,
- formula_enable: bool,
image_analysis: bool,
effort: str = DEFAULT_HYBRID_EFFORT,
url_timeout: int = 60,
@@ -1296,8 +1294,6 @@ async def _run_job(
language=language,
ocr_mode=ocr_mode,
effort=effort,
- disable_table=not table_enable,
- disable_formula=not formula_enable,
disable_image_analysis=not image_analysis,
page_range=page_range,
)
@@ -1769,8 +1765,6 @@ async def create_job(
language_val: str = request.app.state.language
ocr_mode_val: str = request.app.state.ocr_mode
effort_val = runtime.effort
- table_enable_val: bool = request.app.state.table_enable
- formula_enable_val: bool = request.app.state.formula_enable
image_analysis_val: bool = request.app.state.image_analysis
if body.wait > 0:
@@ -1784,8 +1778,6 @@ async def create_job(
language=language_val,
ocr_mode=ocr_mode_val,
effort=effort_val,
- table_enable=table_enable_val,
- formula_enable=formula_enable_val,
image_analysis=image_analysis_val,
url_timeout=url_timeout_val,
)
@@ -1815,8 +1807,6 @@ async def create_job(
language=language_val,
ocr_mode=ocr_mode_val,
effort=effort_val,
- table_enable=table_enable_val,
- formula_enable=formula_enable_val,
image_analysis=image_analysis_val,
url_timeout=url_timeout_val,
)
@@ -2077,8 +2067,6 @@ def create_app(
api_key: str | None = None,
language: str = "ch",
ocr_mode: str = "auto",
- table_enable: bool = True,
- formula_enable: bool = True,
image_analysis: bool = True,
) -> FastAPI:
"""Create a FastAPI application implementing the MinerU v1 REST API.
@@ -2103,10 +2091,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.
- table_enable:
- Whether table recognition is enabled.
- formula_enable:
- Whether formula recognition is enabled.
image_analysis:
Whether image analysis is enabled for Hybrid backends.
"""
@@ -2144,8 +2128,6 @@ def create_app(
application.state.language = language
application.state.ocr_mode = ocr_mode
application.state.effort = effort
- application.state.table_enable = table_enable
- application.state.formula_enable = formula_enable
application.state.image_analysis = image_analysis
yield
if not upload_dir and _upload_dir.exists():
@@ -2175,8 +2157,6 @@ def create_app(
application.state.language = language
application.state.ocr_mode = ocr_mode
application.state.effort = effort
- application.state.table_enable = table_enable
- application.state.formula_enable = formula_enable
application.state.image_analysis = image_analysis
FileStore(_upload_dir).install(application.state)
JobStore(concurrency=concurrency).install(application.state)
@@ -2263,8 +2243,6 @@ def create_app(
type=click.Choice(_OCR_MODES),
help="PDF OCR/text extraction mode. Applies to hybrid-* backends.",
)
[email protected]("--disable-table", is_flag=True, help="Disable table recognition.")
[email protected]("--disable-formula", is_flag=True, help="Disable formula recognition.")
@click.option("--disable-image-analysis", is_flag=True, help="Disable image analysis for Hybrid backends.")
@click.option(
"--api-key",
@@ -2282,8 +2260,6 @@ def main(
max_wait: int,
language: str,
ocr_mode: str,
- disable_table: bool,
- disable_formula: bool,
disable_image_analysis: bool,
api_key: str | None,
) -> None:
@@ -2298,8 +2274,6 @@ def main(
api_key=api_key,
language=language,
ocr_mode=ocr_mode,
- table_enable=not disable_table,
- formula_enable=not disable_formula,
image_analysis=not disable_image_analysis,
)
except ParseServerStartupError as exc:
diff --git a/mineru/parser/pdf.py b/mineru/parser/pdf.py
index 78f6240e..1d4fae40 100644
--- a/mineru/parser/pdf.py
+++ b/mineru/parser/pdf.py
@@ -55,8 +55,6 @@ class PdfBaseParser(DocumentParser):
method: str = "auto",
lang: str = "ch",
effort: str = DEFAULT_HYBRID_EFFORT,
- formula_enable: bool = True,
- table_enable: bool = True,
image_analysis: bool = True,
server_url: str | None = None,
):
@@ -64,8 +62,6 @@ class PdfBaseParser(DocumentParser):
self.method = method
self.lang = lang
self.effort = validate_effort(effort)
- self.formula_enable = formula_enable
- self.table_enable = table_enable
self.image_analysis = image_analysis
self.server_url = server_url
@@ -260,16 +256,12 @@ class PdfHybridParser(PdfBaseParser):
else _resolve_hybrid_backend(self.backend, is_async=False)
)
server_url = self.server_url if backend.endswith("client") else None
- os.environ["MINERU_VLM_FORMULA_ENABLE"] = "true"
- os.environ["MINERU_VLM_TABLE_ENABLE"] = str(self.table_enable).lower()
-
middle_json, model_list, _vlm_ocr_enable = hybrid_doc_analyze(
pdf_bytes,
backend=backend,
parse_method=self.method,
language=self.lang,
effort=self.effort,
- inline_formula_enable=self.formula_enable,
server_url=server_url,
image_analysis=self.image_analysis,
page_index_map=page_index_map,
@@ -290,16 +282,12 @@ class PdfHybridParser(PdfBaseParser):
self.backend if self.effort == LOCAL_HYBRID_EFFORT else _resolve_hybrid_backend(self.backend, is_async=True)
)
server_url = self.server_url if backend.endswith("client") else None
- os.environ["MINERU_VLM_FORMULA_ENABLE"] = "true"
- os.environ["MINERU_VLM_TABLE_ENABLE"] = str(self.table_enable).lower()
-
middle_json, model_list, _vlm_ocr_enable = await hybrid_aio_doc_analyze(
pdf_bytes,
backend=backend,
parse_method=self.method,
language=self.lang,
effort=self.effort,
- inline_formula_enable=self.formula_enable,
server_url=server_url,
image_analysis=self.image_analysis,
page_index_map=page_index_map,
diff --git a/mineru/utils/config_reader.py b/mineru/utils/config_reader.py
index 9ff63eec..47ee7fd4 100644
--- a/mineru/utils/config_reader.py
+++ b/mineru/utils/config_reader.py
@@ -147,18 +147,6 @@ def get_device() -> str:
return "cpu"
-def get_formula_enable(formula_enable: bool) -> bool:
- formula_enable_env = os.getenv("MINERU_FORMULA_ENABLE")
- formula_enable = formula_enable if formula_enable_env is None else formula_enable_env.lower() == "true"
- return formula_enable
-
-
-def get_table_enable(table_enable: bool) -> bool:
- table_enable_env = os.getenv("MINERU_TABLE_ENABLE")
- table_enable = table_enable if table_enable_env is None else table_enable_env.lower() == "true"
- return table_enable
-
-
def get_ocr_det_mask_inline_formula_enable(enable: bool) -> bool:
enable_env = os.getenv("MINERU_OCR_DET_MASK_INLINE_FORMULA_ENABLE")
enable = enable if enable_env is None else enable_env.lower() == "true"
diff --git a/tests/unittest/test_kit_commands.py b/tests/unittest/test_kit_commands.py
index bb2d11c7..3d7a3551 100644
--- a/tests/unittest/test_kit_commands.py
+++ b/tests/unittest/test_kit_commands.py
@@ -2,7 +2,9 @@ from __future__ import annotations
import ast
import asyncio
+import inspect
import json
+import os
import zipfile
from io import BytesIO
from pathlib import Path
@@ -23,6 +25,12 @@ from mineru.utils.image_payload import ImagePayloadCache
runner = CliRunner()
+_REMOVED_DISABLE_TABLE_OPTION = "--disable-" + "table"
+_REMOVED_DISABLE_FORMULA_OPTION = "--disable-" + "formula"
+_REMOVED_TABLE_ENABLE_PARAM = "table" + "_enable"
+_REMOVED_FORMULA_ENABLE_PARAM = "formula" + "_enable"
+_REMOVED_INLINE_FORMULA_PARAM = "inline_" + _REMOVED_FORMULA_ENABLE_PARAM
+
def _assert_unsafe_sidecar_error(output: str) -> None:
"""归一化 Typer/Click 自动换行后的错误输出,再匹配 sidecar 安全错误。"""
@@ -267,6 +275,61 @@ def test_api_server_rejects_backend_and_effort_options() -> None:
assert "--effort" in effort_result.output
+def test_kit_commands_do_not_expose_formula_table_switches() -> None:
+ """校验 mineru-kit 公开命令不再暴露公式/表格识别开关。"""
+ parse_help = runner.invoke(app, ["parse", "--help"])
+ api_server_help = runner.invoke(app, ["api-server", "--help"])
+
+ assert parse_help.exit_code == 0
+ assert api_server_help.exit_code == 0
+ for output in (parse_help.output, api_server_help.output):
+ assert _REMOVED_DISABLE_TABLE_OPTION not in output
+ assert _REMOVED_DISABLE_FORMULA_OPTION not in output
+
+
+def test_cli_old_api_form_builders_remove_formula_table_fields() -> None:
+ """校验旧 API client 表单构造不再声明或发送公式/表格开关。"""
+ from mineru.cli_old import api_client as old_api_client
+ from mineru.cli_old import client as old_client
+
+ for target in (old_api_client.build_parse_request_form_data, old_client.build_request_form_data):
+ parameters = inspect.signature(target).parameters
+ assert _REMOVED_FORMULA_ENABLE_PARAM not in parameters
+ assert _REMOVED_TABLE_ENABLE_PARAM not in parameters
+
+ data = old_api_client.build_parse_request_form_data(
+ lang_list=["ch"],
+ backend="hybrid-engine",
+ parse_method="auto",
+ server_url=None,
+ start_page_id=0,
+ end_page_id=None,
+ image_analysis=True,
+ effort="medium",
+ return_md=True,
+ return_middle_json=True,
+ return_model_output=True,
+ return_content_list=True,
+ return_images=True,
+ response_format_zip=False,
+ return_original_file=False,
+ )
+
+ assert _REMOVED_FORMULA_ENABLE_PARAM not in data
+ assert _REMOVED_TABLE_ENABLE_PARAM not in data
+
+
+def test_cli_old_api_request_models_remove_formula_table_fields() -> None:
+ """校验旧 FastAPI 表单参数对象不再保存公式/表格开关。"""
+ from mineru.cli_old import api_request as old_api_request
+ from mineru.cli_old import fast_api as old_fast_api
+
+ for model in (old_api_request.ParseRequestOptions, old_fast_api.ParseRequestOptions, old_fast_api.AsyncParseTask):
+ annotations = getattr(model, "__annotations__", {})
+ assert _REMOVED_FORMULA_ENABLE_PARAM not in annotations
+ assert _REMOVED_TABLE_ENABLE_PARAM not in annotations
+
+
def test_api_server_forwards_repeated_tiers(monkeypatch: Any) -> None:
seen: dict[str, Any] = {}
@@ -811,8 +874,8 @@ def test_gradio_submit_inputs_are_v1_only() -> None:
assert 'elem_classes=["mineru-client-options"]' not in gradio_text
assert 'elem_classes=["mineru-advanced-popover"]' not in gradio_text
assert "is_ocr = gr.Checkbox(" not in gradio_text
- assert "formula_enable = gr.Checkbox(" not in gradio_text
- assert "table_enable = gr.Checkbox(" not in gradio_text
+ assert _REMOVED_FORMULA_ENABLE_PARAM + " = gr.Checkbox(" not in gradio_text
+ assert _REMOVED_TABLE_ENABLE_PARAM + " = gr.Checkbox(" not in gradio_text
assert "image_analysis = gr.Checkbox(" not in gradio_text
assert "language = gr.Dropdown(" not in gradio_text
assert "use_remote_server=use_remote_server" not in gradio_text
@@ -879,7 +942,7 @@ def test_cli_old_legacy_vlm_branch_maps_to_hybrid_extra_high(monkeypatch: Any, t
def _fake_process_hybrid(*args: Any, **kwargs: Any) -> None:
"""记录 legacy VLM 输入最终进入 Hybrid extra_high 分支。"""
seen["backend"] = args[3]
- seen["hybrid_backend"] = args[6]
+ seen["hybrid_backend"] = args[5]
seen["kwargs"] = kwargs
monkeypatch.setattr(common, "_process_hybrid", _fake_process_hybrid)
@@ -917,10 +980,12 @@ def test_cli_old_hybrid_branch_keeps_effort(monkeypatch: Any, tmp_path: Path) ->
def _fake_process_hybrid(*args: Any, **kwargs: Any) -> None:
"""记录 Hybrid 分支收到的 kwargs,确认 effort 仍传给 hybrid analyzer。"""
- seen["backend"] = args[6]
+ seen["backend"] = args[5]
seen["kwargs"] = kwargs
monkeypatch.setattr(common, "_process_hybrid", _fake_process_hybrid)
+ monkeypatch.setenv("MINERU_VLM_FORMULA_ENABLE", "sentinel-formula")
+ monkeypatch.setenv("MINERU_VLM_TABLE_ENABLE", "sentinel-table")
common.do_parse(
output_dir=str(tmp_path),
@@ -933,6 +998,8 @@ def test_cli_old_hybrid_branch_keeps_effort(monkeypatch: Any, tmp_path: Path) ->
assert seen["backend"] == "vllm-engine"
assert seen["kwargs"]["effort"] == "high"
+ assert os.environ["MINERU_VLM_FORMULA_ENABLE"] == "sentinel-formula"
+ assert os.environ["MINERU_VLM_TABLE_ENABLE"] == "sentinel-table"
def test_cli_old_hybrid_medium_skips_vlm_engine_resolution(monkeypatch: Any, tmp_path: Path) -> None:
@@ -956,7 +1023,7 @@ def test_cli_old_hybrid_medium_skips_vlm_engine_resolution(monkeypatch: Any, tmp
def _fake_process_hybrid(*args: Any, **kwargs: Any) -> None:
"""记录 Hybrid medium 仍进入 Hybrid 处理分支。"""
- seen["backend"] = args[6]
+ seen["backend"] = args[5]
seen["langs"] = list(args[3])
seen["pdf_count"] = len(args[2])
seen["kwargs"] = kwargs
@@ -984,12 +1051,14 @@ def test_process_hybrid_medium_calls_analyzer_per_file(monkeypatch: Any, tmp_pat
calls: list[bytes] = []
languages: list[str] = []
+ analyzer_kwargs: list[dict[str, Any]] = []
outputs: list[tuple[str, str, str]] = []
def fake_doc_analyze(pdf_bytes: bytes, **kwargs: Any) -> tuple[list[PageInfo], list[object], bool]:
"""记录每个文件独立进入 Hybrid medium analyzer。"""
calls.append(pdf_bytes)
languages.append(kwargs["language"])
+ analyzer_kwargs.append(kwargs)
return [PageInfo(page_idx=0, _backend="hybrid")], [], False
monkeypatch.setattr(common, "_load_hybrid_analyze_entrypoint", lambda *_args, **_kwargs: fake_doc_analyze)
@@ -1013,7 +1082,6 @@ def test_process_hybrid_medium_calls_analyzer_per_file(monkeypatch: Any, tmp_pat
pdf_bytes_list=[b"a", b"b"],
h_lang_list=["en", "en"],
parse_method="auto",
- inline_formula_enable=True,
backend="engine",
f_draw_layout_bbox=False,
f_draw_span_bbox=False,
@@ -1028,6 +1096,7 @@ def test_process_hybrid_medium_calls_analyzer_per_file(monkeypatch: Any, tmp_pat
assert calls == [b"a", b"b"]
assert languages == ["en", "en"]
+ assert all(_REMOVED_INLINE_FORMULA_PARAM not in kwargs for kwargs in analyzer_kwargs)
assert [item[0] for item in outputs] == ["a.pdf", "b.pdf"]
@@ -1050,7 +1119,7 @@ def test_cli_old_async_legacy_vlm_branch_maps_to_hybrid_extra_high(monkeypatch:
async def _fake_async_process_hybrid(*args: Any, **kwargs: Any) -> None:
"""记录异步 legacy VLM 输入最终进入 Hybrid extra_high 分支。"""
seen["backend"] = args[3]
- seen["hybrid_backend"] = args[6]
+ seen["hybrid_backend"] = args[5]
seen["kwargs"] = kwargs
monkeypatch.setattr(common, "_async_process_hybrid", _fake_async_process_hybrid)
@@ -1090,10 +1159,12 @@ def test_cli_old_async_hybrid_branch_keeps_effort(monkeypatch: Any, tmp_path: Pa
async def _fake_async_process_hybrid(*args: Any, **kwargs: Any) -> None:
"""记录异步 Hybrid 分支收到的 kwargs,确认 effort 仍传给 hybrid analyzer。"""
- seen["backend"] = args[6]
+ seen["backend"] = args[5]
seen["kwargs"] = kwargs
monkeypatch.setattr(common, "_async_process_hybrid", _fake_async_process_hybrid)
+ monkeypatch.setenv("MINERU_VLM_FORMULA_ENABLE", "sentinel-formula")
+ monkeypatch.setenv("MINERU_VLM_TABLE_ENABLE", "sentinel-table")
asyncio.run(
common.aio_do_parse(
@@ -1108,6 +1179,8 @@ def test_cli_old_async_hybrid_branch_keeps_effort(monkeypatch: Any, tmp_path: Pa
assert seen["backend"] == "vllm-async-engine"
assert seen["kwargs"]["effort"] == "high"
+ assert os.environ["MINERU_VLM_FORMULA_ENABLE"] == "sentinel-formula"
+ assert os.environ["MINERU_VLM_TABLE_ENABLE"] == "sentinel-table"
def test_parse_single_file_middle_json_writes_image_sidecars(
diff --git a/tests/unittest/test_parser_api_contract.py b/tests/unittest/test_parser_api_contract.py
index ea246ec2..007a9439 100644
--- a/tests/unittest/test_parser_api_contract.py
+++ b/tests/unittest/test_parser_api_contract.py
@@ -4,6 +4,7 @@ import inspect
import io
import json
import logging
+import os
import subprocess
import sys
import types
@@ -40,6 +41,16 @@ from mineru.utils.image_payload import ImagePayloadCache
runner = CliRunner()
+_REMOVED_DISABLE_TABLE_PARAM = "disable" + "_table"
+_REMOVED_DISABLE_FORMULA_PARAM = "disable" + "_formula"
+_REMOVED_TABLE_ENABLE_PARAM = "table" + "_enable"
+_REMOVED_FORMULA_ENABLE_PARAM = "formula" + "_enable"
+_REMOVED_INLINE_FORMULA_PARAM = "inline_" + _REMOVED_FORMULA_ENABLE_PARAM
+_REMOVED_DISABLE_TABLE_OPTION = "--disable-" + "table"
+_REMOVED_DISABLE_FORMULA_OPTION = "--disable-" + "formula"
+_REMOVED_TABLE_ENABLE_ENV = "MINERU_" + "TABLE" + "_ENABLE"
+_REMOVED_FORMULA_ENABLE_ENV = "MINERU_" + "FORMULA" + "_ENABLE"
+
def _stub_api_server_dependency_preflight(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(importlib, "import_module", lambda _module_name: object())
@@ -403,7 +414,7 @@ def test_api_client_constructor_does_not_expose_ocr_or_image_options() -> None:
def test_parser_entrypoints_expose_api_server_style_options() -> None:
- for entrypoint in (parse, parse_async):
+ for entrypoint in (parse, parse_async, _build_parser):
parameters = inspect.signature(entrypoint).parameters
assert "tier" in parameters
@@ -411,9 +422,19 @@ def test_parser_entrypoints_expose_api_server_style_options() -> None:
assert "language" in parameters
assert "ocr_mode" in parameters
assert "effort" in parameters
- assert "disable_table" in parameters
- assert "disable_formula" in parameters
assert "disable_image_analysis" in parameters
+ assert _REMOVED_DISABLE_TABLE_PARAM not in parameters
+ assert _REMOVED_DISABLE_FORMULA_PARAM not in parameters
+ assert _REMOVED_TABLE_ENABLE_PARAM not in parameters
+ assert _REMOVED_FORMULA_ENABLE_PARAM not in parameters
+
+
+def test_pdf_hybrid_parser_constructor_removes_formula_table_switches() -> None:
+ """校验 PDF parser 构造链不再公开无效的公式/表格开关。"""
+ parameters = inspect.signature(parser_pdf.PdfHybridParser).parameters
+
+ assert _REMOVED_FORMULA_ENABLE_PARAM not in parameters
+ assert _REMOVED_TABLE_ENABLE_PARAM not in parameters
def test_api_client_omits_page_range_when_unspecified(tmp_path: Path) -> None:
@@ -564,8 +585,8 @@ def test_create_app_does_not_read_runtime_settings_from_env(tmp_path: Path, monk
monkeypatch.setenv("MINERU_LANGUAGE", "en")
monkeypatch.setenv("MINERU_OCR_MODE", "ocr")
monkeypatch.setenv("MINERU_EFFORT", "high")
- monkeypatch.setenv("MINERU_TABLE_ENABLE", "false")
- monkeypatch.setenv("MINERU_FORMULA_ENABLE", "false")
+ monkeypatch.setenv(_REMOVED_TABLE_ENABLE_ENV, "false")
+ monkeypatch.setenv(_REMOVED_FORMULA_ENABLE_ENV, "false")
monkeypatch.setenv("MINERU_IMAGE_ANALYSIS", "false")
app = create_app(upload_dir=str(tmp_path))
@@ -578,9 +599,9 @@ def test_create_app_does_not_read_runtime_settings_from_env(tmp_path: Path, monk
assert app.state.language == "ch"
assert app.state.ocr_mode == "auto"
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
+ assert not hasattr(app.state, _REMOVED_TABLE_ENABLE_PARAM)
+ assert not hasattr(app.state, _REMOVED_FORMULA_ENABLE_PARAM)
def test_api_server_cli_no_longer_exposes_reload() -> None:
@@ -693,8 +714,6 @@ def test_api_server_rendered_outputs_store_image_sidecars(
server_backend="hybrid-engine",
language="ch",
ocr_mode="auto",
- table_enable=True,
- formula_enable=True,
image_analysis=True,
effort="medium",
)
@@ -758,8 +777,6 @@ def test_api_server_middle_json_preserves_backend_for_client_rendering(
server_backend="hybrid-engine",
language="ch",
ocr_mode="auto",
- table_enable=True,
- formula_enable=True,
image_analysis=True,
effort="medium",
)
@@ -825,8 +842,6 @@ def test_api_server_sanitizes_surrogates_in_text_outputs(
server_backend="hybrid-engine",
language="ch",
ocr_mode="auto",
- table_enable=True,
- formula_enable=True,
image_analysis=True,
effort="medium",
)
@@ -880,8 +895,6 @@ def test_api_server_logs_traceback_when_job_file_fails(
server_backend="hybrid-engine",
language="ch",
ocr_mode="auto",
- table_enable=True,
- formula_enable=True,
image_analysis=True,
effort="medium",
)
@@ -1251,14 +1264,23 @@ def test_pdf_hybrid_medium_parser_skips_vlm_backend_resolution(monkeypatch: pyte
raise AssertionError("medium effort should not resolve VLM backend")
monkeypatch.setattr(parser_pdf, "_resolve_hybrid_backend", fail_resolve_backend)
+ monkeypatch.setenv("MINERU_VLM_FORMULA_ENABLE", "sentinel-formula")
+ monkeypatch.setenv("MINERU_VLM_TABLE_ENABLE", "sentinel-table")
- parser = parser_pdf.PdfHybridParser(backend="hybrid-engine", effort="medium", lang="en")
+ parser = parser_pdf.PdfHybridParser(
+ backend="hybrid-engine",
+ effort="medium",
+ lang="en",
+ )
pages = parser._run_analysis(b"%PDF-1.7\n")
assert pages[0]._backend == "hybrid"
assert seen["backend"] == "hybrid-engine"
assert seen["effort"] == "medium"
assert seen["language"] == "en"
+ assert _REMOVED_INLINE_FORMULA_PARAM not in seen
+ assert os.environ["MINERU_VLM_FORMULA_ENABLE"] == "sentinel-formula"
+ assert os.environ["MINERU_VLM_TABLE_ENABLE"] == "sentinel-table"
@pytest.mark.parametrize(
@@ -1368,17 +1390,15 @@ def test_api_server_stores_parser_runtime_options(tmp_path: Path, monkeypatch: p
tier="medium",
language="en",
ocr_mode="ocr",
- table_enable=False,
- formula_enable=False,
image_analysis=False,
)
assert app.state.language == "ch"
assert app.state.ocr_mode == "ocr"
assert app.state.effort == "medium"
- assert app.state.table_enable is False
- assert app.state.formula_enable is False
assert app.state.image_analysis is False
+ assert not hasattr(app.state, _REMOVED_TABLE_ENABLE_PARAM)
+ assert not hasattr(app.state, _REMOVED_FORMULA_ENABLE_PARAM)
def test_api_server_rejects_removed_ch_lite_language(tmp_path: Path) -> None:
@@ -1394,9 +1414,9 @@ def test_api_server_cli_exposes_parser_runtime_options() -> None:
assert "--language" in option_names
assert "--ocr-mode" 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
+ assert _REMOVED_DISABLE_TABLE_OPTION not in option_names
+ assert _REMOVED_DISABLE_FORMULA_OPTION not in option_names
assert _API_SERVER_LANGUAGES == (
"ch",
"ch_server",