-
Notifications
You must be signed in to change notification settings - Fork 192
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
Sanitizing ArrayData for REST-API #5613
Conversation
…as JSON via the REST-API. Addresses aiidateam#5559
@sphuber, @chrisjsewell Do you agree with this PR? Or should something else be done before merging? |
I'm happy with the concept of changing |
Hi @sphuber!
Sure thing! I'll add a test, I guess that what we are interested in is setting a test in the route to verify that the resulting JSON is valid. Since otherwise the valid entries of the array are the same. aiida-core/tests/restapi/test_routes.py Lines 35 to 51 in 6ab9f51
After that one would just request for that node and check what is obtained from it like in this case aiida-core/tests/restapi/test_routes.py Lines 1004 to 1015 in 6ab9f51
Sure thing I'll add a note in the documentation indicating that if an
Yes, I'm also unsure of what the most efficient implementation would be, but this is the best I could find. there is a function in numpy to replace |
@sphuber done, test and note in docs added. If something else is needed just let me know. |
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.
Thanks @JPchico , the changes look ok to me. If you can just fix the failing docs build, this can be merged.
If the docsstring are giving you issues, it might be best to remove the typing from the docstring and use type hints directly in the function signature. Didn't request this in the review since it is a minor thing, but since you are touching it now anyway, might as well use type hints |
Hi @sphuber , funnily enough it seems to be that there were some issues with unavailable resources (in other areas of the code), for example one of the errors that I'm getting is the following
I solved another in which the link for the requests documentation seemed to be pointing to an unsafe ulr that could not be accessed. This one though is a bit strange since I can enter the url but the compilation ends in error. |
So removing the |
…t they are valid JSON. Adding a note in the documentation explaining that invalid JSON values will be replaced by None which will be rendered as nulls.
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.
Thanks @JPchico
Sanitizing np.array from Nan and np.inf to ensure that the arrays are proper JSON and can be obtained via the REST-API. Fixes #5559