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

Links under top-level 'links' may be objects #394

Closed
merkys opened this issue Jul 10, 2020 · 2 comments · Fixed by #484
Closed

Links under top-level 'links' may be objects #394

merkys opened this issue Jul 10, 2020 · 2 comments · Fixed by #484
Assignees
Labels
priority/high Issue or PR with a consensus of high priority validator Related to the OPTIMADE validator

Comments

@merkys
Copy link
Member

merkys commented Jul 10, 2020

I am trying to validate COD implementation (in development) using optimade-python-tools v0.9.8. The validator seems to require the values under the top-level links being strings:

$ optimade_validator https://www.crystallography.net/cod-test/optimade -v 5
Testing entire implementation at https://www.crystallography.net/cod-test/optimade...

Mandatory tests:
[snip]
2020-07-10 14:51:48,137 - optimade.validator.validator |    DEBUG: Testing multiple entry endpoint of references
✔: https://www.crystallography.net/cod-test/optimade/references?page_limit=5 - request successful.
✖: https://www.crystallography.net/cod-test/optimade/references?page_limit=5 - deserialize_response - failed with error
[snip]
	links -> first
	  str type expected (type=type_error.str)
	links -> next
	  str type expected (type=type_error.str)
Traceback (most recent call last):
[snip]
  File "/home/andrius/.local/lib/python3.6/site-packages/optimade/validator/validator.py", line 619, in get_endpoint
    request_str = request_str.replace("\n", "")
AttributeError: 'dict' object has no attribute 'replace'

In the COD implementation these values are "link objects", as per OPTIMADE specification:

   "links" : {
      "first" : {
         "href" : "http://www.crystallography.net/cod-test/optimade/v1.0.0/references?page_limit=5"
      },
      "next" : {
         "href" : "http://www.crystallography.net/cod-test/optimade/v1.0.0/references?page_limit=5&page_offset=5"
      },
      "base_url" : "http://www.crystallography.net/cod-test/optimade/v1.0.0/"
   }
@merkys merkys added the validator Related to the OPTIMADE validator label Jul 10, 2020
@ml-evs
Copy link
Member

ml-evs commented Jul 10, 2020

Hi @merkys, something is indeed going wrong here. It looks like we expect lists of links objects (not just in the validator) rather than a dictionary, which looks like the intention in the spec. I'll look into this more shortly.

This one might require a bit more work (as this error really shouldn't crash the validator, no matter what model is expected), but hopefully we can get a hotfix release out tonight (provided someone else is around to review it!)

In the meantime, if you want to validate other endpoints that would be checked after this crash, you can try using --as_type e.g.

optimade_validator -v 4 'https://www.crystallography.net/cod-test/optimade/structures?filter=elements HAS "Na"' --as_type structures

@ml-evs ml-evs added the priority/high Issue or PR with a consensus of high priority label Jul 10, 2020
@ml-evs ml-evs self-assigned this Jul 10, 2020
@merkys
Copy link
Member Author

merkys commented Jul 10, 2020

Thanks a lot @ml-evs for the prompt response! No need to hurry, I will get back to validation later.

In the meantime, if you want to validate other endpoints that would be checked after this crash, you can try using --as_type e.g.

optimade_validator -v 4 'https://www.crystallography.net/cod-test/optimade/structures?filter=elements HAS "Na"' --as_type structures

Sadly, this one crashes the validator with a looong traceback. Will open a separate issue with that, as it seems unrelated to me.

Edit: I have opened #397 to describe the aforementioned problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/high Issue or PR with a consensus of high priority validator Related to the OPTIMADE validator
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants