Add PDF annotation services in CLI - #111
Open
lfoppiano wants to merge 3 commits into
Open
Conversation
…ionPatentAnnotations) Wire the GROBID PDF annotation endpoints into the CLI and batch pipeline. Each service declares its own Accept header, output suffix and write mode: - referenceAnnotations -> application/json, *.references.json - citationPatentAnnotations -> application/json, *.patent-citations.json - annotatePDF -> application/pdf (binary), *.annotated.pdf The TEI -> JSON/Markdown conversion is skipped for these services. Because the annotation endpoints only honor a subset of the processing options, the client warns once when the caller enables an option the selected service will ignore (e.g. consolidate_header on annotatePDF). Documented in the Readme and covered by unit tests. Closes #79
The per-service Accept headers added by the previous commit never left the client: call_api overwrote whatever the caller passed with its own accept_type, so every request went out as application/xml and the annotation endpoints were asked for the wrong representation. It went unnoticed because the tests mock post(), one layer above the overwrite, and assert on what process_pdf passes rather than on what is sent. accept_type is now the fallback, not the last word. A caller that needs a specific representation - JSON coordinates, or the annotated PDF - gets it, and the two new tests exercise the request layer itself so the header cannot silently be dropped again. Verified against a stub server: annotatePDF now writes a real binary PDF and referenceAnnotations real JSON, where all four services previously wrote the same text/plain body.
lfoppiano
force-pushed
the
feature/issue-79-annotation-services
branch
from
August 14, 2026 07:57
f15cc3c to
067cda3
Compare
The "text/plain" the client passed for the process* services never left it: call_api replaced it with its own application/xml, so that is what GROBID has been answering all along. Making the caller's header win in the previous commit was right for the annotation endpoints, but it also sent the TEI services out as text/plain for the first time - a type that describes neither the payload nor what a server enforcing @produces would accept. The default descriptor now names the representation these services actually return, and the two tests that pinned the old value follow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wire the GROBID PDF annotation endpoints into the CLI and batch pipeline. Each service declares its own Accept header, output suffix and write mode:
The TEI -> JSON/Markdown conversion is skipped for these services. Documented in the Readme and covered by unit tests.
Closes #79