api-clients-automation
api-clients-automation copied to clipboard
fix(python): chunked_batch helper
🧠What and Why
Fix a bug in the chunked_batch helper for the Python API client.
The bug shows when using the replace_all_objects helper—the new index won't have all the records:
- < 1,000 records: only the first record (
0 % batch_size == 0) will be sent. - > 1,000 records: only the first
1 + n x 1,000records will be sent. The records after the last integer multiple ofbatch_sizewon't be sent.
Changes included:
- Send the request when the length of the
requestarray reaches thebatch_size, or when the end of theobjectslist is reached. - Change the type of the
objects"list" inreplace_all_objectsandchunked_batchto be anIterableinstead of an explicit list. This makes it possible to use also with things like list comprehensions.
🧪 Test
No additional test added (didn't quite know how we could test this, as the API is mocked in these tests... we would have to test whether the replaced index has the correct records in it).
✗ The generated branch has been deleted.
If the PR has been merged, you can check the generated code on the main branch.
You can still access the code generated on main via this commit.
🚀 Deployed on https://66470a6b56a651806f08f68f--api-clients-automation.netlify.app
@millotp @morganleroi don't want to bother you, but could you review this PR? It should fix a bug in the Python API client.
I think we have that issue in other clients too, i'll add a ticket to our backlog just to be sure
alternatively, a universal solution, might be to first build a list of list of batch by iterating over all objects, then iterating on the list to do the requests
This should be addressed for all clients by #3154.