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

Fix/openapi endpoints #361

Merged
merged 5 commits into from
Jun 2, 2022
Merged

Conversation

eimrek
Copy link
Member

@eimrek eimrek commented Jun 1, 2022

Currently the endpoints

"extensions/docs",
"extensions/redoc",
"extensions/openapi.json",

are not available on materialscloud. See e.g. https://aiida.materialscloud.org/optimade-sample/optimade/v1/extensions/docs

(but they are listed on https://aiida.materialscloud.org/optimade-sample/optimade/v1/info)

On localhost, they are available.

The problem seems to stem from here:

docs_url=f"{DOCS_ENDPOINT_PREFIX}{OPEN_API_ENDPOINTS['docs']}",
redoc_url=f"{DOCS_ENDPOINT_PREFIX}{OPEN_API_ENDPOINTS['redoc']}",
openapi_url=f"{DOCS_ENDPOINT_PREFIX}{OPEN_API_ENDPOINTS['openapi']}",

Comparing with similar code in optimade-python-tools

https://github.com/Materials-Consortia/optimade-python-tools/blob/281ca780881d9529d7d247e5075eddf08152a362/optimade/server/main.py#L57-L59

they don't add the full path to the corresponding arguments.

I changed the code to be similar as optimade-python-tools and now everything seems to work. I removed the get_custom_base_url_path() function for maintainability, as it remains unused now.

@codecov
Copy link

codecov bot commented Jun 1, 2022

Codecov Report

Merging #361 (0f04e2d) into develop (b48cb39) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop     #361      +/-   ##
===========================================
+ Coverage    92.93%   93.03%   +0.09%     
===========================================
  Files           32       32              
  Lines         1373     1363      -10     
===========================================
- Hits          1276     1268       -8     
+ Misses          97       95       -2     
Flag Coverage Δ
aiida 89.43% <100.00%> (+0.06%) ⬆️
mongo 79.16% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiida_optimade/utils.py 100.00% <ø> (+5.71%) ⬆️
aiida_optimade/main.py 95.65% <100.00%> (-0.07%) ⬇️

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 b48cb39...0f04e2d. Read the comment docs.

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

@eimrek thanks. It looks all good to me.

@unkcpz
Copy link
Member

unkcpz commented Jun 1, 2022

Hi @CasperWA, since this is not a big PR and a quick fix of things that bring issues to materials cloud page. I will do the merge without your approval, hope you don't mind.

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

@eimrek make a test on materials cloud and still not working.

@eimrek
Copy link
Member Author

eimrek commented Jun 1, 2022

Important to use root_path in the config file.

Everything works well on materialscloud, if base_url is just the domain and root_path is the rest before the optimade-specific part. E.g.

  "base_url": "https://dev-aiida.materialscloud.org",
  "root_path": "/optimade-sample/optimade",

APP = FastAPI(
root_path=CONFIG.root_path,
Copy link
Member

Choose a reason for hiding this comment

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

I think we'd remove this it should read from CONFIG or we also explicitly set base_url.

Copy link
Member Author

Choose a reason for hiding this comment

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

removing root_path didn't work. So i added also base_url to be consistent

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

It is tested and works fine on Materials cloud

@unkcpz unkcpz merged commit ce68cc2 into aiidateam:develop Jun 2, 2022
@eimrek eimrek deleted the fix/openapi-endpoints branch June 2, 2022 10:57
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.

2 participants