Skip to content

feat: the Page clients name a document, a collection and a folder as PageIndexClient does, by doc_id, collection_id and folder_id; the earlier names still work and warn - #735

Merged
rejojer merged 9 commits into
mainfrom
feat/unified-parameter-names
Dec 3, 2026

Conversation

@rejojer

@rejojer rejojer commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

What changes

The five clients name a document, a collection and a folder the same way: doc_id, collection_id, folder_id. The Page clients' earlier names (document, documents, document_ids, collection, folder, start_page, end_page) still work and emit a DeprecationWarning that names the new one, so no caller breaks. Beside the names, the calls that had a counterpart in another client now behave as that counterpart does.

search.search("What was revenue?", doc_id="pi-1", pages="3-9")     # was document=, start_page=, end_page=
search.search("What was revenue?", doc_id=["pi-1", "pi-2"])         # was documents=
search.search_documents("Who audits it?", collection_id="c-1")      # was collection=
search.upload("report.pdf", folder_id="f-1")                        # new
extract.extract("invoice.pdf", schema, folder_id="f-1")             # new, on classify() and split() too
client.wait_outline(doc_id, outline_structure="hierarchical")       # new
client.delete_folder(folder_id)                                     # new
  • Names.
    • PageSearchClient.search() and search_documents() take doc_id (one ID, or a list), collection_id and folder_id, and upload() takes collection_id, as chat() and submit_document() do. Passing a name and its earlier name together raises.
    • extract(), classify() and split() keep collection=: it takes a collection's name as well as its ID, and makes the collection.
    • search() takes pages: "3-9", (3, 9), 3, or (30, None) and (None, 9) for an open end. get_page_content() also takes 5 and (5, 7). A tuple is a range, (first, last): one of other than two items raises, there and in extract() and classify(), which read (5, 7, 9) as pages 5 to 7 (search() read () as the whole document).
  • New calls and parameters, each the counterpart of one that existed.
    • wait_outline(doc_id, timeout, outline_structure) beside wait_document() and the three job waits. Given the outline_structure asked of build_outline(wait=False), it raises when that outline could not be built and the document kept the one it had, as build_outline(wait=True) does.
    • delete_folder(folder_id) beside delete_collection().
    • get_collection_id(name) beside get_document_id() and get_folder_id().
    • folder_id= on PageSearchClient.upload(), extract(), classify() and split(), as on submit_document(). On the three job clients it stands in place of collection: naming another collection with it raises.
    • submit_document(timeout=): the seconds wait=True waits, the outline included.
  • Behavior aligned.
    • A wait whose poll cannot read polls again and gives up on the third failure in a row. All five waits (document, outline, extract, classify, split) now do this and raise PageIndexAPIError with the HTTP status; a 401, 403 or 404 is raised at once. The outline wait raised the read's own error, so a dropped connection came out as requests.ConnectionError. A wait's first read, and the read wait_document() and wait_outline() return, go once, as before: the cloud session already sends a GET again after a dropped connection or a 5xx, twice.
    • What is not found carries status_code == 404 when the SDK makes the answer too: a local document read or deleted, get_collection(), get_collection_id(), get_document_id(), get_folder_path() and get_folder_id(). A local wait_document() on a missing document waited 5 seconds and then said the processing continued in the cloud; it raises at once.
    • classify() refuses types written as {"name": ..., "description": ...}, which it read as two types named "name" and "description". split() already did.
    • A file stored under another name (name_1.pdf): extract() warned at a line inside the SDK and classify() and split() did not warn. All three warn at the call that sent the file. For it, classify() and split() read the document once more after the job starts (GET /doc/{id}/metadata/); a failed read gives no warning, and the job goes on.
    • submit_document(wait=True) and upload() return 'status': "completed" once they have waited; they returned the upload's "queued". build_outline(wait=True) already set its status.
    • A Page client built without a key names itself; each said PageIndexCloudClient requires a PageIndex API key. In local mode, folder_context() and collection_context() name themselves too; each said folder_id is cloud-only or collection_id is cloud-only, which chat(folder_id=) and chat(collection_id=) keep.
    • A 409 from the cloud API is raised at once. The cloud session sent a GET, PUT or DELETE again on a 409, twice over 1 to 3 seconds, by the rule the model calls follow. The cloud API's 409 is a state the caller acts on (a document still processing, a schema declared already), so sending it again only delayed it or hid it: on Dev, delete_folder() on a folder whose 40-page upload was still processing got a 409, the second try found the document finished and answered 200, and the counts returned were that try's (1 document and 1 folder, where 2 and 2 were deleted). delete_folder() and delete_collection() now raise the 409 their docstrings name, and delete_document() says the same of a document still processing. 408, 429 and 5xx are sent again as before; the model calls keep their rule.
    • delete_folder() and delete_collection() add up their counts when a server error cut a delete short. The server deletes the documents one by one; a 5xx part-way leaves part of them deleted and asks for the DELETE again. The session sent it again but returned only the last try's counts: 10 documents, a 500 after 6, then 4, and the answer said 4. Both calls now send it again themselves, up to twice as before, and return the counts added up over the tries (10). When every try fails, the error message says how many were deleted. cloud_session(server_errors=False) leaves a 5xx to its caller; urllib3 sent a 503 with Retry-After again even when not listed, so a 5xx now goes again only when listed, and the default session is unchanged.
  • Docstrings. Classify and Split give their price per 1,000 pages ($1 and $5). create_folder(), list_folders() and create_metadata_schema() say what they return, as their collection counterparts do. delete_collection() says that the other documents are deleted while one still processing stays, as delete_folder() and the API reference say. extract(), classify() and split() say that a path whose file is stored and still processing is waited for with wait=False too, and that a stored file that failed is uploaded again.

Compatibility

Callers that keep working unchanged: every earlier parameter name, build_outline_index(), .pageindex. What a caller could notice:

  • status_code is 404 where it was None on the SDK-made "not found" errors above; the messages are unchanged.
  • The third failed read of an outline wait raises PageIndexAPIError in place of the read's own error.
  • classify() raises on a dict keyed by name or description.
  • extract() and classify() raise on a tuple of pages of other than two items, which they read as its first two.
  • An upload that waited returns 'status': "completed" in place of "queued".
  • A call the cloud answers with 409 raises at once: delete_document(), delete_folder() and delete_collection() while a document is still processing, create_metadata_schema() on a schema declared already. Each waited 1 to 3 seconds first, and a delete went through when the document finished within that time.
  • After a server error part-way, delete_folder() and delete_collection() return the counts of every try, not of the last.

Release

No server change is needed: the HTTP API takes all of this today. The docs site and the JS SDK still show the earlier names; both are follow-ups, and the earlier names keep working until then.

Test plan

  • New and changed tests in tests/test_client.py: each earlier name warning at the caller's line and raising beside its new name; pages in each form and the arguments it refuses; a tuple of pages of other than two items raising at all four calls; wait_outline(), and with the outline_structure asked raising when the document kept its outline; delete_folder(), get_collection_id(); an upload's outline time-out naming the whole timeout; a job keeping its file in the folder named; the five waits on failed reads; the 404s; the stored-name warning at the call that sent the file; a client without a key, and a local folder_context() or collection_context(), naming itself; an upload's status after a wait; a 409 answered to a GET, PUT or DELETE sent once; a folder or collection delete cut short by a 500 or a 502 adding up its counts, raising with them after three 500s, and sent once on a 409; a session without server errors sending a 500 or a 503 once.
  • The suite locally at d467285, with no API key set, in a venv installed as CI installs it (litellm 1.112.1, openai-agents 0.26.2, anthropic 2.16.0, claude-agent-sdk 0.2.189): 1327 passed, 7 skipped.
  • Live on Dev: upload(folder_id=); folder_id= on extract(), classify() and split() (each file lands in the folder, each job completes); delete_folder() on a folder with documents and on one with a subfolder, the documents then answering 404; create_folder() and list_folders() returning the keys their docstrings name; delete_folder() and delete_document() while a 200-page upload was still processing, each raising 409 after one DELETE on the wire (0.6 s and 0.3 s), the folder and the document staying, and both deleted once it had finished. Run again at a7fc808: the same 409s after one DELETE each, and delete_folder() (1 document, 1 folder) and delete_collection() (2 documents) returning the server's counts once the documents had finished. A server error part-way cannot be caused on Dev, so the added-up counts are tested only with mocked answers.

…PageIndexClient does, by doc_id, collection_id and folder_id; the earlier names still work and warn

PageSearchClient.search() and search_documents() take doc_id (one ID, or a list), collection_id and folder_id, and upload() takes collection_id, as chat() and submit_document() do. document, documents, document_ids, collection and folder are their earlier names: each still works and emits a DeprecationWarning that names the new one, and passing both raises. extract(), classify() and split() keep collection=, which takes a collection's name as well as its ID.

search() takes pages ("3-9", (3, 9), 3, or (30, None) for an open end), as extract(), classify() and get_page_content() do. start_page and end_page are its earlier names and warn. get_page_content() also takes 5 and (5, 7).

Aligned with it:

- upload() takes folder_id, as submit_document() does.
- get_collection_id(name) looks a collection up by its name, beside get_document_id() and get_folder_id().
- submit_document() takes timeout, the seconds wait=True waits, the outline included.
- A wait for an extract job, a classify job or an outline reads again after a failed read and raises on the third, as a wait for a split job or a document does. A 401, 403 or 404 raises at once.
- classify() refuses types written as {"name": ..., "description": ...}, which it read as two types named "name" and "description". split() already did.
- Docstrings: Classify and Split give their price per 1,000 pages, and the Page clients' and build_outline()'s no longer leave out Page Classify and Page Split.
…r a document, and delete_folder() deletes a folder as delete_collection() deletes a collection

build_outline(wait=False) was the one start-now call with no wait of its
own: wait_document(), wait_extract(), wait_classify() and wait_split() had
theirs. wait_outline(doc_id, timeout) returns what get_outline() returns,
and raises for a document that has no outline and none being built.

A folder could be created and listed, a collection also deleted.
delete_folder(folder_id) calls the server's DELETE /folder/{id}: the
documents and subfolders in it go too, and one still queued or processing
stays with its folder while the rest is deleted, with HTTP 409.

A file stored under another name: extract() warned at a line inside the
SDK, and classify() and split() did not warn, since a job's answer carries
no name. Extract's warning now points at the call that sent the file, and
Classify and Split read the document's name once the job has started and
give the same warning. A failed read gives no warning: the job is running
and its id must reach the caller.

extract(), classify() and split() say that a path whose file is stored
already and still processing is waited for with wait=False too. The
behavior is unchanged.

search(pages="3-") searched page 3 alone. It raises, as
get_page_content("3-") does and as the server does for Extract and
Classify.
…folder_id=, and what is not found answers 404 wherever the answer is made

submit_document() and PageSearchClient.upload() place a file in a folder
by folder_id; the three job clients could only name a collection, though
the server takes a folder for their files too. folder_id= stands in place
of collection: naming another collection with it raises.

A document, a collection or a folder that is not found carried HTTP 404
only when the server said so. The answers the SDK makes itself now carry
it too: a local document read or deleted, get_collection(),
get_collection_id(), get_document_id(), get_folder_path() and
get_folder_id(). The messages are unchanged. This is what ends a local
wait_document() on a missing document at once: it waited 5 seconds and
then said the processing continued in the cloud.

A wait that cannot read three times in a row: the job waits raised
PageIndexAPIError with the HTTP status, the document wait raised it
without the status, and the outline wait raised the read's own error, so
a dropped connection came out as requests.ConnectionError. All five now
raise PageIndexAPIError with the status, and name what was waited for. A
401, 403 or 404 is still raised as it was read.

PageSearchClient(), PageExtractClient(), PageClassifyClient() and
PageSplitClient() without a key said that PageIndexCloudClient requires
one. Each names itself.

submit_document() and PageSearchClient.upload() annotate file_path as a
str or a PathLike, as the job clients do; a Path worked already.

Docstrings: create_folder(), list_folders() and create_metadata_schema()
say what they return, as their collection counterparts do;
build_outline() and upload() give timeout its own entry; classify() and
split() say a stored file that failed is uploaded again under a suffixed
name, as extract() says.
…utline() says of the outline it waited for

submit_document(wait=True) and PageSearchClient.upload() returned the
upload's own answer after the wait: 'status' said "queued" for a document
that had completed. build_outline(wait=True) sets its 'index_status' to
"completed" once it has waited. An upload's 'status' now says "completed"
after a wait; an answer that carries no 'status', as a local one and an
older server's, gains none. The Returns lines name the key.

Seen in a live run on Dev.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T12:45:51.802227Z d467285 New commits
🔒 Security Review ✅ Completed 2026-12-03T12:47:14.640405Z d467285 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…ng sent again, so delete_folder() and delete_collection() raise the 409 their docstrings name

The cloud session sent a GET, PUT or DELETE again on a 409, up to twice
over 1 to 3 seconds, by the rule the model calls follow. The cloud API's
409 is a state the caller acts on: a document still queued or
processing, a metadata schema declared already. Sent again, it came 1 to
3 seconds late, or not at all: deleting a folder whose 40-page upload
was still processing answered 409, the second try found the document
finished and answered 200, and the counts returned were that try's (1
document and 1 folder, where 2 and 2 were deleted).

408, 429 and 5xx are sent again as before, and the model calls keep
their rule. delete_document() says it raises 409 on a document still
processing, as delete_folder() and delete_collection() do.
…rt is sent again with its counts added up over the tries

The server deletes a folder's or a collection's documents one by one. A
server error part-way leaves part of them deleted and asks for the DELETE
again. The SDK sent it again, but returned only the last try's counts:
10 documents, a 500 after 6, then 4 on the retry, and the answer said 4.

delete_folder() and delete_collection() now send the DELETE again
themselves, up to twice, and add up deleted_documents (and
deleted_folders) over the tries. When every try fails, the error says how
many were deleted. A 409 still raises at once.

cloud_session(server_errors=False) leaves a 5xx to its caller. urllib3
resends a 503 with Retry-After even when it is not listed; a 5xx now goes
again only when listed, so the default session is unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7fc808937

ℹ️ 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".

Comment thread pageindex/client.py
Comment on lines +1275 to +1277
self._wait_for_outline(
doc_id, None, timeout, self.get_outline(doc_id)["index_status"])
return self.get_outline(doc_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include all outline reads in the polling retry policy

If the first outline GET encounters a dropped connection or transient API error, wait_outline() raises immediately without entering the retry loop. The final GET is likewise unprotected, so a single transient failure can fail the wait even after polling has confirmed completion. For example, an initial requests.ConnectionError followed by a successful response produces only one read and leaks the connection error. Handle the initial read through the polling retry policy and return the successful terminal response instead of issuing another unprotected read.

Useful? React with 👍 / 👎.

… delete_collection() says the rest is deleted while a document still processing stays

- wait_outline() in local mode raised "get_outline is cloud-only"; every other
  cloud-only call names itself.
- delete_collection()'s docstring said the collection and the busy document
  stay, but not that the other documents are deleted, as delete_folder() and
  the API reference say (seen on Dev).
- retry.py's module docstring said one rule for every model and cloud call;
  a cloud call is no longer sent again on a 409.
- submit_document()'s Returns rewrapped.
… its cloud-only error, as every other cloud-only call does

Both handed the check to the targeting blocks chat() uses, whose error names
chat()'s parameter: "folder_id is cloud-only". The blocks now take the name to
give, chat() keeps its parameter's, and the two methods give their own. A local
folder_context("root") still returns "", the library itself.
…ses when the outline asked of it could not be built, and an upload's outline time-out names its timeout

- A tuple of pages is (first, last). get_page_content(), search(), extract()
  and classify() read (5, 7, 9) as pages 5 to 7, without a word; (5,) raised
  an IndexError, and search() read () as the whole document. Any tuple of
  other than two items now raises PageIndexAPIError.
- wait_outline(doc_id, timeout, outline_structure): given the structure asked
  of build_outline(), it raises when that outline could not be built and the
  document kept the one it had, as build_outline(wait=True) does; it
  returned the outline kept.
- submit_document(wait=True, outline_structure=...) waits for the pages and
  the outline within one timeout; its time-out said the seconds left, such
  as "Timed out after -40s", and says the timeout given.
@rejojer
rejojer merged commit e200e28 into main Dec 3, 2026
10 checks passed
rejojer added a commit that referenced this pull request Dec 3, 2026
…737)

pageindex 0.8.4 names a document, a collection and a folder as doc_id, collection_id and folder_id in every client (#735), and a sent upload waits at most 600 s for its answer (#733).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant