Skip to content
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 104 commits into from
Jun 20, 2024
Merged

Refactor batch request mechanism #383

merged 104 commits into from
Jun 20, 2024

Conversation

ssssarah
Copy link
Contributor

@ssssarah ssssarah commented Feb 15, 2024

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:

@ssssarah ssssarah marked this pull request as ready for review February 15, 2024 14:39
@crisely09
Copy link
Contributor

crisely09 commented Feb 22, 2024

@MFSY any thoughts?

@MFSY MFSY merged commit 87c4995 into master Jun 20, 2024
2 checks passed
MFSY pushed a commit that referenced this pull request Jul 5, 2024
@ssssarah ssssarah deleted the refactor_batch branch August 16, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants