-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor batch request mechanism #383
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
crisely09
reviewed
Feb 17, 2024
crisely09
reviewed
Feb 17, 2024
crisely09
reviewed
Feb 17, 2024
@MFSY any thoughts? |
* batch retrieval * return action on error
MFSY
approved these changes
Jun 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
nexus-forge/kgforge/specializations/stores/bluebrain_nexus.py
Line 119 in 02da102
nexus-forge/kgforge/specializations/stores/bluebrain_nexus.py
Line 190 in 02da102
This has not been addressed in this MR but should be in the future.