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

Common rules for inclusion and querying #210

Merged
merged 32 commits into from
Dec 20, 2019
Merged

Common rules for inclusion and querying #210

merged 32 commits into from
Dec 20, 2019

Conversation

merkys
Copy link
Member

@merkys merkys commented Nov 25, 2019

In discussions with @rartino and @CasperWA over #184 the following ideas over property inclusion have been crystallized:

  • There should be a small set of properties that MUST be included in the response by default;
  • response_fields may be used to include optional properties.

Similarly,

  • There should be a small set of properties that MUST support querying;
  • Other properties support querying OPTIONALLY.

This PR implements these ideas by adding general notices and cleaning up the 'Entry List' section to explicitly mark only those properties that either included by default or must support querying. (I know, this goes against @CasperWA's idea of having a property reference there, but I have little ideas how to do it otherwise. Machine-readable specs maybe? 😕). Thus fixes #204.

Also this PR:

@merkys merkys self-assigned this Nov 25, 2019
@merkys merkys added the PR/ready-for-review Add this flag if you are the author of the PR and you want it to be reviewed. Remove it when editing label Nov 25, 2019
@rartino
Copy link
Contributor

rartino commented Nov 25, 2019

Thank you for doing the job with this PR! This will greatly help to avoid a situation with all implementations having slightly incompatible interpretations of the rules of when to, and when not to, include output fields.

However, with the edits you've made so far in this PR, don't you have to also update the definition of response_fields in 4.1.1, i.e.,from

response_fields: a comma-delimited set of fields to be provided in the output. If provided, only these fields MUST be returned and no others. Example: http://example.com/optimade/v0.9/structures?response_fields=id,url

into something like

response_fields: a comma-delimited set of optional fields to be provided in the output. If provided, the implementation MUST include in its response both the indicated fields and the fields marked as REQUIRED for the endpoint. Fields for which no meaningful value can be given MUST still be included with a null value. The implementation MUST NOT return any other fields. Example: http://example.com/optimade/v0.9/structures?response_fields=immutable_id,chemical_formula_hill

@merkys
Copy link
Member Author

merkys commented Nov 26, 2019

Right, the suggested change to response_fields would fix #209 as well. However, I am a little hesitant about bundling that many changes in a single PR, as requirements of other implementations might conflict. Maybe let's wait for today's Web meeting to discuss it with wider audience, OK?

@merkys merkys added this to the 1.0 release milestone Nov 28, 2019
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.

Thanks @merkys!

I think you can definitely include the changes to response_fields here as well, as was suggested by @rartino. While it is a lot of changes in one PR, they are deeply connected. In the end, we do not squash and commit, so the commits will still be separate no matter what. So for the purposes of the PR, it is nice to have it done all-in-one :)

optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated
@@ -1656,8 +1656,7 @@ lattice\_vectors
- **Type**: list of list of floats.
- **Requirements/Conventions**:

- **Response**: REQUIRED in the response unless explicitly excluded, except when property `dimension_types`_ is equal to :val:`[0, 0, 0]` (in this case it is OPTIONAL).
- **Query**: Support for queries on this property is OPTIONAL. If supported, filters MAY support only a subset of comparison operators.
- **Response**: REQUIRED in the response.
Copy link
Member

Choose a reason for hiding this comment

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

I presume it is intentional to leave out the conditional here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The intent was to simplify the rules for inclusion/exclusion of properties. Also I had PR #206 in mind while developing the current PR.

optimade.rst Show resolved Hide resolved
@@ -1977,7 +1965,6 @@ Database-provider-specific entry types MUST have all properties described above

- **Requirements/Conventions for properties in database-provider-specific entry types**:

- **Response**: OPTIONAL in the response.
- **Query**: Support for queries on these properties are OPTIONAL.
Copy link
Member

Choose a reason for hiding this comment

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

You've deleted this for some that are OPTIONAL in the response, but not all. How do you justify this? Or rather, what is the implication?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. I was a little hesitant to cleanup the requirements, but I think with the addition of general clarification in 502bd44 the rest of the optional clauses can be removed. Did so in 8a6a4b2 and 892f60a.

Copy link
Contributor

@rartino rartino left a comment

Choose a reason for hiding this comment

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

In my opinion, every PR MUST leave the full specification internally consistent. Without editing the description of response_fields I don't think this PR fulfills that requirement.

We cannot simultaneously have:

  • The response_fields parameter described as "only these fields MUST be returned and no others."
  • A list of fields marked "REQUIRED in the response" with no indication that a valid response can (and should) exclude them if the response_fields parameter is used and they are not included.

Hence, I think the easiest solution to this problem by far is to also integrate the fix that was proposed for #209 into this PR, and simply say that REQUIRED properties are always REQUIRED in the response, and resonse_fields only indicates extra fields to include on top of those.

Otherwise, you need to revert the unless otherwise excluded caveats and look over the rest of the text for internal consistency with how response_fields is described to work in the present version.

optimade.rst Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
@rartino rartino added PR/waiting-for-update This PR has been reviewed and is waiting for the author to response or update the PR and removed PR/ready-for-review Add this flag if you are the author of the PR and you want it to be reviewed. Remove it when editing labels Dec 4, 2019
@rartino
Copy link
Contributor

rartino commented Dec 18, 2019

I had forgotten to merge the current state of develop. And, oh wow, that was a painful merge.

(I've tried to be careful, and my interpretation is that any bad mistake ought to show up in the diff for the present PR, since it would be reverting changes in the present state of develop. But, I'm honestly not sure on that; I remember a case earlier in the history of optimade.md where we managed to revert some changes in an unclean merge. We couldn't even trace back in which merge it had happened, there were 3 or so candidates...)

rartino
rartino previously approved these changes Dec 18, 2019
@merkys
Copy link
Member Author

merkys commented Dec 18, 2019

I had forgotten to merge the current state of develop. And, oh wow, that was a painful merge.

I trust you did the merge right :) OK, so we need yet one more approve.

@rartino
Copy link
Contributor

rartino commented Dec 18, 2019

Pinging @CasperWA, @sauliusg or @giovannipizzi for a review!

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.

Finally got around to going through this - sorry for the delay.

I really like the new "Supported".
Thanks for all the hard work that has been put into this PR!

Some things I noticed:

  • "Default properties" don't seem to be defined anywhere, but maybe that was just me missing it?
  • In the Entry list section, there are intermxed uses of either filter features or filter operators. I like both, and both have merit, I just wanted to point it out, to make sure this is a desired change by all - since they do have slightly different meanings/connotations.
  • In a similar vein, comparison operators vs. filter operators are used for some properties and not others. These make a lot of sense, but we should make sure they are used correctly when changed (or used).

optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated
@@ -310,16 +310,13 @@ The text in this section describes how the API handles properties with the value
The use of :val:`null` values inside nested property values (such as, e.g., lists or dictionaries) are described in the definitions of those data structures elsewhere in the specification, see section `Entry List`_.
For these properties, :val:`null` MAY carry a special meaning.

REQUIRED properties with an unknown value MUST be returned in the response, unless explicitly left out (e.g., by using :query-param:`response_fields`, see section `Entry Listing URL Query Parameters`_).
Responses that include entries where REQUIRED properties have an unknown value MUST include these properties with the value :val:`null`.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence is a bit difficult to read, I think. How about:

Suggested change
Responses that include entries where REQUIRED properties have an unknown value MUST include these properties with the value :val:`null`.
REQUIRED properties with an unknown value MUST be included and returned in the response.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've edited into:

REQUIRED properties with an unknown value MUST be included and returned in the response with the value :val:null.

optimade.rst Outdated

OPTIONAL properties with an unknown value MAY be returned in the response.
If an OPTIONAL property is *not* returned in a *full* response (i.e., not using :query-param:`response_fields`), the client MUST assume the property has an unknown value, i.e., :val:`null`.
Responses to requests where OPTIONAL properties have been explicitly requested via the :query-param:`response_fields` query parameter, and which include entries where those properties have an unknown value, MUST include these properties with the value :val:`null`.
Copy link
Member

Choose a reason for hiding this comment

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

This may then also be rewritten.

Suggested change
Responses to requests where OPTIONAL properties have been explicitly requested via the :query-param:`response_fields` query parameter, and which include entries where those properties have an unknown value, MUST include these properties with the value :val:`null`.
OPTIONAL properties, if requested explicitly via the :query-param:`response_fields` query parameter, MUST be included and returned in the response.

Copy link
Contributor

@rartino rartino Dec 19, 2019

Choose a reason for hiding this comment

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

Your version misses "with an unknown value". Sure, arguably you can say that the statement applies generally--- unknown value or not, but the point of this section is to clarify that these properties need to be in the response even if the value is unknown.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've edited into:

OPTIONAL properties with an unknown value, if requested explicitly via the :query-param:response_fields query parameter, MUST be included and returned in the response with the value :val:null.

optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
@rartino
Copy link
Contributor

rartino commented Dec 20, 2019

@CasperWA Thanks for the careful review! Hopefully, this version is better.

rartino
rartino previously approved these changes Dec 20, 2019
rartino
rartino previously approved these changes Dec 20, 2019
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.

@CasperWA Thanks for the careful review! Hopefully, this version is better.

This is looking splendid. Thanks for being so fast and taking care of my late-night review and suggested changes - here are a handful more 😅

I found some typing mistakes and have tried to rephrase a couple of sentences, not much this time.

I think with these last comments taken care of, this should be ready to be merged.

optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
optimade.rst Outdated Show resolved Hide resolved
@rartino
Copy link
Contributor

rartino commented Dec 20, 2019

@CasperWA done!

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.

Woot woot! I approve this hard work started by @merkys and finished by @rartino !
Thank you guys!

This is a somewhat major change, so we should definitely announce this change at the meeting today (but merge before, i.e., now).

So please merge @rartino, when you have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR/ready-for-review Add this flag if you are the author of the PR and you want it to be reviewed. Remove it when editing
Projects
None yet
3 participants