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 data_returned and data_available #93

Merged
merged 3 commits into from
Nov 27, 2019

Conversation

CasperWA
Copy link
Member

See the OPTiMaDe spec issue here.

data_returned is defined as the total number of data that can be returned using the passed parameters.
data_available is defined as the total number of data available of a certain type at any time.

data_available is saved "lazily", i.e., when the first request has been made, and then it is stored as a property for the specific collection instance.

Tests have been slightly updated to account for the fix.
Perhaps the expected data_returned value should be hard-coded?

data_returned is defined as the total number of data that can be
returned using the passed parameters.
data_available is defined as the total number of data available of a
certain type at any time.

data_available is saved "lazily", i.e., when the first request has been
made, and then it is stored as a property for the specific collection
instance.

Tests have been slightly updated to account for the fix.
Perhaps the expected data_returned value should be hardcoded?
@codecov
Copy link

codecov bot commented Nov 25, 2019

Codecov Report

Merging #93 into master will increase coverage by <.01%.
The diff coverage is 81.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
+ Coverage   85.06%   85.06%   +<.01%     
==========================================
  Files          38       38              
  Lines        2209     2210       +1     
==========================================
+ Hits         1879     1880       +1     
  Misses        330      330
Impacted Files Coverage Δ
optimade/server/utils.py 64.28% <100%> (-0.43%) ⬇️
optimade/server/tests/test_server.py 88.7% <79.48%> (+0.09%) ⬆️
optimade/server/entry_collections.py 83.73% <84.61%> (ø) ⬆️

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 3d3f906...4ad7e88. Read the comment docs.

ml-evs
ml-evs previously approved these changes Nov 25, 2019
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 clearing this up @CasperWA, I guess we all read the spec the same way.

I'm happy to approve at this stage, but have a minor comment. In the Mongo case, collection.count() will already use a cached value if no insertions/deletions have occurred, but obviously our value will become "out of date" if any have occurred. I guess this is just one of those implementation dependent things again, but calling count() explicitly every time makes sense to me as the number will always be correct if the number of documents has changed, and it shouldn't be much slower than the python cached version when it hasn't changed.

@CasperWA
Copy link
Member Author

I'm happy to approve at this stage, but have a minor comment. In the Mongo case, collection.count() will already use a cached value if no insertions/deletions have occurred, but obviously our value will become "out of date" if any have occurred. I guess this is just one of those implementation dependent things again, but calling count() explicitly every time makes sense to me as the number will always be correct if the number of documents has changed, and it shouldn't be much slower than the python cached version when it hasn't changed.

Ah, didn't know this. And maybe it is just easier to actually use the implemented methods. I will remove the local "cache".

optimade/server/entry_collections.py Outdated Show resolved Hide resolved
@CasperWA CasperWA requested a review from ml-evs November 27, 2019 09:45
@CasperWA CasperWA merged commit 18181e2 into master Nov 27, 2019
@CasperWA CasperWA deleted the fix_definition_data_returned_available branch November 27, 2019 12:44
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.

2 participants