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: REST API date-time query #4959

Merged
merged 6 commits into from
Jul 28, 2021
Merged

🐛 FIX: REST API date-time query #4959

merged 6 commits into from
Jul 28, 2021

Conversation

NinadBhat
Copy link
Contributor

Fixes #4957

Added hashing function for DatetimePrecision object.

@chrisjsewell Not sure if this is entirely right, but this method solved the error for me.

@NinadBhat NinadBhat changed the title Datetimeprecision hash Adds hashing for DatetimePrecision object May 21, 2021
@codecov
Copy link

codecov bot commented May 21, 2021

Codecov Report

Merging #4959 (149daa6) into develop (6606a5b) will increase coverage by 0.06%.
The diff coverage is 84.62%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4959      +/-   ##
===========================================
+ Coverage    80.17%   80.23%   +0.06%     
===========================================
  Files          515      515              
  Lines        36741    36746       +5     
===========================================
+ Hits         29454    29478      +24     
+ Misses        7287     7268      -19     
Flag Coverage Δ
django 74.70% <84.62%> (+0.06%) ⬆️
sqlalchemy 73.63% <84.62%> (+0.06%) ⬆️

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

Impacted Files Coverage Δ
aiida/common/utils.py 79.65% <77.78%> (-0.07%) ⬇️
aiida/common/hashing.py 93.81% <100.00%> (+0.17%) ⬆️
aiida/restapi/common/utils.py 78.98% <100.00%> (+4.91%) ⬆️
aiida/transports/plugins/local.py 81.41% <0.00%> (-0.25%) ⬇️
...iida/orm/implementation/sqlalchemy/querybuilder.py 81.61% <0.00%> (+0.58%) ⬆️
aiida/orm/implementation/django/querybuilder.py 77.85% <0.00%> (+0.64%) ⬆️

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 6606a5b...149daa6. Read the comment docs.

@ltalirz ltalirz requested a review from chrisjsewell May 24, 2021 08:02
Copy link
Member

@chrisjsewell chrisjsewell left a comment

Choose a reason for hiding this comment

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

Thanks @NinadBhat!
The fix looks fine, I think though it would be good to also add a test in tests/restapi/test_routes.py:RESTApiTestSuite, with an mtime/ctime filter on nodes

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

Here are some questions from my view:

  1. We already know the DatetimePrecision has a datatime and an int as its objects, then is there any particular reason that you dispatch it to return like a abc.Sequence instead of dispatch it like numbers.Complex which also defined by two auguments.
  2. I would suggest moving the DatatimePrecision definition from aiida.restapi.common.utils to aiida.common. Since aiida.common is a more 'internal' module then aiida.restapi. or maybe can put new code in aiida.restapi.common.utils and leave aiida.common untouched?
  3. I believe would be also good to add test in tests/common/test_hashing.py.

@unkcpz
Copy link
Member

unkcpz commented May 24, 2021

just look into the tests/common/test_hashing.py, since there are lots of tests assertion which compare expected with hash strings, it would be suitable to use pytest-regression to do this. But this will be in other PR. Also looking for your opinion @chrisjsewell .

@NinadBhat
Copy link
Contributor Author

@chrisjsewell, the one test failing is because docker does not install flask. Not sure where I should add flask dependency for it to be installed with docker.

@unkcpz
Copy link
Member

unkcpz commented May 25, 2021

the one test failing is because docker does not install flask. Not sure where I should add flask dependency for it to be installed with docker.

From my point of view, I think this is a side effect that I mentioned, where you import restapi.common in aiida.common. In fact, aiida.common would be better to know nothing about aiida.restapi I guess.

@NinadBhat
Copy link
Contributor Author

@unkcpz makes sense. Thanks for the quick reply. @chrisjsewell should I move DatatimePrecision to aiida.common ?

@chrisjsewell
Copy link
Member

should I move DatatimePrecision to aiida.common

Yeh I don't think that is a problem; it is a very simple class with no dependencies

We already know the DatetimePrecision has a datatime and an int as its objects, then is there any particular reason that you dispatch it to return like a abc.Sequence instead of dispatch it like numbers.Complex which also defined by two auguments.

meh, I'm not too bothered either (particularly as we are likely going to scrap all the current restapi code soon 😆). It would actually be kind of nice to know where/why it is actually being hashed in the first place; from a quick look in the code, this was not immediately apparent (but don't worry about spending too long on this)

it would be suitable to use pytest-regression to do this. But this will be in other PR. Also looking for your opinion @chrisjsewell .

yeh always happy to use pytest-regression 👍 , although I don't think its a test dependency yet so yeh wouldn't add it in this PR

@chrisjsewell chrisjsewell changed the title Adds hashing for DatetimePrecision object 🐛 FIX: REST API date-time query Jul 28, 2021
@chrisjsewell chrisjsewell merged commit 91c1c0b into aiidateam:develop Jul 28, 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.

REST API: Querying for datetime excepts
4 participants