-
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
Suite API - On-The-Fly #2123
Comments
I just had a play with Ben's original branch from #2020 - it would be good to get onto this soon... |
Following up on #2020 (comment)
For suite commands the API now rests (pun intended) with the comms layer rather than the CLI. Consequently the CLI scripts for suite commands should now just be nothing more than simple API wrappers doing the following:
This same functionality is also desired of the comms layer. To me it makes sense to move all of this functionality into the comms layer so that it is in one place where it can be re-used for both the CLI and HTTP(S) APIs. If we write the method docstrings in a standard format [1, 2] then they could be parsed by a system like sphinx+napoleon [3]. From this information we should be able to:
In the long run auto-generated HTTP forms could be used by future web-based GUIs which should make progress faster. Doing this would remove the risk of:
All three of these points have spawned bugs since cylc7. I think most of this can be achieved using docstrings in the comms layer (to define arguments and types as implemented in #2020). @cylc/core your thoughts on this. [1] http://google.github.io/styleguide/pyguide.html |
@oliver-sanders - thanks for that, sounds brilliant. |
This change could be made in combination with a shift to graphql which provides a flexible deprecation friendly way to define a communication interface. |
Spent some time today reading this and the two related pull requests. Looks like the changes for the CLI will bring many benefits, such as simpler interface, parameter type check and casting, etc. I am not too sure about the HTML and Web layer. For that layer, there are already a few tools that do that, the most famous being Swagger, now OpenAPI. Not sure if applicable here, or if I haven't understood the scope of this proposal. But if we are going to define the data type used for communication, in a way that forms can be generated to query that, and also as a tool to document the API for clients, then I think it would be best to write the minimum code possible for that. The Swagger/OpenAPI Petstore has become the de-facto HTML automatic form generator for the specs, used too by JupyterHub, and JS developers should be familiar with that I think. I haven't looked how JupyterHub devs do it, but I suspect they sync changes manually, which could lead to errors. zalando/connexion not only uses the OpenAPI spec, but also validates the exposed Flask endpoints against the specification. So if your server code gets out of sync with the API spec, the server fails to initialize. I haven't used it with GraphQL, but looks like there was some work to support it already. RPC appears to be an ongoing discussion since 2016, without an official solution, but with some people implementing their own version. And looks like some people have already shared some ZMQ/Protobuf endpoints documented with OpenAPI, so that should be doable. There's also an OpenAPI sphinx library, which could be used to generate the sphinx documentation (never tested that tho). Sorry if what I said is out of context here. Cheers |
GUI component completed, CLI component less urgent, bumping the remainder of this issue to 8.x or beyond. |
Automatically generate user interfaces based on the GraphQL API:
Self Documenting Comms Layer
#2020 Introduced a new way to access the cylc "suite API".
With the command line the network steps currently are:
Whereas the HTML API in #2020 works somewhat differently:
The subtle difference is that the user is in effect requesting the API from the suite rather than using the API as it is known to the cylc command. This reflects the way that a cylc suite can now be though of as a web service (as of #1923). This isolates the suite API from the particular cylc version employed by the user improving robustness.
The Proposal
The proposal is that the command line API be re-written to follow the pattern of the HTML API. The commands to which this proposal applies are those involved in user - suite interaction (i.e.
cylc help control
plusshow
,dump
,get-suite-version
, ...), system commands (i.e.cylc help task
minussubmit
) would not be included in this change (although the command line interface could still be auto-generated [non-runtime] from the comms layer).Advantages:
Disadvantages:
cylc help preparation
), will stay as they are meaning that the suite API is implemented separately to the remainder of the cylc API.Philosophy
Since #1923 the "suite interface" has effectively moved from the command line into the network layer. Suite commands are now more-or-less simple bash scripts which effectively serve as wrappers for the comms layer. At present the "interface" is defined by the arguments/options defined by the bash scripts, with the addition of the HTML API it would make sense to move this "interface" into the comms layer where it could be written in a more abstract form - for example as a docstring:
This interface could then be used to build the command line / HTML APIs on-the-fly.
The information in the interface should be sufficient to perform basic user-side verification (i.e. JavaScript form validation for the HTML API, error message for the command line API), but should also be sufficient to "cast" arguments as they arrive server side (i.e. no more nasty
setting in [True, 'True']
statements).Client side mechanics:
Suite side mechanics:
See #423, #2020 and #1980.
The text was updated successfully, but these errors were encountered: