-
Notifications
You must be signed in to change notification settings - Fork 42
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
New REQUIRED level properties #153
New REQUIRED level properties #153
Conversation
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.
@CasperWA I have a few minor comments,
but I also need to say that I didn't quite get the main point of the PR, so probably better if we have a quick chat tomorrow (or someone else could review)
@@ -84,7 +84,7 @@ def validate_chemical_symbols(cls, v): | |||
def validate_concentration(cls, v, values): | |||
if len(v) != len(values.get("chemical_symbols", [])): | |||
raise ValueError( | |||
f"Length of concentration ({len(v)}) MUST equal length of chemical_symbols ({len(values.get('chemical_symbols', []))})" | |||
f"Length of concentration ({len(v)}) MUST equal length of chemical_symbols ({len(values.get('chemical_symbols', 'Not specified'))})" |
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.
Is 'Not specified'
better than None
here?
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.
I guess it's more informative if you're developing a server, which these messages are mainly for.
Edit: None
might be a deliberately set value.
I have added a test, repeated 3 times for each endpoint "links", "references" and "structures". |
Furthermore, I have opened an issue Materials-Consortia/OPTIMADE#250 to clarify the spec description of |
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 for this @CasperWA, everything here looks sensible. When you're happy with it I can run through this alongside the spec to check that we have all the required fields.
Could you just clarify something for me? It's now possible for implementations to return (by default) a set of fields that would be insufficient to construct our own models from, correct? e.g. if by default an implementation does not return nsites
, we cannot build an optimade-python-tools StructureResource
as it nsites
is required for validating the positions. If this is the case, we might have to think about producing a list somewhere of all our "required" properties so that any future client built from this repo (where the validator itself is an example) can ask for the fields it needs to build our models.
Huh, you're right. Didn't think about this, actually. Yeah, we need to take this into account for the validator. |
The `handle_response_fields` utility function now assumes that all fields to be excluded from entries are under `attributes`, since `id`, `type` and all other top-level non-attributes fields are REQUIRED in the response, even when not included as a value to `response_fields`. The mappers can use the class variable `REQUIRED_FIELDS` to have a set of REQUIRED response fields that MUST be returned, even when not included as a value to `response_fields`. Note: At the time of this commit, there are no fields under any endpoint's attributes that are REQUIRED in the response.
7fc5adb
to
032b7ae
Compare
Added my validators and tests. I changed |
Should we get this in for this PR or can it wait? I guess it can be done in a separate PR, although it is related to the same OPTiMaDe PR. This was more about the models, not the validator consequenses ... |
Another PR, for sure. |
Bump to v0.4.0 Changes: Changes: - Reorder test files and update testing endpoints setup (#162, @CasperWA) - Separate the regular and index-meta database server, making sure they're not importing each other (#160, @CasperWA) - Introduce Starlette/FastAPI HTTP middleware for redirecting URLs ending with a slash to URLs _not_ ending with a slash (#160, @CasperWA) - Fix validation of `dimension_types` resulting in `response_fields` failing and add tests for `response_fields` (#153, @CasperWA) - Update entry list property descriptions according to updated OPTiMaDe spec (#153, @CasperWA) - Validate updated entry list properties and test updated entry list properties (#153, @ml-evs) - Add OpenAPI schema descriptions for query parameters (#166, @CasperWA) - Remove custom constrained types `NonnegativeInt` and `conlist` and use instead standard types together with `pydantic`'s `FieldInfo` parameters for schema generation and validation (#166, @shyamd, @CasperWA)
Fixes #114
Fixes #154
See commit message.
Note: