Repository navigation
Conversation
This fix makes the pymupdf4llm functions available in PyMuPDF's API.
| use_layout = util._use_layout() and hasattr(pymupdf, "layout") | ||
| use_4llm = util._use_4llm() and hasattr(pymupdf, "pymupdf4llm") |
There was a problem hiding this comment.
We must not use things like hasattr() in tests. If util._use_layout() returns true, then it is an error if pymupdf.layout does not exist.
So i think we should just use util._use_layout() directly in the test.
There was a problem hiding this comment.
Ok - will remove this then, including the checks in the test function itself.
| if pymupdf.__version__ < "2.0": | ||
| print(f"not testing version < {pymupdf.__version__}") | ||
| return |
There was a problem hiding this comment.
We don't generally expect to run pymupdf tests on a different version of pymupdf, and i don't think any other tests check the pymupdf version like this. So this could be removed i think.
| if use_layout: | ||
| print("not testing: layout feature available") | ||
| return | ||
| if not use_4llm: | ||
| print("not testing: 4llm feature not available") | ||
| return |
There was a problem hiding this comment.
We currently only make release wheels that either have both layout and 4llm (pymupdf), or neither layout or 4llm (pymupdf-lite).
So i'm not sure this test is useful? Were you expecting pymupdf-lite to contain pymupdf4llm code?
| Document.to_json = _to_json # noqa: F401 | ||
| Document.to_chunks = _to_chunks # noqa: F401 | ||
| convert_batch = _convert_batch # noqa: F401 | ||
| use_layout = _use_layout # noqa: F401 |
There was a problem hiding this comment.
This setting of use_layout seems new - what is it used for?
There was a problem hiding this comment.
How does a user disable the use of layout?
This fix makes the pymupdf4llm functions available in PyMuPDF's API.