Repository navigation
feat: PageSplitClient.split() cuts a PDF that bundles several documents into those documents, each with its pages and its type among the types given; a PDF given by its path is kept in the "Page Split" collection - #725
Merged
Conversation
…ts into those documents, each with its pages and its type among the types given; a PDF given by its path is kept in the "Page Split" collection
PageSplitClient.split(document, types=None, rules=None) takes a path or a doc_id and waits for the job; wait_split() and get_split() read it later. types is {name: description}, a list of names, one name, or a list of {"name", "description", "identifier_key"}; rules is free text. CloudAPI.create_split() and get_split() are the REST calls.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… failed reads of its job, and says a document's type is None when none fits
- One type given as a dict without a list around it, such as {"name": "Schedule K-1", "identifier_key": "the partner"}, was read as {name: description}: types named "name" and "identifier_key" were sent, the job ran and was charged, and nothing raised. A dict whose keys are "name" and any of "description" and "identifier_key" is now that one type.
- Waiting on a job read it every second and raised on the first failed read. A split runs up to about 45 minutes, so one short outage ended split() while the job ran on and was charged, and running it again paid twice; a few waits at once also spent much of the per-user rate limit. It now reads every 2 s, growing to 15 s, and raises on the third failed read in a row, or at once on 401, 403 or 404, as waiting on a document does.
- A document none of the types fits has 'type' None, as Page Classify answers, and its 'identifier' is left out when none is read; the docstrings said the type was left out and the identifier always there.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24b6559536
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
2 tasks done
…of being guessed as one type
A dict whose keys are only "name", "description" and "identifier_key" reads two ways: one type ({"name": "Schedule K-1", "identifier_key": "the partner"}) or the {name: description} shorthand with a type named "name" ({"name": "A legal-name record"}). Reading it as one type relabelled the second silently; reading it as the shorthand relabelled the first. split() now raises PageIndexAPIError for it before any request and says to put one type in a list. A mapping with other type names beside "name" is the shorthand, as before.
The upload test pops the configuration before asserting on it, so the pop does not live inside an assert.
…stead of becoming types named after its keys
{"name": "Schedule K-1", "identifier": ...} (identifier for identifier_key)
and {"Schedule K-1": ..., "identifier_key": ...} got past the guard, which
raised only when every key was name, description or identifier_key. They were
sent as types named "name", "identifier" or "identifier_key", and the job ran
and was charged; in a list the same dict gets the server's 422. A bare dict
with a key named name, description, identifier_key or identifier now raises
before anything is sent; a type with such a name goes in the list form.
rejojer
added a commit
that referenced
this pull request
Nov 30, 2026
pageindex 0.8.3 adds PageSplitClient, Page Split's client (#725).
3 tasks done
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.
What changes
PageSplitClientis Page Split's client, besidePageSearchClient,PageExtractClientandPageClassifyClient, and works the wayPageClassifyClientdoes. Page Split cuts a PDF that bundles several documents, such as a scanned stack or a tax return with its schedules, into those documents.split(document, types=None, *, rules=None, wait=True, timeout=3600, collection="Page Split").POST /split,file) and kept as a document incollection. A file stored already whose document is still processing (HTTP 409 naming itsdoc_id) is waited for, then split by itsdoc_id, asclassify()does.doc_id. A document still processing is waited for, or raises withwait=False.typesis optional:{name: description}(a description may beNone), a list of names, one name, or a list of{"name", "description", "identifier_key"}. A dict alone, without a list, raises before any request when one of its keys isname,description,identifier_keyoridentifier: it could be one type, or the{name: description}shorthand with types of those names, which go in the list form. Without types the PDF is split and every document'stypeisNone, as is thetypeof a document none of the types fits.identifier_keysays what tells two documents of a type apart; such a document carries itsidentifierwhen one is read. A field Page Split does not know in a listed type, such asidentifierforidentifier_key, gets a 422 before anything is charged.rulesis free text: how the caller wants their documents split.GET /split/{id}every 2 s, growing to 15 s, and raisesPageIndexAPIErroron the third failed read in a row (at once on 401, 403 or 404), if the job fails, or if it is not done withintimeout. The default is an hour: a long PDF is read in order and can take most of one.wait_split(job_id)andget_split(job_id)read a job started withwait=False.CloudAPI.create_split()andget_split()are the two requests.Release
The server side is VectifyAI/pageindex-compute#1013 (
POST /split,GET /split/{id}). Release this once that is on Prod.split()'s docstring states the price, $0.005 a page ($5 per 1,000 pages); that PR must charge the same before this is released.Test plan
tests/test_client.py:doc_id;{name: description}, a dict keyed byname,description,identifier_keyoridentifier(one type alone, a misspelt field, or a type named "name" among others) raises and sends nothing;maintoo with the litellm installed here.