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

Add optimade end points #42

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

unkcpz
Copy link

@unkcpz unkcpz commented Sep 12, 2022

Implementation of #14

@csadorf this is a draft implementation of the OPTIMADE endpoints, start from adding getOptimadeVersions and getOptimateStructure capabilities. Please have a look and let me know if it is the right direction to our goal. Thanks!

@unkcpz unkcpz marked this pull request as draft September 12, 2022 13:12
Copy link
Collaborator

@csadorf csadorf left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started!

  1. Can you check whether it would be possible to mount the original optimade fastapi structures router as a sub-application? Otherwise it seems like we would need to re-implement a lot of things here.
  2. I assume we don't actually need the models/optimade module since we can import the models directly from the optimade package published on PyPI, correct?

pyproject.toml Show resolved Hide resolved
@unkcpz
Copy link
Author

unkcpz commented Sep 12, 2022

Can you check whether it would be possible to mount the original optimade fastapi structures router as a sub-application? Otherwise it seems like we would need to re-implement a lot of things here.

Thanks! This is something I am looking for. I'll give it a try.

I assume we don't actually need the models/optimade module since we can import the models directly from the optimade package published on PyPI, correct?

Yes, I think we are supposed to reuse all the models.

@csadorf
Copy link
Collaborator

csadorf commented Sep 12, 2022

Yes, I think we are supposed to reuse all the models.

In this case, please remove that empty module.

@unkcpz
Copy link
Author

unkcpz commented Sep 13, 2022

Can you check whether it would be possible to mount the original optimade fastapi structures router as a sub-application? Otherwise it seems like we would need to re-implement a lot of things here.

I think for the standard-app-api, we only put the placeholder here for openAPI generation and for app developers to implemented.
Look at the implementation again, I am not sure the routers of optimade-python-tools can be used here since they are not the placeholder but the real implementation of the APIs if I understand correctly.
Meanwhile, the models have lots of code that we'll not re-implement, while the routers we keep here as placeholders.

Pinning @CasperWA for comment.

@csadorf
Copy link
Collaborator

csadorf commented Sep 13, 2022

Maybe we can use something like https://github.com/ioxiocom/openapi-to-fastapi to generate our own scaffold?

@unkcpz
Copy link
Author

unkcpz commented Sep 19, 2022

Have an offline discussion with Casper, and the sub-app is good to use since the routers of optimade-python-tools are also abstract implementations,s and it just a bit more details and can be overridden by a new optimade database implementation. The validation check between python module and open API JSON can be generated and done with optimate API as sub-app. I'll check and continue with this line.

@CasperWA
Copy link

Have an offline discussion with Casper, and the sub-app is good to use since the routers of optimade-python-tools are also abstract implementations,s and it just a bit more details and can be overridden by a new optimade database implementation. The validation check between python module and open API JSON can be generated and done with optimate API as sub-app. I'll check and continue with this line.

The OPTIMADE Python tools example server is not an abstract implementation, but that shouldn't matter if you're only after the the generated OpenAPI?
Also, I'm unsure exactly what you mean by "abstract" in this context?

@unkcpz
Copy link
Author

unkcpz commented Sep 19, 2022

The OPTIMADE Python tools example server is not an abstract implementation, but that shouldn't matter if you're only after the the generated OpenAPI?

Yes, this is what I understand.
By "abstract" I mean the router functions are there but all as placeholders which raise HTTPException(status_code=501, detail="Not implemented.")

@unkcpz unkcpz closed this Sep 19, 2022
@unkcpz unkcpz reopened this Sep 19, 2022
@CasperWA
Copy link

The OPTIMADE Python tools example server is not an abstract implementation, but that shouldn't matter if you're only after the the generated OpenAPI?

Yes, this is what I understand. By "abstract" I mean the router functions are there but all as placeholders which raise HTTPException(status_code=501, detail="Not implemented.")

This is not what the OPTIMADE Python tools example server is doing - but it shouldn't matter if what you're after is just the OpenAPI specification.
The OPTIMADE Python tools example server is a full implementation, albeit as an example, meaning one needs to provide a proper set of configuration values to make it your own. Since you're only interested in the generated specification, I'd just use the example data, and use the mongomock backend. You would need to change some configuration options still to ensure you have the right base URL, root URL, provider and implementation information and probably more?

I'd confer with the OPTIMADE Python tools documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants