-
Notifications
You must be signed in to change notification settings - Fork 27
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 #280
Add subscriptions #280
Conversation
e9f9e43
to
4489d20
Compare
Codecov Report
@@ Coverage Diff @@
## master #280 +/- ##
==========================================
+ Coverage 66.75% 68.28% +1.52%
==========================================
Files 24 16 -8
Lines 361 227 -134
Branches 20 0 -20
==========================================
- Hits 241 155 -86
+ Misses 113 72 -41
+ Partials 7 0 -7
Continue to review full report at Codecov.
|
Build is passing, tests passing fine. Spent most of the morning working around dependencies that needed to be imported or removed, then rest of morning and part of afternoon fixing tests. Now the application is loading fine, but the Not sure why. Could be because we are using the |
Oh, actually solved the problem. I think it's about 90% done now. The first issue was that I had to use The second issue was that looks like the Both fixed, now needs just a modification in the |
Apparently done. Happy to take any reviews now, but can't remove the Draft mark, as this PR if merged without the WebSockets on the backend, it would break Cylc UI. For me it looks much faster now with WebSockets, and the application is more interactive for users. So if curious, have a try. Hopefully it will work well as long as the other 2 PR's for backend are checked out and built in a venv 🤞 |
"apollo-client": "^2.6.4", | ||
"apollo-link": "^1.2.13", | ||
"apollo-link-http": "^1.5.16", | ||
"apollo-link-ws": "^1.0.19", |
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.
These were dependencies of ApolloBoost, a helper that simplifies creating Apollo clients. However, when you provide a link that can handle both HTTP and WebSocket, ApolloBoost ignores it and unless you provide a URI, it will create and use an HTTP Link, simply ignoring the WebSocket.
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.
Where it shows that ApolloBoost is not compatible with WebSockets. Hence the removal, and the need to add these dependencies.
"axios": "^0.19.0", | ||
"babel-eslint": "^10.0.3", | ||
"chai": "^4.2.0", | ||
"cross-env": "^5.2.0", | ||
"cross-fetch": "^3.0.4", |
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.
We were using the node-fetch for tests, but it didn't work after removing the default ApolloClient (which would prevent Apollo and its libraries of trying to validate that the fetch global existed. This polyfill provides the global fetch for tests.
src/services/workflow.service.js
Outdated
|
||
export { workflowService } | ||
export { LiveWorkflowService, SubscriptionWorkflowService } |
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.
We were exporting a singleton, that once imported would exist for the whole app.
Now we export classes, let users decide whatever they want to do with these (mock, test, extend, instantiate, create a singleton, etc).
Vue has a way to create application globals via Vue.prototype.$applicationSingleton
, which has effectively the same result as exporting a singleton, with more flexibility if necessary.
Plus, it will be available to the whole application as this.$workflowService
. The $
is per convention.
ps: must be used with care this global objects in Vue, as they docs state
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.
Can we get rid of the LiveWorkflowService
now?
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.
I can't recall why I left. Not sure if it was still being used for testing/mocking, or if I was scared that the WebSockets could fail and we would have to revert to the old service 😄 will take another look to confirm.
src/utils/graphql.js
Outdated
operation.setContext({ | ||
headers: { | ||
// FIXME: this is the random generated password, update every time it is generated for now! | ||
Authorization: 'Basic Y3lsYzpiaFRTbnRpWjRqR2YzSWR3eTlVMg==' |
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 old prototype, I suspect the PR for Cylc UI Server auth may require something like this, but we can cross that bridge when time comes, no need to leave an old Cylc Suite passphrase hard-coded here.
} | ||
}) : new ApolloLink() // return an empty link, useful for testing | ||
|
||
const link = split( |
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.
Think of split
as a ternary ?
operator. Given a condition, return either the next value, or the subsequent.
5cfdef1
to
806afff
Compare
Updated with one more commit for changelog. |
806afff
to
9494c90
Compare
@@ -24,9 +24,12 @@ workflows only. | |||
[#283](https://github.com/cylc/cylc-ui/pull/283) - Load user information | |||
on application startup. | |||
|
|||
[#283](https://github.com/cylc/cylc-ui/pull/285) - Update Vuetify to 2.1, | |||
[#285](https://github.com/cylc/cylc-ui/pull/285) - Update Vuetify to 2.1, |
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.
Oops.
Rebased, fixed conflicts, and added one small fix during rebase for the changelog entry of #285 (mea culpa). |
And fixed something I hadn't tested. I tested the subscriptions with live data. But after rebasing tried the Now, instead, we export everything as before, plus an In other words, user/caller can use whatever name s/he wants, as the module/callee is exporting a default implementation. Tested both just now after pushing the last changes 👍 |
Huh, I thought it was ready after the PR's of David, but this actually is waiting on another PR of cylc-uiserver: cylc/cylc-uiserver#82 |
Merged 😉 (cylc/cylc-uiserver#82) |
I'm syncing all branches, will do a quick smoke test with this PR again. If everything works fine, will change it to ready for review. Thanks @hjoliver ! |
Re-creating the virtual environments after syncing the repositories, got the following dependency error.
It looks to me like there is a typo in the dependency requirement of |
PR submitted graphql-python/graphql-ws#39 |
1bc12af
to
54a2f1d
Compare
Rebased, fixed conflicts, updated the other components & views (graph & gscan were updated after this PR was created). Also tested with no workflows, with Found one problem. Independent of the running of running workflows. I had just Looks like there are two messages received at the same time. My suspicion is that The |
Ok, just finished with unit tests, and also some quick tests. Tomorrow will test it again with NIWA's notebook after re-creating the whole environment, and if it works there too, it will be ready for review. |
(One problem was that it had two queries, as I didn't call |
Apparently working OK on both my work & home environments. Used two workflows to test it. Found only one browser console message, but that it related to the workflow data structure returned, and how we are accessing attributes and creating the hierarchy (i.e. not related to this issue). So ready for review. Please, remember that it is required to use the latest Cylc UI Server, which should also install the latest Cylc Flow (or install manually if you prefer to avoid the local cache). Thanks |
…instead of exporting a singleton
8dca002
to
e318e3a
Compare
If GitHub action passes, then this PR is ready for review. Everything worked locally, tested with 2 workflows, also tested mutations. The toolbar buttons are a bit buggy at the moment, some times changing the enable/disable attribute incorrectly. But that is for another ticket. |
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 a functional stand-point this PR is ready to go IMO! 👍
(any further improvements can probably be separate PRs)
Thanks @dwsutherland ! |
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.
Closes #207
Closes #266 (noticed this while testing this PR, will add a comment where it fixes this issue)
This pull request adds subscriptions to Cylc UI. The
ApolloClient
has a feature called link, which defines the transport link. It can be an HTTP link, a WebSockets Link, a mocked link, or whatever transport link you need to transport the data.We were using only an
HTTPLink
in theApolloClient
. Now the link is actually asplit
function (fromapollo-link
module).This function acts as a ternary operator, and will decide based on the query definition which link to use. If the query definition specifies it is a subscription, it will use a
WebSocketLink
(from new package added in this PRapollo-link-ws
), otherwise it will use the existingApolloLink
(fromapollo-link-http
).Unit tests passing on my environment, managed to fix IDE issues, now it is only missing to make it work with live workflow.
Sibling PRs: