-
Notifications
You must be signed in to change notification settings - Fork 18
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 subscriptions #82
Conversation
Work in progress, will start adding now the code to have subscriptions. But this was what was more obvious to me that was necessary for this change. More to come in the next days 👍 |
Codecov Report
@@ Coverage Diff @@
## master #82 +/- ##
==========================================
+ Coverage 48.81% 52.45% +3.64%
==========================================
Files 6 6
Lines 338 366 +28
Branches 57 57
==========================================
+ Hits 165 192 +27
- Misses 170 171 +1
Partials 3 3
Continue to review full report at Codecov.
|
a5a89df
to
bdef1dc
Compare
I think we can add the UIS Subscriptions machinery (modules, endpoints ...etc) to this PR (like you have), but develop the GraphQL schema in This way we design it, from the beginning, to be able to plug into either |
Oh that's helpful. I saw you define resolvers in cylc flow, then extend it here and add only the specific for uiserver. Clever. So this ia pretty much it for uiserver for now? We leave it like this and now start working on chema changes in cylc flow?? |
|
I think so, once you have this one working locally with the simple case in |
@dwsutherland I've added the template to render websocket subscriptions in GraphiQL. Moved everything websockets related under the The UI is still working, tested with a running workflow. Then going to subscription {
workflows {
id
}
} I can see that the message was submitted to the backend, parsed, interpreted, and rejected because the schema is not ready to handle it yet. I think we are done here for now. And now the only missing parts are in the cylc-flow repository. What do you think @dwsutherland ? |
Yes, although perhaps we could leave this one open until we have put a minimal Subscription into |
Yup, I'm planning to mark it ready for review once we get at least one subscription working, so that we can test it from point (ui + hub) to point (cylc-flow with running workflow data). |
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.
@dwsutherland this one won't change much for now. I've added some comments to the code to help reviewers 👍
@@ -24,7 +24,7 @@ python: 3.7 | |||
|
|||
before_install: | |||
- pip install pycodestyle | |||
- pycodestyle --exclude=".git,.tox,__pycache,venv,.eggs,build,jupyterhub_config.py" | |||
- pycodestyle --exclude=".git,.tox,__pycache,venv,.eggs,build,jupyterhub_config.py,cylc/uiserver/websockets/" |
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.
This is due to the graphene-tornado
class that we copied from an open PR. Mainly due to line number that is greater than 80 there 👍 so we need to ignore that for now.
@@ -145,9 +150,58 @@ def prepare(self): | |||
super().prepare() | |||
|
|||
|
|||
class SubscriptionHandler(websocket.WebSocketHandler): |
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.
Note: copied from the PR's example.
return wider_context | ||
|
||
|
||
class GraphiQLHandler(UIServerGraphQLHandler): |
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.
From the PR's example. This handler renders a custom React app that talks WebSockets. So that the query is reloaded automatically 👍
from string import Template | ||
|
||
|
||
def render_graphiql(base_url: str) -> str: |
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.
From the PR's example.
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.
Modified to create the WebSocket subscription URL using JS for hostname and port, and Python for the base URL.
setup_observable_extension() | ||
|
||
|
||
class TornadoConnectionContext(BaseConnectionContext): |
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.
From the PR's example, with one modification.
06dd5f1
to
fe5af34
Compare
Added some unit tests. Should be ready for review now. |
5f34fca
to
92fb33f
Compare
Juts added a new commit with the changelog. |
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.
LGTM 👍 .. Worked locally ( I don't think this breaks existing functionality )
Oh, got one conflict in the handlers, will fix it in a few minutes 👍 |
92fb33f
to
d9bd127
Compare
I think I found one possible solution. A mix of more JS, and just a little Python. We still replace the The WebSocket client is created on the client-side, so it should be safe to ignore JupyterHub configurations like Test with default port 8000 after running Then the result after running |
ef7a6f1
to
be86139
Compare
Rebased and conflicts fixed. |
Naming it graphql_ws or tornado could cause issues loading Python code.
…ow in our project)
be86139
to
86fc8a8
Compare
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.
LGTM 👍
Closes #14
graphql-ws
)asyncio.sleep
ing for a few seconds, then sending more data. This can be improved later to send data only when there is data available, but this will be an improvement for later.Sibling PRs: