Skip to content

fix(cli): keep convert-remote working on docling-client installs - #4803

Merged
dolfim-ibm merged 1 commit into
mainfrom
fix/cli-slim-convert-remote
Oct 13, 2026
Merged

dolfim-ibm merged 1 commit into
mainfrom
fix/cli-slim-convert-remote

Conversation

@dolfim-ibm

Copy link
Copy Markdown
Member

pip install docling-client installs the docling CLI, but the CLI crashed at startup, also for docling convert-remote --help. The CLI module builds the OCR, layout, and table engine factories at import time. This loads the built-in plugins, which import the engine modules. On docling-slim[service-client] installs these imports fail (packaging, then torch). The existing guard only covered the factory import, not the factory construction.

Changes:

  • docling/cli/main.py: build the factories inside the same try/except ImportError as the factory import. Keep the error.
  • docling convert and --show-external-plugins now exit with code 1 and an install hint (pip install docling, or docling convert-remote) when the local model stack is missing. Before, they showed a traceback.
  • Full installs are unchanged: docling convert --help still lists the available engines.

Checklist:

  • Documentation has been updated, if necessary. (Not necessary: the docs already state that service-client is enough for convert-remote.)
  • Examples have been added, if necessary. (Not necessary.)
  • Tests have been added, if necessary.

Review evidence:

Before: in a fresh venv with only docling-client installed, docling convert-remote --help fails with ModuleNotFoundError: No module named 'packaging' from docling/models/inference_engines/vlm/_utils.py, through get_ocr_factory() in docling/cli/main.py.

After, same venv (uv pip install ./packages/docling-client ., no torch, no packaging):

  • docling convert-remote --help: exit 0, help shown.
  • docling convert-remote file.pdf against an unreachable URL: reaches the service client and reports Cannot reach service.
  • docling convert file.pdf: exit 1 with the install hint.
  • docling --version: works.

Tests:

  • Replaced test_cli_main_importable_without_local_model_stack with two tests that run the CLI in a subprocess with pypdfium2, scipy, torch, and packaging blocked: convert-remote --help must succeed, and convert must exit 1 with the install hint. The subprocess keeps the blocked and re-imported modules out of the other tests (an in-process version polluted tests/test_cli_remote.py). Both tests fail without the fix.
  • uv run pytest tests/test_cli.py tests/test_cli_remote.py tests/test_cli_tools.py: 139 passed.
  • make validate: passed.

Building the OCR, layout, and table engine factories loads the built-in
plugins, which import the engine modules. On docling-client /
docling-slim[service-client] installs these imports fail (packaging,
torch), so the docling CLI crashed at startup, also for
`docling convert-remote --help`.

Guard the factory construction together with the factory import. When
the local model stack is missing, `docling convert` and
`--show-external-plugins` now exit with an install hint instead of a
traceback.

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @dolfim-ibm, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working CLI issues related to the command line interface (CLI) labels Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit c9483fe239. The analysis read the diff only. It did not run code from this pull request.

This pull request prevents import errors when users run docling convert-remote without local model dependencies. It also shows a clear error message when local conversion commands run without required packages.

Topic labels added: bug, CLI.

CI safety: no concern found. A maintainer must still approve CI.

1 related pull request(s) in the same code
PR State Signal Assessment
#4676 open changes the same code related: PR 4676 modifies external plugin discovery in the CLI, while this pull request prevents startup import errors when optional model dependencies are absent.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at c9483fe239. It read the code and did not run it.

I found no defect that decides the merge. In docling/cli/main.py the import guard now also covers building the OCR, layout, and table factories, which is where the packaging and torch imports fail. convert and --show-external-plugins exit with code 1 and an install hint when the stack is missing. Two things are not covered: the old module-level names ocr_factory_internal, layout_factory_internal, and table_structure_factory_internal are gone, and nothing else in the repo uses them. The --show-external-plugins exit path has no test. This second gap is minor.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.75000% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/cli/main.py 43.75% 8 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@PeterStaar-IBM PeterStaar-IBM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@dolfim-ibm
dolfim-ibm merged commit 711fc47 into main Oct 13, 2026
33 checks passed
@dolfim-ibm
dolfim-ibm deleted the fix/cli-slim-convert-remote branch October 13, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working CLI issues related to the command line interface (CLI)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants