Skip to content

refactor(api): isolate vector-store polling helpers - #3713

Merged
apcha-oai merged 1 commit into
mainfrom
apcha/castiron-python-vector-polling
Aug 21, 2026
Merged

refactor(api): isolate vector-store polling helpers#3713
apcha-oai merged 1 commit into
mainfrom
apcha/castiron-python-vector-polling

Conversation

@apcha-oai

Copy link
Copy Markdown
Contributor
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Move the existing sync/async vector-store file and file-batch polling bodies into SDK-owned lib/_vector_stores.py, sharing their identical openai-poll-after-ms lookup, integer conversion, and one-second fallback. The public poll methods remain thin delegates with the same signatures, defaults, docstrings, and return types.

Request headers, response parsing, interval handling, terminal conditions, return identity, and error/cancellation propagation are preserved. Upload orchestration, create-and-poll methods, other requests, and response wrappers are untouched. This adds no generic polling framework, timeout behavior, schema/compiler changes, or generation-metadata changes.

Review pointers:

  • Original public polling bodies: Files and FileBatches, with the corresponding async methods in the same files.
  • SDK-owned helper: the four bodies only rename their receiver and replace the repeated interval block with the shared lookup. Source/AST comparison against the base verifies those edits and the unchanged remainder of both resources.
  • Focused tests: 106 lines / 22 cases covering the four public entry points, terminal results, default/server/explicit intervals and headers, retrieval errors, and async cancellation. Existing API and helper-signature tests are unchanged.

Additional context & links

Validation:

  • Commands: .venv/bin/python -m pytest tests/lib/test_vector_store_polling.py -q -n 0 and the same command with .venv-pydantic-v1/bin/python passed all 22 cases against the original implementation and again after extraction.
  • Commands: TEST_API_BASE_URL=http://127.0.0.1:4142 .venv/bin/python -m pytest tests/api_resources/vector_stores tests/lib/test_vector_store_files.py tests/lib/test_vector_store_file_batches.py tests/lib/test_vector_store_polling.py -q -n 0 and the same command with .venv-pydantic-v1/bin/python passed 248 tests in each Pydantic mode.
  • Commands: ./scripts/format and ./scripts/lint passed, including Ruff, Pyright, mypy, and import checks. Unrelated reporter-formatting edits were excluded.
  • Command: ./scripts/build passed. Both distributions include the helper, and a fresh import from the built wheel loads the helper and all four resource classes.

The verified custom-code report keeps 36 mixed files, with only the two vector-store resource customizations changed:

  • files.py: +222/-4 to +179/-1.
  • file_batches.py: +275/-4 to +242/-3.

All other 34 customizations, generation metadata, API reference, dependencies, and workflows are unchanged. Reproduction command:

python3 scripts/castiron/custom_code_report.py report \
  --base bedb9a7b8839e193107e88b92f7cc166f08ac83d \
  --head 25e95b31c1402b3a927cedb9fff5d3d7a785bbeb \
  --fetch --require-head-hash --public \
  --out /tmp/castiron-vector-polling

@apcha-oai
apcha-oai requested a review from a team as a code owner August 21, 2026 14:18
@apcha-oai apcha-oai added the custom-code-burndown Behavior-preserving cleanup of custom code in generated SDK files label Aug 21, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-21T14:19:18.237175Z 25e95b3 PR opened
🔒 Security Review Completed 2026-08-21T14:19:41.771123Z 25e95b3 PR opened
ℹ️ 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.

@github-actions

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

36 mixed files remain; 2 existing customizations changed.

Compared bedb9a7b883925e95b31c140. Generated baselines verified.

File Result Current custom patch
src/openai/resources/vector_stores/file_batches.py Existing customization changed +242 / −3
src/openai/resources/vector_stores/files.py Existing customization changed +179 / −1
34 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/openai/init.py
  • src/openai/_client.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/responses/responses.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/realtime/realtime.py
  • src/openai/resources/responses/responses.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/init.py
  • src/openai/types/chat/init.py
  • src/openai/types/chat/chat_completion_message_tool_call.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/responses/init.py
  • src/openai/types/responses/response.py
  • src/openai/types/responses/response_function_web_search.py
  • src/openai/types/responses/response_function_web_search_param.py
  • src/openai/types/responses/tool.py
  • src/openai/types/responses/tool_param.py
  • src/openai/types/webhooks/init.py
  • src/openai/types/websocket_connection_options.py
  • tests/api_resources/test_videos.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 32491427690 --repo openai/openai-python \
  --name castiron-custom-code-32491427690-1 --dir /tmp/castiron-custom-code-32491427690-1
git apply --stat /tmp/castiron-custom-code-32491427690-1/custom-code.patch
cat /tmp/castiron-custom-code-32491427690-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin bedb9a7b8839e193107e88b92f7cc166f08ac83d 25e95b31c1402b3a927cedb9fff5d3d7a785bbeb
python3 scripts/castiron/custom_code_report.py report \
  --base bedb9a7b8839e193107e88b92f7cc166f08ac83d \
  --head 25e95b31c1402b3a927cedb9fff5d3d7a785bbeb --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-25e95b31c140
cat /tmp/castiron-custom-code-25e95b31c140/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@openai-sdks

openai-sdks Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.587s for Python SDK PR #3713.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 245ms
tests/chat-completions-create.test.ts ✅ Passed 210ms
tests/chat-completions-stream.test.ts ✅ Passed 135ms
tests/files-content-binary.test.ts ✅ Passed 207ms
tests/files-create-multipart.test.ts ✅ Passed 271ms
tests/files-list-pagination.test.ts ✅ Passed 150ms
tests/initialize-config.test.ts ✅ Passed 171ms
tests/instance-isolation.test.ts ✅ Passed 170ms
tests/models-list.test.ts ✅ Passed 117ms
tests/responses-background-lifecycle.test.ts ✅ Passed 353ms
tests/responses-body-method-errors.test.ts ✅ Passed 442ms
tests/responses-cancel-timeout.test.ts ✅ Passed 221ms
tests/responses-cancel.test.ts ✅ Passed 303ms
tests/responses-compact-retries.test.ts ✅ Passed 304ms
tests/responses-compact.test.ts ✅ Passed 246ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 201ms
tests/responses-create-advanced.test.ts ✅ Passed 342ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.213s
tests/responses-create-errors.test.ts ✅ Passed 224ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 190ms
tests/responses-create-retries.test.ts ✅ Passed 346ms
tests/responses-create-stream-failures.test.ts ✅ Passed 128ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 208ms
tests/responses-create-stream-wire.test.ts ✅ Passed 3.676s
tests/responses-create-stream.test.ts ✅ Passed 321ms
tests/responses-create-terminal-states.test.ts ✅ Passed 285ms
tests/responses-create-timeout.test.ts ✅ Passed 248ms
tests/responses-create.test.ts ✅ Passed 235ms
tests/responses-delete.test.ts ✅ Passed 232ms
tests/responses-input-items-errors.test.ts ✅ Passed 341ms
tests/responses-input-items-list.test.ts ✅ Passed 291ms
tests/responses-input-items-options.test.ts ✅ Passed 343ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 282ms
tests/responses-input-tokens-count.test.ts ✅ Passed 188ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.799s
tests/responses-not-found-errors.test.ts ✅ Passed 320ms
tests/responses-parse.test.ts ✅ Passed 471ms
tests/responses-retrieve-retries.test.ts ✅ Passed 255ms
tests/responses-retrieve.test.ts ✅ Passed 306ms
tests/responses-stored-method-errors.test.ts ✅ Passed 640ms
tests/retry-behavior.test.ts ✅ Passed 3.034s
tests/sdk-error-shape.test.ts ✅ Passed 408ms

View OkTest run #32491401438

SDK merge (a138a0c922b9) · head (25e95b31c140) · base (bedb9a7b8839) · OkTest (2b1bdfd25e98)

@jbeckwith-oai jbeckwith-oai 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.

Reviewed all four extracted sync/async vector-store polling implementations and the shared interval lookup. Public signatures, terminal states, explicit/server-header interval precedence, malformed-header behavior, sleep hooks, request metadata, exception identity, and cancellation remain unchanged. Focused tests cover every resource variant, and relocated existing type annotations introduce no new suppressions. Looks good.

@apcha-oai
apcha-oai added this pull request to the merge queue Aug 21, 2026
Merged via the queue into main with commit a002ef3 Aug 21, 2026
22 checks passed
@apcha-oai
apcha-oai deleted the apcha/castiron-python-vector-polling branch August 21, 2026 15:29
@openai-sdks openai-sdks Bot mentioned this pull request Aug 21, 2026
leiandy pushed a commit to leiandy/openai-python that referenced this pull request Aug 26, 2026
Automated Release PR
---


##
[3.4.0](openai/openai-python@v3.3.1...v3.4.0)
(2026-08-25)


### Features

* **api:** Add obfuscation field to ChatCompletionChunk
([openai#3690](openai#3690))
([c7d8e1d](openai@c7d8e1d))
* **api:** add project residency configuration and cost quantity units
([openai#3726](openai#3726))
([bc4f8ef](openai@bc4f8ef))


### Bug Fixes

* **api:** encode Realtime call offers and session configuration
([openai#3736](openai#3736))
([555ac48](openai@555ac48))
* apply consistent origin checks to WebSocket redirects
([openai#3693](openai#3693))
([1b324d0](openai@1b324d0))
* **azure:** encode deployment names consistently
([openai#3683](openai#3683))
([689538d](openai@689538d))
* **azure:** keep provider validation errors value-free
([openai#3691](openai#3691))
([72529c0](openai@72529c0))
* **azure:** resolve one authentication mode
([openai#3689](openai#3689))
([e3d0681](openai@e3d0681))
* compute custom-code summaries from trusted workflow code
([openai#3692](openai#3692))
([2b5868d](openai@2b5868d))
* create upload example fixtures in private directories
([openai#3686](openai#3686))
([f36e6f7](openai@f36e6f7))
* decode SSE incrementally without limiting event size
([openai#3687](openai#3687))
([2598d53](openai@2598d53))
* keep Python SDK diagnostics metadata-only
([openai#3685](openai#3685))
([600aa8d](openai@600aa8d))
* Preserve Azure authentication boundaries across transports
([openai#3684](openai#3684))
([06ef57c](openai@06ef57c))
* preserve the configured TLS hostname
([openai#3694](openai#3694))
([aa5fbc4](openai@aa5fbc4))
* preserve WebSocket send queue byte accounting during flush
([openai#3688](openai#3688))
([96f966d](openai@96f966d))


### Chores

* **api:** Clarify image background docs and preview support
([openai#3703](openai#3703))
([bedb9a7](openai@bedb9a7))
* **api:** document supported image generation models
([openai#3695](openai#3695))
([8edd9ae](openai@8edd9ae))
* **api:** move chat validation tests out of generated code
([openai#3698](openai#3698))
([9d3ba20](openai@9d3ba20))
* **api:** move webhook tests out of generated code
([openai#3700](openai#3700))
([04ecb3c](openai@04ecb3c))
* **api:** remove redundant generated formatting
([openai#3696](openai#3696))
([5ac1e03](openai@5ac1e03))
* **api:** remove redundant generated test edits
([openai#3697](openai#3697))
([351ef84](openai@351ef84))
* **api:** Update SDK generation metadata only
([openai#3716](openai#3716))
([e43b422](openai@e43b422))
* set a ceiling for Python SDK customization
([openai#3714](openai#3714))
([04d5d79](openai@04d5d79))


### Documentation

* **api:** restore generated ChatKit API index
([openai#3705](openai#3705))
([4534106](openai@4534106))
* standardize Python SDK vulnerability disclosure policy
([openai#3642](openai#3642))
([1fc0a21](openai@1fc0a21))


### Refactors

* **api:** isolate audio response format selection
([openai#3701](openai#3701))
([ece4324](openai@ece4324))
* **api:** isolate vector-store polling helpers
([openai#3713](openai#3713))
([a002ef3](openai@a002ef3))
* **api:** move file processing polling into SDK-owned helpers
([openai#3712](openai#3712))
([5f20c51](openai@5f20c51))
* **api:** share embedding response decoding
([openai#3699](openai#3699))
([50de9af](openai@50de9af))
* **api:** share webhook signature verification
([openai#3704](openai#3704))
([e14ac34](openai@e14ac34))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

custom-code-burndown Behavior-preserving cleanup of custom code in generated SDK files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants