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

Add configurable field-specific validator overrides to set filter operators as optional #1025

Merged
merged 1 commit into from Dec 20, 2021

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Dec 17, 2021

Closes #1024.

@ml-evs ml-evs added priority/medium Issue or PR with a consensus of medium priority validator Related to the OPTIMADE validator labels Dec 17, 2021
@codecov
Copy link

codecov bot commented Dec 17, 2021

Codecov Report

Merging #1025 (07bff38) into master (1b1225b) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1025      +/-   ##
==========================================
+ Coverage   92.33%   92.34%   +0.01%     
==========================================
  Files          67       67              
  Lines        3784     3790       +6     
==========================================
+ Hits         3494     3500       +6     
  Misses        290      290              
Flag Coverage Δ
project 92.34% <100.00%> (+0.01%) ⬆️
validator 92.34% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
optimade/validator/config.py 100.00% <100.00%> (ø)
optimade/validator/validator.py 83.11% <100.00%> (+0.06%) ⬆️

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 1b1225b...07bff38. Read the comment docs.

@ml-evs ml-evs force-pushed the ml-evs/validate_optional_substring branch from b495177 to 07bff38 Compare December 17, 2021 19:09
Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Seems good to me.

Would it be possible to add a test?
Just a very simple one for checking sub-strings in a valid and invalid case, maybe?
Simply making sure the feature works.

Also - I was thinking - the models support levels are taken from what we set in the models, correct? Does this mean we need to update these as well - or is it merely because we're hitting a sub-criterium here that the support level needs to be overridden like this?

@ml-evs
Copy link
Member Author

ml-evs commented Dec 20, 2021

Seems good to me.

Would it be possible to add a test? Just a very simple one for checking sub-strings in a valid and invalid case, maybe? Simply making sure the feature works.

Bit tricky to test that the tests are treated as optional (we don't test this anywhere else) since it depends on the server. The validator "config" is very much not user code, and the config values are basically hardcoded to reflect the specification. We could add a validator for the config field, but I think it would be overly restrictive in the dev edge case that someone wants to patch the validator for their own system.

Also - I was thinking - the models support levels are taken from what we set in the models, correct? Does this mean we need to update these as well - or is it merely because we're hitting a sub-criterium here that the support level needs to be overridden like this?

Yes, this doesn't affect the field support, but adds handling of edge cases to the queryable nature of the field. We certainly do want to validate equality queries on chemical formulae, so queryable should definitely remain a MUST. As these are the only two cases I have found so far, I don't think it is worth restructuring our queryable field around this.

@CasperWA
Copy link
Member

Would it be possible to add a test? Just a very simple one for checking sub-strings in a valid and invalid case, maybe? Simply making sure the feature works.

Bit tricky to test that the tests are treated as optional (we don't test this anywhere else) since it depends on the server. The validator "config" is very much not user code, and the config values are basically hardcoded to reflect the specification. We could add a validator for the config field, but I think it would be overly restrictive in the dev edge case that someone wants to patch the validator for their own system.

Fair enough. Would it make sense with a unit test at least for the functions? Making sure the if-blocks are reached as expected? Or would you rather just not test? :)

@ml-evs
Copy link
Member Author

ml-evs commented Dec 20, 2021

Fair enough. Would it make sense with a unit test at least for the functions? Making sure the if-blocks are reached as expected? Or would you rather just not test? :)

We could really go to town on unit tests of edge cases with the validator (mocking servers/requests, checking particular requests etc. are made) but I don't think it is worth the effort at this stage (I don't have the bandwidth, at least). I've tested this on the OQMD (who the issue affects) and a few other providers. We should see any bugs popping up in the dashboard PR runs (when we next release) which I think provides better coverage than we could in this code.

@ml-evs ml-evs merged commit 75d2e3e into master Dec 20, 2021
@ml-evs ml-evs deleted the ml-evs/validate_optional_substring branch December 20, 2021 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/medium Issue or PR with a consensus of medium priority validator Related to the OPTIMADE validator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overzealous validation of substring comparisons for chemical formula fields
2 participants