feat(py-client): Implement "many" api for batch requests - #546
feat(py-client): Implement "many" api for batch requests#546matt-codecov wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #546 +/- ##
==========================================
+ Coverage 89.22% 89.36% +0.13%
==========================================
Files 109 111 +2
Lines 19089 19688 +599
==========================================
+ Hits 17033 17595 +562
- Misses 2056 2093 +37
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Please see also the now closed #419. It's gone out of sync with main, so it's better to carry on here. The prior PR focused on streaming as much as possible and had gone through a round of feedback with the Python SDK maintainers for the public API. Also, there's configuration for concurrency that uses an optional thread pool executor. I hope there are some parts we could leverage from that. |
|
bugbot run |
9ac7967 to
c481164
Compare
|
|
||
| A port of the ``ZSTD_COMPRESSBOUND`` macro definition in ``zstd.h``. | ||
| """ | ||
| margin = ((128 << 10) - size) >> 11 if size < (128 << 10) else 0 |
There was a problem hiding this comment.
https://github.com/facebook/zstd/blob/82d322c4973d9e2968d94047a40892bc6d9a9bdf/lib/zstd.h#L249 is the source. it is a bit of a mess to parse but here it is with some extra indentation for clarity:
#define ZSTD_COMPRESSBOUND(srcSize) \
( \
((size_t)(srcSize) >= ZSTD_MAX_INPUT_SIZE) \
? 0 \
: (srcSize) + ((srcSize)>>8) + ( /* size + (size >> 8) + */ \
((srcSize) < (128<<10)) /* if size < (128 << 10) */ \
? (((128<<10) - (srcSize)) >> 11) /* then ((128 << 10) - size) >> 11 */ \
: 0 /* else 0 */ \
) \
)once upon a time writing convoluted preprocessor macros was my job
| if concurrency == 1 and executor is None: | ||
| for item in work: | ||
| yield from _run_work(session, item) | ||
| else: | ||
| yield from _execute_concurrent(session, work, concurrency, executor) |
There was a problem hiding this comment.
Do we really need the special case for concurrency=1 or could we just send the ops into _execute_concurrent with a special/single-threaded executor and that's it?
There was a problem hiding this comment.
the special case here skips any executor/threading and just runs it on the caller thread. i don't think there is a "same thread executor" ready-made we could use here. but it probably wouldn't be hard to write
There was a problem hiding this comment.
i left this as-is
c481164 to
ff03dcd
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ff03dcd. Configure here.
ff03dcd to
2000ed9
Compare
2000ed9 to
9b05797
Compare

#277 / #478 implemented the
manyAPI in the Rust client which uses Objectstore's batch endpoint. This PR ports it over to Python.Incorporates direction from #419.
Closes FS-330
Some notes:
ThreadPoolExecutor'smax_workersto allow for results to be streamed from individual batch requests without having to buffer the whole response. Otherwise a batch of 1000 5MB GET results would eat 5GB RAM and delay yielding anything to the caller.Get/Putoperation type classes copy the arg list of theget()andput()methods onsession, the decompression code inget()is copied... but I didn't want to touch existing code much to reorganize in this PR.1because that's the default urllib3 connection pool size. You can still send concurrent requests with a connection pool size of 1, it just opens/closes a connection per request and logs a warning about it instead of actually pooling.