-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Formally describe command args and results #58
Comments
This issue has been mentioned on Jupyter Community Forum. There might be relevant details there: |
I think this proposal could benefit from some use cases as examples. It would help clarify the benefit, and would make it easier to reason about the pros and cons of the proposal. |
The description of command results can be tricky as some commands are expected to output a JavaScript object; most notably a new widget. |
Commands are critical to the interaction between many parts of a lumino app, yet are very loosely-typed, and generally opaque to implementers and users. This limits the discovery, effective user interface, and reusability of commands. While these problems are likely unsolveable at compile time, runtime validation and discovery would improve all of these for the user of a lumino application, with minimal effort to implementers.
Individual issues and PRs
describedBy
to command #322describedBy
to be an async function #331Current Challenges
Discovery
At present, commands are difficult to discover. Yes, one can
listCommands
to get their ids, and then iterate over all of their option values, and try calling them.When commands are further abstracted, it becomes basically impossible to determine whether a command execution will be well-formed, and what is just nonsense that will fail in a fully-spun-up application.
User Interface
From the application perspective, commands are fire-and-forget, delegating the responsibility to individual implementations. Many commands would benefit from even minimal UI to modify their behavior, and could be, by default, presented in a single, consistent way vs some commands "just working", some opening dialogs, and other unpredictable/inconsistently accessible things that can occur.
Payoff
With well-typed and documented commands, it becomes possible to generate machine-readable representations of possible command states (to-be-executed, was-executed, etc). A command palette, thus enhanced, could provide significant value.
Additionally, with discoverable commands, hybrid gui/cli applications, a la clui become possible.
Finally, the ability to understand each command's arguments and result make it possible to serialize longer chains of commands that reference each other's output:
DockPanel
's layout serialization represents this in one, particular way, but more generalized approaches could truly make lumino an engine for lisp machine/smalltalk-style self-extensibility and introspection.Out of scope
Selecting the validation description itself is probably neither viable nor useful: there still exists no standards-body adopted description-of-JSON-in-JSON, much less one implemented in browsers. While JSON Schema is the de facto representation, with
ajv
the de facto browser validator, it's worth exploring other options... once we have something that can accept any of it, with the usual caveats of performance, security, stability, and cross-language compatibility.Proposal
I don't think any of these would require breaking changes, but it may be worth targeting/tabling this work until such a time as it would make sense. At any rate, I would be able to commit to implementing these feature, just not on what timeline.
@lumino/coreutils
JSONValidationExt
IValidator
which defines a minimal validation scheme, e.g.validate(schema, instance) => Promise<any[]>
(suitably genericized)@lumino/commands
CommandRegistry.IOptions
validator
to avalidate: {args: true, result: false}
describedby
toICommandOptions
which returns (a promise to) a schema forargs
result
(if it even makes sense to validate outputs, as many are "fat" objects, e.g.Widget
)@lumino/application
validator
toApplication.IOptions
(new)@lumino/commandpalette
renderArgs
toIRenderer
examples
Follow-On
package.json
field, e.g.{"lumino": {"commands": {}}
which would make available commands truly discoverable.metadata
field ondescribedby
could allow for application/implementation specific options, such as rjsf'suiSchema
.References
Downstreams:
The text was updated successfully, but these errors were encountered: