Add request batching - #402
Conversation
2bf9131 to
fd79ef9
Compare
6daae66 to
59da410
Compare
fdc3d3f to
b37c185
Compare
|
|
||
| Args: | ||
| slug_or_uuid_or_id (Union[str, int]): application slug (string), uuid (string) or id (number). | ||
| slug_or_uuid_or_id (Union[str, int, List[int]]): application slug (string), uuid (string), |
There was a problem hiding this comment.
slug_or_uuid_or_id_or_ids?
It is very long but at least it is consistent with the other ones....
| """ | ||
|
|
||
| try: | ||
| if isinstance(slug_or_uuid_or_id, str): |
There was a problem hiding this comment.
I think this is a bug isn't it? This path should also be taken if slug_or_uuid_or_id is a single id (number), otherwise this will "work" but it gets compiled into a $in filter with a single element, which at SQL levl is less efficient than indexing directly by its id (it becomes a = ANY() with a binding param so it creates a full list and maybe be harder for the api to cache aswell)
There was a problem hiding this comment.
More over, have you checked that ApplicationNotFound is still raised properly? I suspect yes, but it would be good to check if the tests cover it
| query["body"] = body | ||
| actual_fn(query) | ||
|
|
||
| self.__batch_device_operation(uuid_or_id_or_ids, _operation) |
There was a problem hiding this comment.
I think same comment as above? Ideally, if we get just a single uuid or single id, we prefer to use the resource_id indexing (e.g. directly passing an ID or {"uuid"...}, is the node-sdk also generalising over batch operations even when a single one is passing? 🤔
c5721bb to
5546877
Compare
| { | ||
| "$select": "id", | ||
| "$expand": { | ||
| "is_for__device_type": { | ||
| "$select": "is_of__cpu_architecture", | ||
| "$expand": {"is_of__cpu_architecture": {"$select": "slug"}}, | ||
| } | ||
| }, | ||
| }, |
There was a problem hiding this comment.
I usually prefer to not create a variable if the query is small but if you prefer to keep the options separated I can revert it without issues
d0b6145 to
4f6a1f5
Compare
4f6a1f5 to
37f1df8
Compare
Change-type: minor
37f1df8 to
eb07602
Compare
See: https://balena.fibery.io/Work/Project/Add-batch-operation-handler-in-Python-SDK-2489
Change-type: minor
Description:
Introduce
batch_resource_operation_factoryto resolve, chunk, and validate lists of UUIDs/IDs before executing an operation (200 numeric / 50 string per chunk). Wire it intodevice.move,pin_to_release,pin_to_supervisor_release, andapplication.remove, which now all accept arrays in addition to a single uuid/id.