Repository navigation
feat: Add live iteration over a run's dataset items - #1085
Conversation
|
See more at https://github.com/apify/apify-client-js/actions/runs/36873957439#summary-110408503694 |
45f6cad to
689db0a
Compare
|
Hi @barjin and @Pijukatel, FYI: I assigned Jindra to the JS PR and Pepa to the Python one. Both PRs implement the same feature. Please also let me know WDYT about naming and whether you think adding just one method to Thanks! |
|
The recent force push(?) has messed up this PR's diff. Can you please merge |
|
Or just wait a bit and retarget to master, v3 will be merged there in a few minutes. |
689db0a to
c9450bd
Compare
Ah, sorry. The |
barjin
left a comment
There was a problem hiding this comment.
Thank you @vdusek ,
just one edge case regarding the /last run endpoint ⬇️
Imo the placement fits, this should be under RunClient, as it's bounded by the Run's lifetime. It's a bit weird we'll have both .dataset() and .iterateDatasetItems(), but I cannot think of a better alternative.
Offset iterators (`list()`, `listItems()`) stopped at the first page's `total`, so rows pushed during the loop were never read. They now page until a page scans no rows or `limit` is reached, like the Python client. Each page advances by the larger of `x-apify-pagination-count` and `items.length`, capped at the requested limit, because the header lags a fresh push. Loosely related to #1085: `RunClient.iterateDatasetItems()` stays the tool for reading a dataset a run is still writing. Closes: #1117 *✍️ Drafted by Claude Code*
Adds
RunClient.iterateDatasetItems(). It yields a run's dataset items while the run is still pushing them and returns once the run has finished and the dataset is drained. It mirrors apify/apify-client-python#1079: same algorithm, options and tests.Each poll reads the dataset's
itemCountand fetches pages whoselimitends at it. The endpoint scans exactlylimitrows, so offsets stay exact even whenclean,skipEmptyorunwindchange how many items a page returns. Between polls,waitForFinish()waits up topollIntervalSecsfor the run to finish.itemCountlags about 5 s, so after the run finishes, the rows past it are read page by page until a page comes back empty. Withclean,skipEmptyorunwind, one unfilteredlimit: 1read confirms the end. Polling goes on throughABORTINGandTIMING-OUT, since such a run can still push items.The options follow
listItems()withoutdesc,signature,flattenandview, pluspollIntervalSecs(default 5).unwindtakes onlystring[], andsignalreaches every request.Docs: a new section in the Retrieve Actor data guide, and a mention on the convenience methods and pagination pages.
Closes #1073
✍️ Drafted by Claude Code