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

Update models, endpoints and responses to 1.0.0 #380

Merged
merged 5 commits into from Jul 2, 2020

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Jun 30, 2020

Closes #379. This PR brings our models, responses and endpoints up to date with newly released 1.0.0 of the specification.

I've split this up into 4 commits, which should each individually pass the tests:

  1. Enabled serving the API at the unversioned base URL and moved the vMajor router addition to a separate function. This means the generated schemas no longer contain version numbers, as desired.
  2. Added the /versions endpoint from the unversioned base URL for both index and regular db's. This should now have the correct schema response (matching the released version).
  3. Removed the index_base_url field, as it has been from the schema. I've moved the original config option we had for this to the top-level, and had to adjust our tests accordingly.
  4. Updated all the models according to the final changes since 1.0.0-rc.2, e.g.
    • meta now being mandatory, but several sub-fields becoming optional,
    • consistency in how we represent links (i.e. Union[jsonapi.Links, AnyUrl]).
    • descriptions for version/api_version numbers
    • fixed some other descriptions, e.g. typos, broken internal links and missing newlines.

@ml-evs ml-evs force-pushed the ml-evs/add_versions_endpoint branch from a59292a to 00da5df Compare June 30, 2020 14:15
@codecov
Copy link

codecov bot commented Jun 30, 2020

Codecov Report

Merging #380 into master will decrease coverage by 0.05%.
The diff coverage is 82.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #380      +/-   ##
==========================================
- Coverage   90.27%   90.22%   -0.06%     
==========================================
  Files          54       55       +1     
  Lines        2386     2404      +18     
==========================================
+ Hits         2154     2169      +15     
- Misses        232      235       +3     
Flag Coverage Δ
#unittests 90.22% <82.22%> (-0.06%) ⬇️
Impacted Files Coverage Δ
optimade/models/baseinfo.py 94.87% <ø> (ø)
optimade/models/entries.py 100.00% <ø> (ø)
optimade/server/main.py 84.78% <44.44%> (-0.94%) ⬇️
optimade/server/main_index.py 84.78% <57.14%> (-5.70%) ⬇️
optimade/models/optimade_json.py 93.97% <100.00%> (+0.07%) ⬆️
optimade/models/responses.py 97.50% <100.00%> (ø)
optimade/server/config.py 100.00% <100.00%> (ø)
optimade/server/routers/index_info.py 100.00% <100.00%> (ø)
optimade/server/routers/landing.py 68.75% <100.00%> (+2.08%) ⬆️
optimade/server/routers/versions.py 100.00% <100.00%> (ø)
... and 1 more

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 cdf3483...65e5136. Read the comment docs.

@ml-evs ml-evs force-pushed the ml-evs/add_versions_endpoint branch 2 times, most recently from 0dd0557 to b872fe4 Compare June 30, 2020 14:41
@ml-evs ml-evs requested review from CasperWA and shyamd June 30, 2020 14:44
@ml-evs ml-evs force-pushed the ml-evs/add_versions_endpoint branch 2 times, most recently from 0d5af29 to 9991937 Compare June 30, 2020 14:45
@ml-evs ml-evs mentioned this pull request Jun 30, 2020
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.

Should versions also be included in the index meta-database?

optimade/server/main.py Outdated Show resolved Hide resolved
optimade/server/routers/versions.py Outdated Show resolved Hide resolved
tests/server/routers/test_versions.py Outdated Show resolved Hide resolved
tests/server/routers/test_versions.py Show resolved Hide resolved
@CasperWA
Copy link
Member

CasperWA commented Jul 1, 2020

Why isn't /versions added to the OpenAPI schema? Can it not be added? Or it shouldn't?

Edit: I found your "thought" on this in the OP :)

optimade/server/main.py Outdated Show resolved Hide resolved
optimade/models/optimade_json.py Outdated Show resolved Hide resolved
optimade/models/optimade_json.py Outdated Show resolved Hide resolved
optimade/server/routers/versions.py Outdated Show resolved Hide resolved
optimade/server/routers/versions.py Outdated Show resolved Hide resolved
optimade/server/routers/versions.py Outdated Show resolved Hide resolved
@ml-evs
Copy link
Member Author

ml-evs commented Jul 1, 2020

I think we've now ironed out all differences between schemas and the specification, except the way we specify the content type of the versions endpoint, which I'll have a go at later.

@ml-evs
Copy link
Member Author

ml-evs commented Jul 1, 2020

We also need to change a lot of our test data so that the tests pass, e.g. index_base_url no longer existing.

@ml-evs ml-evs force-pushed the ml-evs/add_versions_endpoint branch 2 times, most recently from 7e46503 to 24b4f9c Compare July 1, 2020 22:49
@ml-evs
Copy link
Member Author

ml-evs commented Jul 1, 2020

Pending these test failures, I think that's everything done, except changing the content of /versions to text/csv rather than application/json.

- This URL is now used when generating the OpenAPI schemas
- This commit removes the `index_base_url` from the models and updates
all tests, routers and config files accordingly.
- `index_base_url` is now a top-level config option.
@ml-evs ml-evs force-pushed the ml-evs/add_versions_endpoint branch from f0fb738 to 9b293c9 Compare July 2, 2020 11:19
@ml-evs
Copy link
Member Author

ml-evs commented Jul 2, 2020

I've just spent a while meticulously thematically splitting this PR into just a few commits, each of which should pass tests individually. If you're reviewing, it might make sense to break it down per commit.

@ml-evs ml-evs changed the title Add the /versions endpoint Update models, endpoints and responses to 1.0.0 Jul 2, 2020
@ml-evs ml-evs added priority/high Issue or PR with a consensus of high priority schema Concerns the schema models server Issues pertaining to the example server implementation labels Jul 2, 2020
@ml-evs ml-evs requested review from shyamd and CasperWA July 2, 2020 11:27
shyamd
shyamd previously approved these changes Jul 2, 2020
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.

We should add homepage to the implementation configurations as well, I think?

All in all, pretty great work @ml-evs !

openapi/index_openapi.json Outdated Show resolved Hide resolved
openapi/openapi.json Outdated Show resolved Hide resolved
optimade/models/optimade_json.py Outdated Show resolved Hide resolved
@@ -73,13 +73,16 @@ class ServerConfig(BaseSettings):
),
description="Introspective information about this OPTIMADE implementation",
)
index_base_url: Optional[AnyHttpUrl] = Field(
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have this now?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can remove it, sure, it's only (optionally) used in the landing page now

Copy link
Member

Choose a reason for hiding this comment

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

Right. Is there a way for us to automagically retrieve it from the links endpoint data JSON file? Then there is only one source of truth and we're not mixing concepts. Especially, when it's using a recently outdated valid field name.

optimade/server/main.py Show resolved Hide resolved
optimade/server/routers/landing.py Outdated Show resolved Hide resolved
optimade/server/routers/versions.py Show resolved Hide resolved
tests/server/utils.py Outdated Show resolved Hide resolved
tests/server/utils.py Show resolved Hide resolved
tests/server/utils.py Outdated Show resolved Hide resolved
tests/server/utils.py Outdated Show resolved Hide resolved
@ml-evs ml-evs force-pushed the ml-evs/add_versions_endpoint branch 2 times, most recently from 4a694dc to 83176d4 Compare July 2, 2020 21:12
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
optimade/server/routers/versions.py Outdated Show resolved Hide resolved
@ml-evs ml-evs force-pushed the ml-evs/add_versions_endpoint branch from 83176d4 to 65e5136 Compare July 2, 2020 21:24
@ml-evs ml-evs merged commit b9ce81c into master Jul 2, 2020
@ml-evs ml-evs deleted the ml-evs/add_versions_endpoint branch July 2, 2020 21:31
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 schema Concerns the schema models server Issues pertaining to the example server implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Un)versioned URLs
3 participants