-
Notifications
You must be signed in to change notification settings - Fork 31
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
Adding Swagger documentation to Gateway #1205
Conversation
Thank you @david-alber for your contribution! |
Awesome, thank you @david-alber ! ❤️ |
If I understand correctly, this will serve the swagger docs directly from the gateway pod, right? Do we also want to makes the docs available offline and add them to a repo, either here or in the main IQP docs one? |
Yes, you are right, Paul.
Mmm... I think it's not needed but open to discuss it. |
Neither of the UI sites work for me: the |
@IceKhan13 I didn't think about it when we added the plugin but probably @psschwei has a point here. If I remember correctly we are not using now these end-points without keycloack so we could remove this ViewSet If I'm not wrong 🤔 (we could fix this in another PR). |
Looking at the Runtime API as an example, their docs are available at: The former looks like it makes the doc available similar to how we do here (in their case, via https://runtime-us-east.quantum-computing.ibm.com/static/qiskit_runtime.v1.yaml, which unless I'm mistaken is being served from their app, like we do the gateway here) Not sure about the docs on IBM Cloud. In any case, as long as what we're doing can easily move into the main docs (at whichever location), I think we're good... |
Good question @psschwei , to be honest I thought that those pages required another additional step. I don't know if exporting our swagger configuration could be more than enough. Definitely something that we can try. |
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.
Neither of the UI sites work for me: the /swagger/ one asks for a Django login, and the /redoc/ one just loads a blank page. Both the file ones work fine.
Same as @psschwei , I see Django Login if I enter in the /swagger
url. Are we doing something wrong @david-alber ? Thank you in advance 😄
I deploy quantum-serverless locally: docker-compose -f docker-compose-dev.yaml up --build Then I can see the swagger UI at The most recent commit allows the rendering if no user is set. Could this have been the issue? |
Yes, I think we can remove them. |
I'm deploying on Kubernetes (local kind cluster) using the Helm chart. Even with the most recent change, I am not able to access the Swagger UI (still getting the Django log in screen). But it does work fine on Docker Compose. One other thing -- I didn't see a way to pass the token as a header, which I think we might need for users to authenticate against the gateway to run commands |
|
Sorry for the delay @david-alber . In my case I use |
@psschwei @Tansito with the latest commit I am addressing the following concerns:
I have tested this by locally building the respective docker containers: docker compose -f docker-compose-dev.yaml up postgres ray-head gateway -d --build The Swagger UI is then available via: Unfortunately, I am having issues with the deployment on K8s via a local kind cluster and thus cannot reproduce this test scenario. Maybe we can move this to another issue? |
Signed-off-by: Paul S. Schweigert <[email protected]>
* add ModelView API for CatalogEntry * additional apis for catalogentry --------- Signed-off-by: Akihiko Kuroda <[email protected]>
* Removed main components from repository project * Updated chart lock * Remove repository references from the client
Signed-off-by: Akihiko Kuroda <[email protected]>
* use LocalProvider for notebook test Signed-off-by: Akihiko Kuroda <[email protected]>
* Update contribution guidelines * Update contributing doc with supported python versions * Remove Python 3.7 badge from README files * Upgrade min python version in setup.py
Yep, I agree. Thank you @david-alber , I will take a look on it and let you know 🙏 |
Thank your for the update @david-alber I will try to take a look along this week 😄 |
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.
Hey @david-alber I see everything fine and from my part is working now. Thank you so much 🙏
Oddly, I no longer see the Swagger UI, even when rolling back to the previous commit that did work, though I'm going to assume that's an issue on my end given that it's working for @Tansito |
I tested it with the codespace feature + |
Port forwarding the kubernetes service |
@psschwei if you execute |
It did not (though that command did copy 69 files...), though that seems to be a step in the right direction |
Locally for me it's working too (I just checked it right now). We can always continue improving this configuration later until it works for everyone. |
Well, not so much getting blocked as not existing... edit: files exist in the pod, for example
|
@Tansito how are you exposing the Kubernetes service? Port forwarding? Ingress? Door number 3? |
Not using kubernetes at all, I just checked running locally with |
Ah, ok... it works fine for me too without kubernetes (docker compose in my case). |
Yeah, I don't discard that we will need to review permissions or those kind of things. Is it something maybe that we can do in another PR? What do you think? (I don't have a strong opinion). |
I think either way is fine... as is, this PR adds the docs, and we just need to figure out how to expose it via Kubernetes (which is how end users will access it). |
hmm... doesn't look like we're actually using gunicorn in kubernetes, whereas we are in docker compose... |
Initially yes, or at least in our CI / CD: This will run the command when it deploys the gateway if I'm not wrong, won't it @psschwei ? |
No, you're right... I was only looking at the dockerfile, not the deployment |
Ok, so I think I've narrowed this down to an issue with how Django serves static files... short version is in Kubernetes the Running locally, putting Django in debug mode and making a couple of tweaks to urls.py $ git diff urls.py
diff --git a/gateway/main/urls.py b/gateway/main/urls.py
index 3180e81b..41cd6d03 100644
--- a/gateway/main/urls.py
+++ b/gateway/main/urls.py
@@ -22,6 +22,7 @@ from rest_framework import routers, permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
import probes.views
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
schema = get_schema_view( # pylint: disable=invalid-name
openapi.Info(
@@ -68,3 +69,4 @@ urlpatterns = [
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+ urlpatterns += staticfiles_urlpatterns() I was able to get the swagger ui working. But that's not an appropriate solution for production, so we'd need to do something more along the lines of the link above (s3?) |
A quick remark @psschwei gateway > main > settings.py CSP_DEFAULT_SRC = "'none'"
CSP_SCRIPT_SRC = "'none'"
CSP_FRAME_ANCESTORS = "'self'"
CSP_OBJECT_SRC = "'self'"
CSP_IMG_SRC = ("'self'", "data:", "https://cdn.redoc.ly")
CSP_STYLE_SRC_ELEM = ("'self'", "'unsafe-inline'")
CSP_SCRIPT_SRC_ELEM = "'self'"
CSP_CONNECT_SRC = "'self'"
CSP_WORKER_SRC = ("'self'", "blob:") |
Thanks @david-alber -- I tried those, but they didn't solve the issue on Kubernetes (which seems to be an issue with the availability of the |
I proceed to merge it then 😄 Thanks @david-alber for your help here! |
@psschwei Would you open a new issue? I would like to take a look at it. Thanks! |
This was fun, as always. Thanks y'all for the support and guidance 🙏 ❤️ . |
Summary
Closes #1165
Adding swagger and openapi documentation to gateway.
The UI documentation is available via
<host>:<gateway-port>/swagger/
or<host>:<gateway-port>/redoc/
JSON, and YAML is available via
<host>:<gateway-port>/swagger.yaml
or<host>:<gateway-port>/swagger.json
Details and comments
The API documentation is publically available to any user: No authorization or login is required.