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
Generalising collections and adding ElasticsearchCollection #660
Conversation
], | ||
) | ||
|
||
def find( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that much of the parameter handling (especially all the guard checks) could be done in the base class, as they are basically independent of the underlying db. I would suggest to implement find(params)
in the base class and have an abstract method _run_db_query(filter_query, page_limit, page_offset, sort_field, order)
.
ebed0ec
to
a8cb9d6
Compare
Codecov Report
@@ Coverage Diff @@
## master #660 +/- ##
==========================================
- Coverage 92.78% 92.67% -0.11%
==========================================
Files 67 68 +1
Lines 3533 3645 +112
==========================================
+ Hits 3278 3378 +100
- Misses 255 267 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
f46aedc
to
5430799
Compare
5430799
to
8f6df73
Compare
38c087a
to
7bf5b91
Compare
I think this is now ready for you @markus1978... perhaps it makes sense for you to test your server with this backend as part of the review? We can then go through and improve the overall integration in future PRs (see e.g. future to-do list in top comment) |
Requesting @CasperWA too in case he wants to look at the more general stuff. |
d718bcf
to
5ab64c1
Compare
Weird pydantic failures regarding the config with Python 3.9 that I can't shake off... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several different things to touch on. But generally, I'm really optimistic about these changes and this implementation/extension to the entry collections module.
See all suggested changes and comments below.
import pytest | ||
from optimade.server.config import CONFIG, SupportedBackend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have issues when importing from the package outside specific test functions.
I see you're using it in decorators, but maybe we can get around this in another way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, when reviewing this file, you're already using several different ways to handle the different backends. Choose one, and don't choose the one that uses decorators (because we then need to import from the package outside the test functions). And then import from the package where needed within each function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the problems that you're alluding to are; each pytest session is going to be testing one fixed backend so it shouldn't break anything. Importing inside each test will have the same side effect anyway, as the client will only be created once.
The different ways of handling it correspond to different outcomes: either needing to check for different error messages, or marking the tests as xfail
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure about the import order, but I just remember there were issues with importing configuration settings and similar outside tests as opposed to inside. But if it works, it's fine, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works fine with this current layout, i.e. testing each backend indepedently. It would be nice if we could wrap a lot of these tests with some kind of parameterized context manager that can switch between the backends (this will also be more extensible if we add more backends) but that is beyond the scope of this PR
f225114
to
41abcae
Compare
b972b88
to
a7526b6
Compare
- Renamed 'use_real_mongo' option to reflect general usage - Tweaks to elasticsearch indexes and naming conventions - Explicitly remove HAS ONLY code
- Remove CI_FORCE_<x> config values and promote mongomock to a supported backend - Reintroduce 'use_real_mongo' as a deprecated field
- Generalised some tests to work with elastic - Fix sorting and aliases - Fix 'more_data_available' response from elasticsearch - Fix query in structure router tests - Fix typo in elastic aliases - Add 'id' to elastic index and sort on it by default - Properly handle aliases in elastic index - Fixed elasticsearch sorting and tests - Added default sort over ID for structure data - Updated sorting tests to reflect that elasticsearch does not store milliseconds - Comment out HAS ONLY and correlated list tests, pending removal - Add quotes and properly decode URLs when testing elastic - Use 'date' type for last_modified in elastic index and add species_at_sites - Formatted elastic index - Use CONFIG rather than env var for elastic testing - Skip mongo mapper test for non-mongo backends - Run validator coverage tests with all backends
c9534d3
to
3d57a79
Compare
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @ml-evs ! As well as the initial work @markus1978. Thanks !
Thanks guys for all this work. I hope I can get around taking it for a spin soon. |
This PR is the spiritual successor of #339 and includes a lot of @markus1978's original work.
Closes #742.
To-do
ElasticsearchCollection
and move some mongo-specific stuff into theMongoCollection
.Known issues (to be raised pending review)
Some future to-do:
This PR opens up the opportunity to do some work, which we can track with new issues:
HAS ONLY
)