Skip to content

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

feat: add --stack option to mineru-kit models show

jinzhenj156a14693415
diff --git a/mineru/kit/commands/models.py b/mineru/kit/commands/models.py
index adf5e930..d75de80d 100644
--- a/mineru/kit/commands/models.py
+++ b/mineru/kit/commands/models.py
@@ -12,6 +12,7 @@ from ...utils.model_registry import (
get_model_repo,
model_repo_names,
model_repos_for_tier,
+ resolve_model_stack,
validate_model_tier,
)
from ...utils.models_download_utils import (
@@ -98,8 +99,19 @@ def download_cmd(
@app.command("show")
-def show_cmd() -> None:
+def show_cmd(
+ stack: str | None = typer.Option(
+ None,
+ "--stack",
+ help="Model stack: auto (default, follows config.model.stack), light, or full.",
+ ),
+) -> None:
"""Show current MinerU model configuration."""
+ try:
+ effective_stack = resolve_model_stack(stack)
+ except ValueError as exc:
+ exit_with_message("invalid_request", str(exc), "stack")
+
config_file = get_config_file_path()
lines = [
f"Config: {config_file}",
@@ -109,17 +121,20 @@ def show_cmd() -> None:
f"model.base_dir.source: {get_config_source('model.base_dir')}",
f"model.source: {config.model.source}",
f"model.source.source: {get_config_source('model.source')}",
+ f"model.stack: {config.model.stack}",
+ f"model.stack.source: {get_config_source('model.stack')}",
+ f"Effective stack: {effective_stack}",
"Repos:",
]
for line in lines:
print_info(line)
for repo in MODEL_REPOS:
- print_info(f" {_format_repo_status(repo)}")
+ print_info(f" {_format_repo_status(repo)} [stack={repo.stack}]")
print_info("Model tiers:")
for tier in DEPLOYMENT_TIERS:
- repos = model_repos_for_tier(tier)
+ repos = model_repos_for_tier(tier, stack=effective_stack)
names = ", ".join(repo.name for repo in repos) or "(none)"
print_info(f" {tier}: {names}")
diff --git a/tests/unittest/test_kit_commands.py b/tests/unittest/test_kit_commands.py
index 0f2303f3..11e1efc5 100644
--- a/tests/unittest/test_kit_commands.py
+++ b/tests/unittest/test_kit_commands.py
@@ -2018,3 +2018,38 @@ def test_models_download_repo_ignores_stack(monkeypatch: Any) -> None:
assert captured["repo"] == "PP-DocLayoutV2_onnx"
assert captured["stack"] == "light"
assert "Downloaded models for PP-DocLayoutV2_onnx" in result.output
+
+
+def test_models_show_displays_stack_fields(tmp_path: Path, monkeypatch: Any) -> None:
+ base_dir = tmp_path / "models"
+ monkeypatch.setattr(models.config.model, "base_dir", str(base_dir))
+ monkeypatch.setattr(models.config.model, "stack", "full")
+
+ result = runner.invoke(app, ["models", "show"])
+
+ assert result.exit_code == 0
+ assert "model.stack: full" in result.output
+ assert "Effective stack: full" in result.output
+ assert "[stack=full]" in result.output
+ assert "[stack=light]" in result.output
+
+
+def test_models_show_with_light_stack_filter(tmp_path: Path, monkeypatch: Any) -> None:
+ """--stack light 时 effective stack 解析为 light,tiers 部分按 light 显示。"""
+ base_dir = tmp_path / "models"
+ monkeypatch.setattr(models.config.model, "base_dir", str(base_dir))
+ monkeypatch.setattr(models.config.model, "stack", "full")
+
+ result = runner.invoke(app, ["models", "show", "--stack", "light"])
+
+ assert result.exit_code == 0
+ assert "Effective stack: light" in result.output
+ assert "PP-DocLayoutV2_onnx: " in result.output
+ assert "PDF-Extract-Kit-1.0: " in result.output
+
+
+def test_models_show_rejects_invalid_stack() -> None:
+ result = runner.invoke(app, ["models", "show", "--stack", "torch"])
+
+ assert result.exit_code == 1
+ assert "Unsupported stack 'torch'" in " ".join(result.output.split())