Motivated by:
Future batch retrieval feature, that could benefit from the existing mechanism, under some changes. + Aligning batch/single request logics (remove duplicate logic)
For the methods: Deprecate, Tag, Update, Update Schema, Register:
The logic of knowing which http method to use, which url to target, what query params to use, what headers to use, what payload to give and what exception to throw on error is prepared in prepared_methods.py. This information will either be used by the requests.request method (for synchronous calls, when performing these operations for one resource) or aiohttp.ClientSession.request (for asynchronous calls, when performing these operations for multiple resources)
When using BatchRequestHandler.batch_request_for_resources, the appropriate prepare_x should be provided. Everything else can either be found in the service instance or the kwargs.
BatchRequestHandler.batch_request provides a way to run a list of tasks. These tasks will be initialised using the task_creator parameter this method requires.
In the case of the methods cited above (deprecate, tag, update…), they all have the same task_creator method, which is defined by BatchRequestHandler.create_tasks_for_resources
In the effort to remove duplication of logic, some differences were spotted:
Batch registration only targeted POST regardless of the presence of an id specified in the payload (https://bluebrainnexus.io//docs/delta/api/resources-api.html#create-using-post). This has been fixed, and now batch registration targets either POST or PUT, like single-resource registration did before (and still does).
Motivated by: Future batch retrieval feature, that could benefit from the existing mechanism, under some changes. + Aligning batch/single request logics (remove duplicate logic)
For the methods: Deprecate, Tag, Update, Update Schema, Register:
The logic of knowing which http method to use, which url to target, what query params to use, what headers to use, what payload to give and what exception to throw on error is prepared in
prepared_methods.py
. This information will either be used by therequests.request
method (for synchronous calls, when performing these operations for one resource) oraiohttp.ClientSession.request
(for asynchronous calls, when performing these operations for multiple resources)When using
BatchRequestHandler.batch_request_for_resources
, the appropriateprepare_x
should be provided. Everything else can either be found in theservice
instance or thekwargs
.BatchRequestHandler.batch_request
provides a way to run a list of tasks. These tasks will be initialised using thetask_creator
parameter this method requires.In the case of the methods cited above (deprecate, tag, update…), they all have the same
task_creator
method, which is defined byBatchRequestHandler.create_tasks_for_resources
In the effort to remove duplication of logic, some differences were spotted: