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

Fix query negation in MongoDB #814

Merged
merged 35 commits into from Jun 29, 2021
Merged

Fix query negation in MongoDB #814

merged 35 commits into from Jun 29, 2021

Conversation

JPBergsma
Copy link
Contributor

I have tried to fix the issues mentioned in issue #79 including simplifying the queries, for example $not :{$gt : 1} -> {$lte:1}

@codecov
Copy link

codecov bot commented May 27, 2021

Codecov Report

Merging #814 (b92fc9f) into master (00cb4e6) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #814      +/-   ##
==========================================
+ Coverage   92.64%   92.69%   +0.04%     
==========================================
  Files          67       67              
  Lines        3724     3749      +25     
==========================================
+ Hits         3450     3475      +25     
  Misses        274      274              
Flag Coverage Δ
project 92.69% <100.00%> (+0.04%) ⬆️
validator 92.69% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
optimade/filtertransformers/mongo.py 97.33% <100.00%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00cb4e6...b92fc9f. Read the comment docs.

@ml-evs ml-evs changed the title Jp bergsma/closes #79 Fix query negation in MongoDB May 28, 2021
@ml-evs
Copy link
Member

ml-evs commented May 28, 2021

Thanks for this @JPBergsma, I'd really like to get #797 in first, if you wouldn't mind re-reviewing that. I will take a look at this in the meantime.

Copy link
Member

@ml-evs ml-evs 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 so far @JPBergsma!

Could you please also add some tests to some of the end results, e.g. concoct some queries on the test data that should return a certain set of structures? That way we can also test that this is already being handled correctly in ES (and that the underlying MongoDB can use the query we generated). These tests can be found in tests.server.query_params.test_filter.

optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
tests/filtertransformers/test_mongo.py Show resolved Hide resolved
optimade/server/data/providers.json Outdated Show resolved Hide resolved
reverted providers.json back to its original state

Co-authored-by: Matthew Evans <7916000+ml-evs@users.noreply.github.com>
@JPBergsma JPBergsma requested a review from ml-evs June 21, 2021 14:59
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

Thanks for this @JPBergsma!

I've just had a first look and this is really shaping up. I've made a couple of preliminary comments below before I do a full review soon.

INSTALL.md Outdated Show resolved Hide resolved
tests/server/query_params/test_filter.py Outdated Show resolved Hide resolved
@JPBergsma JPBergsma requested a review from ml-evs June 23, 2021 16:31
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

Thanks for the good work @JPBergsma, a few suggestions:

optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
tests/filtertransformers/test_mongo.py Outdated Show resolved Hide resolved
tests/server/query_params/test_filter.py Outdated Show resolved Hide resolved
tests/server/query_params/test_filter.py Show resolved Hide resolved
Co-authored-by: Matthew Evans <7916000+ml-evs@users.noreply.github.com>
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

Just a few more suggestions for type hints and docstrings

optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Show resolved Hide resolved
optimade/filtertransformers/mongo.py Outdated Show resolved Hide resolved
optimade/filtertransformers/mongo.py Show resolved Hide resolved
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

Great work @JPBergsma, happy to approve this.

As there are two orthogonal changes in this PR (query negation & providers installation instructions), we would typically rebase/squash this PR into a smaller number of commits before merging, but as the provider installation instructions are very minor and the other changes are well localised, I think we can just squash this PR as one big commit.

The other option would be to manually rebase the changes in a sensible way and split into 3-4 commits, but I think this will require quite a lot of unpicking given the whitespace changes (even though they are no longer in the final changes).

So it's up to you - feel free to hit the squash+merge button when you are ready, or reorganise the PR and re-request my review!

@JPBergsma
Copy link
Contributor Author

I will go for the squash and merge.
It is indeed better to address one issue at a time, but, since the change in the instructions is very small, I think it won't be worth the extra time to split them into two PR's.

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.

None yet

3 participants