-
Notifications
You must be signed in to change notification settings - Fork 323
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
IDE uses new visualization API #3661
Conversation
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.
#3655 needs an ability to invoke the Enso part of the visualization with arguments. How can one do that with setPreprocessor(module, method)
?
port. In case it is not connected, the visualization becomes an interactive | ||
widget allowing the user to specify data. For example, a map visualization | ||
will allow the user to manually pick locations. After each change, the new | ||
locations will be sent to the output port. Under the hood, widgets are |
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.
That almost sounds like "dynamic widgets" to me!
data to visualization. If not called, a default unspecified code is used | ||
- #### Method `setPreprocessor(module,method)` | ||
Set an Enso method which will be evaluated on the server-side before sending | ||
data to visualization. If not called, a default unspecified method is used |
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.
default unspecified? That's a strange formulation in a specification of the behavior ;-)
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.
Why? Specification explicitly opts-out from defining this.
There'll be some code present, but custom visualization should not make any assumptions about it. Thanks to that, we can adjust it without breaking public API.
where visualization is defined - you may use any symbol defined or imported in | ||
that module. | ||
The code will be evaluated in the context of the module where the preprocessor | ||
method is defined - you may use any symbol defined or imported in that module. |
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.
How can one pass arguments to the method? #3655 needs to be able to invoke the Enso engine part of the visualization with different arguments.
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'd expect that arguments are part of the expression, as the arguments change we update the expression.
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.
Ah, it was removed. Then some mechanism for arguments is necessary,
Co-authored-by: Jaroslav Tulach <[email protected]>
app/gui/controller/engine-protocol/src/language_server/types.rs
Outdated
Show resolved
Hide resolved
* When visualization is attached to a node, each time a new value is produced from node, | ||
* the preprocessor shall be invoked with it. Result such call shall be serialized and | ||
* transported to visualization by invoking onDataReceived(data) method. |
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 miss such detailed documentation in the new version.
We have a special documentation page for contributors wanting to create new visualizations, and these docs AFAIK refers to this file for specific documentation of JS methods they can use inside their visualizations.
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 updated the doc with more details and examples. Should be better now
where visualization is defined - you may use any symbol defined or imported in | ||
that module. | ||
The code will be evaluated in the context of the module where the preprocessor | ||
method is defined - you may use any symbol defined or imported in that module. |
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.
Ah, it was removed. Then some mechanism for arguments is necessary,
@@ -44,7 +43,7 @@ class Histogram extends Visualization { | |||
|
|||
constructor(data) { | |||
super(data) | |||
this.setPreprocessor('process_to_json_text', 'Standard.Visualization.Histogram') | |||
this.setPreprocessor('Standard.Visualization.Histogram', 'process_to_json_text') |
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.
Is there any reason to revert the order of arguments?
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 like it more. Imagine calling a method by a fully qualified name Foo.Bar.Baz.quux a b c
. The setPreprocessor
method just splits the call into three sections (arguments are optional in this case)
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.
Please double-check that all calls to this have been update. This is a change that can easily cause issues as the arguments have the same type and this will only fail at runtime.
app/gui/view/graph-editor/src/builtin/visualization/java_script/scatterPlot.js
Outdated
Show resolved
Hide resolved
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.
Thanks. This should be good enough for the scatterplot visualization.
setArguments(...args) { | ||
if (args !== this.__preprocessorArguments__) { | ||
this.__preprocessorArguments__ = args | ||
this.__emitPreprocessorChange__() |
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.
Ideally changing only the setArguments
shall be a lightweight operation. Something that invokes already existing code on the engine side, without re-parsing the code. But I guess this is provided by definition when using method pointers...
@@ -2198,7 +2204,176 @@ class RuntimeVisualizationsTest | |||
"Enso_Test.Test.Visualisation", | |||
"Enso_Test.Test.Visualisation", | |||
"incAndEncode" | |||
), | |||
Vector("2", "3") |
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.
What other types are supported? Text
? Booleans True
, False
? Complex atoms? Function invocations?
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.
An argument can be an arbitrary Enso expression that can be interpreted in the context of the visualization module
@@ -94,6 +75,7 @@ pub enum Notification { | |||
|
|||
/// Describes the state of the visualization on the Language Server. | |||
#[derive(Clone, Debug, PartialEq)] | |||
#[allow(clippy::large_enum_variant)] |
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.
Clippy complains about the size of enum variant. I though that it is safe to ignore because most of the variants have comparable sizes (the size of Visualization
struct). And the variant having two Visualization
fields is the one that Clippy complains about.
@@ -44,7 +43,7 @@ class Histogram extends Visualization { | |||
|
|||
constructor(data) { | |||
super(data) | |||
this.setPreprocessor('process_to_json_text', 'Standard.Visualization.Histogram') | |||
this.setPreprocessor('Standard.Visualization.Histogram', 'process_to_json_text') |
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.
Please double-check that all calls to this have been update. This is a change that can easily cause issues as the arguments have the same type and this will only fail at runtime.
I'm pretty sure I updated all of them. Unless grep failed me 😅 |
Pull Request Description
PR integrates new visualization API that uses method pointers instead of lambdas as visualization expressions.
Important Notes
Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.