bluesky_queueserver_api.zmq.REManagerAPI.item_add_batch¶
- REManagerAPI.item_add_batch(items, *, pos=None, before_uid=None, after_uid=None, user=None, user_group=None, lock_key=None)¶
Add a batch of items to the queue. The batch is represented as a list of items. Each item may be a plan or an instruction represented as a dictionary of parameters or as an instance of
BItem
,BPlan
orBInst
class. If one of items in the batch does not pass validation, then the whole batch is rejected. SeeREManagerAPI.item_add()
API documentation for more detailed information.- Parameters:
- items: list(dict), list(BItem), list(BPlan) or list(BInst)
A list of items in the batch.
- pos: str, int or None
Position of the first item of the batch in the queue. RE Manager inserts the first item at the specified position. The rest of the batch is inserted after the first item. The position may be a positive or negative integer. Negative positions are counted from the back of the queue. If the parameter has a string value
"front"
or"back"
, then the batch is pushed to the front or the back of the queue. If the value isNone
, then the position is not specified.- before_uid, after_uid: str or None
Insert the batch before or after the item with the given item UID. If
None
(default), then the parameters are not specified.- user, user_group: str or None (optional)
User name and user group name used in the API request. The parameter values override the default user and user group names (accessible using
user
anduser_group
properties). The default user or user group name is used if the respective parameter is not specified orNone
. The parameters are ignored by the HTTP version of the API.- lock_key: str or None (optional)
The lock key enables access to the API when RE Manager queue is locked. If the parameter is not
None
, the key overrides the current lock key set byREManagerAPI.lock_key
. See documentation onREMangerAPI.lock()
for more information. Default:None
.
- Returns:
- response: dict
Dictionary keys:
success
: boolean - success of the request.msg
: str - error message in case the request is rejected by RE Manager or operation failed.qsize
: int or None - new size of the queue orNone
if operation failed.items
: list(dict) or None - the list of dictionaries with parameters of inserted items with assigned UID. If the request is rejected,items
returns the copy of the list of submitted items (with assigned UIDs) orNone
on the failure.
- Raises:
- RequestTimeoutError, RequestFailedError, HTTPRequestError, HTTPClientError, HTTPServerError
All exceptions raised by
send_request
API.
Examples
plan1 = BPlan("count", ["det1"], num=10, delay=1) plan2 = BPlan("count", ["det1"], num=15, delay=1) # Synchronous code (0MQ, HTTP) RM.item_add_batch([plan1, plan2]) # Asynchronous code (0MQ, HTTP) await RM.item_add_batch([plan1, plan2])