-
Notifications
You must be signed in to change notification settings - Fork 94
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
Api on the fly - GraphQL schema #3469
Conversation
Looks good so far @oliver-sanders 👍 |
Thanks for logging it over, will clean up and submit. |
ef1e2ba
to
08bea55
Compare
@dwsutherland the last commit is a little more aggressive, aimed at making the mutations better match the CLI e.g. by merging the various broadcast methods. Also copied some docs over from the CLI. |
08bea55
to
11247e6
Compare
I've introduced new "input types" which are more declarative about the meaning of certain types i.e. cycle point is now a special field not just a string (well its still a string underneath but now it's called a cycle point). I've used these as inputs (i.e. arguments to mutators) but haven't gone the whole hog and used them for outputs (i.e. data type returned by GraphQL query/subscription) as this would be a little more destructive, work for later perhaps. |
Looks good to me.
Yes, there's definitely more we could do:
Happy to approve once tests and end-to-end Cylc is working. |
a03d42a
to
34b7a04
Compare
ad21693
to
e060d12
Compare
3ec35ff
to
cd200bf
Compare
* collect stop, hold, broadcast * use enumerations where appropriate * route GQL mutations via the traditional endpoints this is a temporary interface for simplicity it can be torn down later
cd200bf
to
f90d4dd
Compare
Okay, should be good to go... |
8b17d56
to
5ee4c55
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.
Tested and working! GraphiQL via UIS works, didn't try all the mutations, but a few 👍
For me this is pretty much good to go, although I would like to hear your rationale on using server endpoints/methods bound for deprecation in your mapping to internal commands by the GraphQL end-point.
|
Not really sure what you mean here... There is one set with or without this method of mapping hitting them twice before going to the internal commands..
So it's a temporary measure to avoid the lack of fine-grained authorisation (because the graphql endpoint does have authorisation, but will be in the form of middleware at some point presumably) in the current I agree, it's definitely a more obvious guide of how to rewrite the internal Scheduler commands. Ok.. satisfied. |
Sorry I should have explained at the outset, this is not how I think it should be done! Just didn't have the guts to go whole hog in this PR. |
You use So it gives no extra authorisation, anyway? |
Not authentication, authorisation. Each of the server endpoints are protected by an authorisation method which provides fine-ish-grained-authorisation. This is the vestigial remains of the old Cylc7 system, it's effectively inactive as at the moment we always assume an authenticated user is the suite owner but anyway. I'm not fussed about the server interface (as it's going to get torn up anyway), just don't want to re-write it in this PR because it's a blocker to aotf and the alpha2 release. |
* this client-side logic doesn't fit into aoft very nicely * will require a bespoke solution later, perhaps an interface?
5ee4c55
to
29a1775
Compare
FYI the codacy error is kinda un-avoidable* as the function is now tethered to the mutation interface so the argument names must match. The |
Yes, corrected that ☝️
Roger that. |
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.
Happy to move forward, and merge this once Travis CI passes (queries have been answered).
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.
A few docstrings need updating, but no blocker, can be done in this PR or later.
@oliver-sanders thanks for the new comments, that'll be very helpful when working on the UI too.
I think this can close #3340 ? WDYT?
@oliver-sanders I also tested it with the following setup:
- Install this PR in a venv
cd ../cylc-uiserver && pip install -e .
thencd -; pip install -e.
(i.e. install Cylc UI Server and re-install cylc-flow from this branch)- Copied
jupyterhub_config.py
and changed static files location jupyterhub
- Launched suite
five
- Executed the following mutation:
mutation {
stop(workflows: ["five"]) {
result
}
}
- The suite did not stop, and also got the following exception in the terminal:
2020-01-29 16:42:59,644 tornado.application ERROR Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7fb3a2cedfd0>>, <Task finished coro=<WorkflowsManager.gather_workflows() done, defined at /home/kinow/Development/python/workspace/cylc-uiserver/cylc/uiserver/workflows_mgr.py:112> exception=KeyError('CYLC_SUITE_PUBLISH_PORT')>)
Traceback (most recent call last):
File "/home/kinow/Development/python/workspace/cylc-flow/venv/lib/python3.7/site-packages/tornado/ioloop.py", line 743, in _run_callback
ret = callback()
File "/home/kinow/Development/python/workspace/cylc-flow/venv/lib/python3.7/site-packages/tornado/ioloop.py", line 767, in _discard_future_result
future.result()
File "/home/kinow/Development/python/workspace/cylc-uiserver/cylc/uiserver/workflows_mgr.py", line 125, in gather_workflows
for arg in scan_args:
File "/home/kinow/Development/python/workspace/cylc-uiserver/cylc/uiserver/workflows_mgr.py", line 117, in <genexpr>
(reg, host, port, pub_port, self.context, CLIENT_TIMEOUT)
File "/home/kinow/Development/python/workspace/cylc-flow/cylc/flow/network/scan.py", line 283, in get_scan_items_from_fs
contact_data[ContactFileFields.PUBLISH_PORT],
KeyError: 'CYLC_SUITE_PUBLISH_PORT'
Is that expected? Maybe I have something wrong with my setup, or forgot to do something? Just let me know and I'll approve if there's nothing wrong here 👍 everything else looks good.
Thanks
no_check=False | ||
check_point=True |
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.
Good one!
@@ -858,12 +921,12 @@ def put_broadcast( | |||
|
|||
@authorise(Priv.CONTROL) | |||
@expose | |||
def put_ext_trigger(self, event_message, event_id): | |||
def put_ext_trigger(self, message, id): |
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.
id
is also a built-in, but I think it's harmless here.
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.
So the function signature is bound to the mutation interface. The mutation has an argument called id
so the method must have one too.
We can use a **kwargs
hack here but as you say it's harmless.
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.
Codacy has flagged this as an error, "redefining a built-in". I suppose we should really change the mutation interface as well. (Can be a follow-up though).
3ffcd63
to
b961362
Compare
Here is an overview of what got changed by this pull request: Issues
======
- Added 1
See the complete overview on Codacy |
Still have a few unchecked requirements in the description above. E.g. test coverage? |
Not so sure what to do about test coverage. We would need to duplicate every existing cylc subcommand test. Once the CLI is migrated it will be covered by existing tests... |
OK that's fine. |
So if @kinow approves now, we can merge this. |
Addresses the data-provision component of #2123
Not ready for review, putting this up early as it effects downstream activities.
Improve the GraphQL schema so that it contains all of the information required to auto-generate interfaces (e.g. HTML forms or CLI option parsers).
TaskActions
mutation into separate mutations:hold_*
,release_*
,broadcast_*
andstop_*
methodsThis PR pushes mutations through the same
cylc.flow.network.server.SuiteRuntimeServer
interface as the CLI currently uses. This is temporary, hence the docstrings have been left unchanged, this interface will be removed partially/entirely when the CLI is migrated to use the mutations interface.Example Mutation:
Caveats:
TODO:
Testing.Mutation testing will come for free once the CLI is converted, replicating these tests will be a lot of work.Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.