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

14 asynchronous requests #15

Merged
merged 9 commits into from
Jun 29, 2021
Merged

Conversation

xtrojak
Copy link
Collaborator

@xtrojak xtrojak commented Jun 28, 2021

Asynchronous rework which allows to execute multiple requests simultaneously. This pull requests solves issue #14. This approach was chosen as this is a typical example where program execution is often waiting for response of a request.

Also issue #11 is targeted but not solved, as this approach speeds up the performance. On the other hand, too many requests at once can overload request volume limitations of a service (e.g. PubChem).

Close #14.

@xtrojak xtrojak requested review from martenson and hechth June 28, 2021 12:38
Copy link
Member

@hechth hechth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual functionality looks great, the organization is a bit entangled (as we discussed) which could be split up more nicely, but I will create a separate issue for that.

The main idea is that the library code has dependencies to other library objects, instead of being composed by the main application, which makes the code more complex than necessary.

Comment on lines +54 to +55
results += await asyncio.gather(*[self.annotator.annotate(spectra, jobs, repeat) for spectra in
self.spectrums[size * batch_size:(size + 1) * batch_size]])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operation is quite complex and could either be fit into multiple lines or into a small helper function with a descriptive name.

As discussed, this might then also move to a different class.

Copy link
Member

@martenson martenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please consider implementing requests/minute limits -- we will surely need to throttle this even for testing.

@@ -7,23 +7,23 @@ Repository for tool that adds more annotations (e.g. SMILES, InChI, CAS number)

```python
# import MSP class
from libs.MSP import MSP
from libs.Spectra import Spectra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kudos for updating readme

libs/services/Converter.py Show resolved Hide resolved
tests/utils.py Outdated Show resolved Hide resolved
@xtrojak xtrojak merged commit 761d8a3 into RECETOX:main Jun 29, 2021
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.

Asynchronous web queries execution
3 participants