Skip to content

fix(resources): preserve multipart file uploads in generated client (HYBIM-882)#104

Merged
etserend merged 6 commits into
mainfrom
feat/HYBIM-882-port-02ce8bb
Jul 22, 2026
Merged

fix(resources): preserve multipart file uploads in generated client (HYBIM-882)#104
etserend merged 6 commits into
mainfrom
feat/HYBIM-882-port-02ce8bb

Conversation

@etserend

Copy link
Copy Markdown
Contributor

Summary

Port of upstream commit 02ce8bbfix: Preserve multipart file uploads in generated client (#624).

  • openapi.yaml: Replace contentMediaType: application/octet-streamformat: binary for 7 Body_* multipart file fields, enabling openapi-python-client to generate File-typed attributes instead of plain str
  • scripts/import-openapi-yaml.sh: Add yq patches for the 7 binary fields so the fix survives future openapi.yaml regenerations; tighten error handling ($? -ne 0)
  • 6 generated Body_* models: file: strfile: File; add BytesIO/File/FileTypes imports; call .to_tuple() in to_dict/to_multipart; construct File(payload=BytesIO(...)) in from_dict
  • tests/test_datasets.py: 2 new tests verifying File payloads round-trip through to_multipart() correctly

Test plan

  • poetry run pytest tests/test_datasets.py -v — 61 passed
  • New tests: test_create_dataset_body_serializes_file_as_multipart_upload, test_code_scorer_bodies_serialize_files_as_multipart_uploads
  • Trigger regenerate-api-client workflow after merge to produce clean generated output

etserend added 2 commits July 20, 2026 17:52
…02ce8bb)

Port of rungalileo/galileo-python@02ce8bb2 — fix: Preserve multipart file
uploads in generated client (#624).

- openapi.yaml: replace contentMediaType: application/octet-stream with
  format: binary for 7 Body_* multipart file fields so openapi-python-client
  generates File-typed attributes instead of plain str
- scripts/import-openapi-yaml.sh: add yq patches for the 7 binary fields so
  the fix survives future openapi.yaml regenerations; tighten error handling
- 6 generated Body_* models: update file fields from str → File, add BytesIO
  import, add File/FileTypes imports, call .to_tuple() in to_dict/to_multipart,
  construct File(payload=BytesIO(...)) in from_dict
- tests/test_datasets.py: add two tests verifying File payloads round-trip
  through to_multipart() correctly
…ation block

Two gaps vs upstream 02ce8bb:
- ListAnnotationQueueParams.properties.sort.default patch was missing (added in
  e34a5b1 / PR#103 but not carried forward to this branch)
- Post-patch verification block (yq -e with 14 assertions) was absent
- Error message corrected: "Failed to fetch..." -> "Failed to patch..."
@etserend
etserend marked this pull request as ready for review July 21, 2026 16:49
etserend and others added 2 commits July 22, 2026 11:35
…locks

On Windows, time.time_ns() resolution can be coarser than the execution
time of a trivial function, so duration_ns can legitimately be 0.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@fercor-cisco fercor-cisco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.

Verdict: approve — Faithful, correct port of upstream generated multipart-upload fix; call sites already pass File objects, so this repairs genuinely broken uploads. Only minor testing/docs gaps.

- Fix docstring: file (str) -> file (File) in BodyCreateCodeScorerVersion
- Add test_manual_llm_validate_multipart_body_serializes_list_of_files
  covering the loop-based query_files/response_files list handling in
  BodyManualLlmValidateMultipartScorersLlmValidateMultipartPost

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@fercor-cisco

Copy link
Copy Markdown
Collaborator

Port faithfulness review vs upstream 02ce8bb (rungalileo/galileo-python#624)

Verdict: Faithful port ✅

Every substantive change from upstream #624 is present. Remaining deltas are cosmetic artifacts of a different openapi-python-client generator version, not behavioral differences.

File-by-file comparison

Area Upstream #624 This branch Match
openapi.yaml — 7 fields contentMediaTypeformat: binary across 6 schemas ✓ (identical)
scripts/import-openapi-yaml.sh — yq patches + verification block + $? -ne 0
6 Body_* models — file: strFile, .to_tuple(), File(payload=BytesIO(...)) ✓ (logic identical)
tests/test_datasets.py — 2 new tests ✓ (path adapted galileosplunk_ao)

Both new tests pass locally (2 passed).

Cosmetic-only differences (not defects)

Behavior-preserving, stemming from a different generated baseline in this repo:

  1. Union ordering / docstrings — local uses None | str | Unset and Attributes:, upstream has None | Unset | str and NumPy-style Attributes\n----------. Pure formatting.
  2. body_manual_llm_validate_multipart... — upstream imports/uses FileTypes for a to_dict local var annotation; local uses list[Any] and omits the FileTypes import. Annotation only — no runtime difference, no NameError.
  3. body_validate_code_scorer_dataset... / ..._log_record... — local diffs contain an extra incidental refactor of the unrelated _parse_required_scorers / _parse_scoreable_node_types helpers (x = cast(...); return xreturn cast(...)). Regeneration noise, not in #624, but behavior-identical.

Items outside #624 scope (expected, harmless)

  • scripts/import-openapi-yaml.sh also adds ListAnnotationQueueParams.properties.sort.default = "None" (from commit 5f89e46) — a separately-needed local patch, correctly bundled into the monolithic yq command.
  • tests/test_decorator_distributed.py relaxes a duration assertion (> 0>= 0, commit b2f1555) — an unrelated CI-stability fix that rides along on the branch.

Conclusion: Complete and correct port. No correctness gaps. The only deltas versus upstream are generator formatting artifacts and two clearly-separate commits that legitimately ride along on the branch.

🤖 Generated with Claude Code

Reviewer clarified that adding new tests is out of scope for this PR —
it is a mechanical lift of the upstream commit only.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@etserend
etserend merged commit 174c43d into main Jul 22, 2026
13 checks passed
@etserend
etserend deleted the feat/HYBIM-882-port-02ce8bb branch July 22, 2026 21:25
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants