Skip to content

feat: add sheet upload jobs to Python SDK#11

Open
andrewkrippner wants to merge 1 commit into
masterfrom
ak/sheet-upload-sdk
Open

feat: add sheet upload jobs to Python SDK#11
andrewkrippner wants to merge 1 commit into
masterfrom
ak/sheet-upload-sdk

Conversation

@andrewkrippner

@andrewkrippner andrewkrippner commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • add synchronous and asynchronous multipart create_sheet_file methods with 30 MiB preflight and idempotency
  • add typed sheet-upload job and page result models
  • document the upload, poll, placement, and project-wide auto-takeoff flow

Validation

  • uv run ruff check .
  • uv run mypy src
  • uv run pytest
  • uv build

Release this as 0.6.1 after the API deployment is live.

Summary by CodeRabbit

  • New Features

    • Added synchronous and asynchronous support for uploading sheet PDFs.
    • Enforced a 30 MiB upload limit with validation for supported file inputs.
    • Added structured results for sheet-upload jobs, including page-level status and placement details.
    • Added documentation covering upload workflows, job polling, and follow-up processing.
  • Improvements

    • Updated the package version to 0.6.1.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Sheet PDF upload support

Layer / File(s) Summary
Sheet-upload result contract and exports
src/hvakr/schemas/api.py, src/hvakr/schemas/__init__.py, src/hvakr/__init__.py
Adds structured sheet-upload page and job-result models, supports the sheet-upload job type, and exposes the schemas publicly.
Validated synchronous and asynchronous uploads
src/hvakr/client.py, tests/test_client.py
Adds multipart PDF uploads for both clients, enforces the 30 MiB limit, supports idempotency keys, and tests request parsing and validation.
SDK version and upload workflow documentation
pyproject.toml, src/hvakr/__init__.py, tests/test_client.py, README.md
Updates the package and client version to 0.6.1 and documents polling upload jobs before auto-takeoff.ต้อง

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant HVAKRClient
  participant SheetFilesAPI
  participant JobAPI
  Caller->>HVAKRClient: create_sheet_file(project_id, file, file_name)
  HVAKRClient->>HVAKRClient: Validate and normalize PDF content
  HVAKRClient->>SheetFilesAPI: POST multipart sheet file
  SheetFilesAPI-->>HVAKRClient: Return sheet-upload job
  HVAKRClient-->>Caller: Return APIJob
  Caller->>JobAPI: get_job(job_id)
  JobAPI-->>Caller: Return upload result and page readiness
Loading

Suggested reviewers: daytonmux

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding sheet upload job support to the Python SDK.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ak/sheet-upload-sdk

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/hvakr/client.py`:
- Around line 126-130: Update the file-content loading logic near the sheet
upload validation to bound file-like reads: preserve direct bytes handling, but
call read with MAX_API_SHEET_UPLOAD_BYTES + 1 for BinaryIO inputs so the
existing length check can detect oversize content without loading it fully into
memory. Keep the TypeError and ValueError behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1d85022d-57b9-4435-a7a7-2961db65f75e

📥 Commits

Reviewing files that changed from the base of the PR and between 8705de0 and 4d515cc.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • README.md
  • pyproject.toml
  • src/hvakr/__init__.py
  • src/hvakr/client.py
  • src/hvakr/schemas/__init__.py
  • src/hvakr/schemas/api.py
  • tests/test_client.py

Comment thread src/hvakr/client.py
Comment on lines +126 to +130
content = file if isinstance(file, bytes) else file.read()
if not isinstance(content, bytes):
raise TypeError("Sheet upload file must provide bytes.")
if len(content) > MAX_API_SHEET_UPLOAD_BYTES:
raise ValueError("Sheet PDF exceeds the 30 MiB API upload limit.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Bound file-like reads before enforcing the upload limit.

file.read() loads an arbitrarily large BinaryIO into memory before line 129 rejects it. Read at most MAX_API_SHEET_UPLOAD_BYTES + 1 bytes so oversized streams cannot exhaust process memory.

Proposed fix
-        content = file if isinstance(file, bytes) else file.read()
+        content = (
+            file
+            if isinstance(file, bytes)
+            else file.read(MAX_API_SHEET_UPLOAD_BYTES + 1)
+        )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
content = file if isinstance(file, bytes) else file.read()
if not isinstance(content, bytes):
raise TypeError("Sheet upload file must provide bytes.")
if len(content) > MAX_API_SHEET_UPLOAD_BYTES:
raise ValueError("Sheet PDF exceeds the 30 MiB API upload limit.")
content = (
file
if isinstance(file, bytes)
else file.read(MAX_API_SHEET_UPLOAD_BYTES + 1)
)
if not isinstance(content, bytes):
raise TypeError("Sheet upload file must provide bytes.")
if len(content) > MAX_API_SHEET_UPLOAD_BYTES:
raise ValueError("Sheet PDF exceeds the 30 MiB API upload limit.")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/hvakr/client.py` around lines 126 - 130, Update the file-content loading
logic near the sheet upload validation to bound file-like reads: preserve direct
bytes handling, but call read with MAX_API_SHEET_UPLOAD_BYTES + 1 for BinaryIO
inputs so the existing length check can detect oversize content without loading
it fully into memory. Keep the TypeError and ValueError behavior unchanged.

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