Skip to content

Add iter_export_rows to read export rows across pages - #146

Open
rajdipk wants to merge 4 commits into
prooflinedev:mainfrom
rajdipk:iter-export-rows
Open

rajdipk wants to merge 4 commits into
prooflinedev:mainfrom
rajdipk:iter-export-rows

Conversation

@rajdipk

@rajdipk rajdipk commented Dec 1, 2026

Copy link
Copy Markdown

Why

A reporting workflow, such as pulling a month of review data into a script or spreadsheet, needs every row in the window, not the pages that carry them. Today that means looping over iter_export_pages and flattening page.rows by hand, as the README example does. iter_export_rows does that on both clients.

with ProoflineClient() as client:
    rows = list(
        client.iter_export_rows(
            organization_id,
            "reviews",
            from_time="2026-10-01T00:00:00Z",
            to_time="2026-10-25T00:00:00Z",
        )
    )

What it does

  • Added to ProoflineClient and AsyncProoflineClient with the same signature as iter_export_pages, plus max_rows.
  • Delegates to iter_export_pages, so cursor validation, filters and the max_pages bound are unchanged, and rows from a page with an invalid cursor are never yielded.
  • max_rows (default 100,000, range 1..1,000,000) follows the iter_reviews max_items pattern: a window with more rows raises urn:proofline:sdk:pagination-limit after yielding max_rows rows, rather than truncating silently. Both bounds are validated before any request.
  • Rows keep their page's decoding: CSV cells stay strings, NDJSON values keep their JSON types.
  • Registered as a helper in scripts/contracts.py and documented in the README export section.

Tests

New tests in tests/test_http.py, each run against the sync and async clients on the loopback server:

  • a three-page window (with an empty middle page) in CSV and NDJSON, read the way a caller would and summed per repository, with filters checked on every request
  • CSV vs NDJSON row types
  • the row bound falling on a page boundary and inside a page, and a window that ends exactly at the bound
  • a repeated cursor: rows from the bad page are not yielded
  • invalid max_rows / max_pages values rejected before any request

python3 scripts/check.py passes (generation, HTTP contracts, wheel and sdist installs), pytest passes 258 tests, ruff is clean, and mypy reports no new errors.

Rows carry no cursor, so the README points to iter_export_pages for resuming an interrupted export. Happy to add a (row, cursor) variant if that would be useful.

🤖 Generated with Claude Code

rajdipk and others added 4 commits December 1, 2026 22:15
Adds iter_export_rows to ProoflineClient and AsyncProoflineClient. It reuses iter_export_pages for cursors, filters and max_pages, and adds a max_rows bound that raises pagination-limit instead of truncating.

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

This branch has not been deployed

No deployments
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