Skip to content
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

Engine should send notification about node status #3729

Merged
merged 23 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
76b5a89
Collect invalidated cached nodes and tell IDE about them
JaroslavTulach Sep 22, 2022
7a7c11d
Deliver Pending even to the IDE
JaroslavTulach Sep 22, 2022
aedd98e
Some tests may ignore expression update messages
JaroslavTulach Sep 23, 2022
ee488ae
Make sure setExpressionUnsync is called all the time
JaroslavTulach Sep 23, 2022
2c7652d
notifyPendingCacheItems in ProgramExecutionSupport before executionSe…
JaroslavTulach Sep 26, 2022
c471606
Merging with develop branch
JaroslavTulach Sep 26, 2022
91d37d4
Down to just 20 Runtime*Test failures
JaroslavTulach Sep 26, 2022
33b6f47
RuntimeErrorsTest passes OK
JaroslavTulach Sep 26, 2022
eb6e55d
RuntimeVisualizationsTest passes OK
JaroslavTulach Sep 27, 2022
8e056c6
IncrementalUpdatesTest passes OK
JaroslavTulach Sep 27, 2022
42bc4c9
BuiltinTypesTest passes OK
JaroslavTulach Sep 27, 2022
83cec5c
Just five failing tests in RuntimeServerTest
JaroslavTulach Sep 27, 2022
195ca33
Give important metadata items recognizable UUIDs
JaroslavTulach Sep 27, 2022
228567e
RuntimeServerTest passes OK
JaroslavTulach Sep 27, 2022
b1631e6
All runtime-with-instruments tests are fixed
JaroslavTulach Sep 27, 2022
c4e818a
misc: no collection converters
4e6 Sep 27, 2022
ffd0384
Documenting the protocol change
JaroslavTulach Sep 27, 2022
875ee4d
Applying sbt scalafmtAll
JaroslavTulach Sep 27, 2022
0ec1a2f
Merging with Dmitry's changes
JaroslavTulach Sep 27, 2022
f358d8f
Fixing typos in the documentation
JaroslavTulach Sep 27, 2022
a847e25
Merge with develop branch and Marcin's statics
JaroslavTulach Sep 28, 2022
134909a
Better syntax and formatting for the Rust files
JaroslavTulach Sep 28, 2022
a1165aa
Disabling the IDE rendering changes
JaroslavTulach Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
- [main = "Hello World!" is valid Enso sample][3696]
- [Invalidate module's IR cache if imported module changed][3703]
- [Don't rename imported Main module that only imports names][3710]
- [Notify node status to the IDE][3729]

[3227]: https://github.com/enso-org/enso/pull/3227
[3248]: https://github.com/enso-org/enso/pull/3248
Expand Down Expand Up @@ -414,8 +415,9 @@
[3658]: https://github.com/enso-org/enso/pull/3658
[3671]: https://github.com/enso-org/enso/pull/3671
[3696]: https://github.com/enso-org/enso/pull/3696
[3696]: https://github.com/enso-org/enso/pull/3703
[3696]: https://github.com/enso-org/enso/pull/3710
[3703]: https://github.com/enso-org/enso/pull/3703
[3710]: https://github.com/enso-org/enso/pull/3710
[3729]: https://github.com/enso-org/enso/pull/3729

# Enso 2.0.0-alpha.18 (2021-10-12)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ pub enum ExpressionUpdatePayload {
message: String,
trace: Vec<ExpressionId>,
},
#[serde(rename_all = "camelCase")]
Pending {
message: Option<String>,
progress:Option<f64>,
},
}


Expand Down
7 changes: 4 additions & 3 deletions app/gui/src/presenter/graph/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl Expressions {
///
/// This structure keeps the information how the particular graph elements received from controllers
/// are represented in the view. It also handles updates from the controllers and
/// the view in `update_from_controller` and `update_from_view` respectively.
/// the view in `update_from_controller` and `update_from_view` respectively.
#[derive(Clone, Debug, Default)]
pub struct State {
nodes: RefCell<Nodes>,
Expand Down Expand Up @@ -492,6 +492,7 @@ impl<'a> ControllerChange<'a> {
None | Some(Value) => None,
Some(DataflowError { trace }) => Some((Kind::Dataflow, None, trace)),
Some(Panic { message, trace }) => Some((Kind::Panic, Some(message), trace)),
Some(Pending { message: _, progress: _ }) => Some((Kind::Panic, Some("Pending...".to_string()), Vec::new())),
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
}?;
let propagated = if kind == Kind::Panic {
let nodes = self.nodes.borrow();
Expand Down Expand Up @@ -678,15 +679,15 @@ impl<'a> ViewChange<'a> {

impl<'a> ViewChange<'a> {
/// If the connections does not already exist, it is created and corresponding to-be-created
/// Ast connection is returned.
/// Ast connection is returned.
pub fn create_connection(&self, connection: view::graph_editor::Edge) -> Option<AstConnection> {
let source = connection.source()?;
let target = connection.target()?;
self.create_connection_from_endpoints(connection.id(), source, target)
}

/// If the connections with provided endpoints does not already exist, it is created and
/// corresponding to-be-created Ast connection is returned.
/// corresponding to-be-created Ast connection is returned.
pub fn create_connection_from_endpoints(
&self,
connection: ViewConnection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ final class ContextEventsListener(
case Api.ExpressionUpdate.Payload.Value() =>
ContextRegistryProtocol.ExpressionUpdate.Payload.Value

case Api.ExpressionUpdate.Payload.Pending(m, p) =>
ContextRegistryProtocol.ExpressionUpdate.Payload.Pending(m, p)

case Api.ExpressionUpdate.Payload.DataflowError(trace) =>
ContextRegistryProtocol.ExpressionUpdate.Payload.DataflowError(trace)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ object ContextRegistryProtocol {
/** An information about computed expression. */
case object Value extends Payload

case class Pending(message: Option[String], progress: Option[Double])
extends Payload;

/** Indicates that the expression was computed to an error.
*
* @param trace the list of expressions leading to the root error.
Expand All @@ -186,6 +189,8 @@ object ContextRegistryProtocol {

val Value = "Value"

val Pending = "Pending"

val DataflowError = "DataflowError"

val Panic = "Panic"
Expand All @@ -210,6 +215,13 @@ object ContextRegistryProtocol {
.deepMerge(
Json.obj(CodecField.Type -> PayloadType.Panic.asJson)
)

case m: Payload.Pending =>
Encoder[Payload.Pending]
.apply(m)
.deepMerge(
Json.obj(CodecField.Type -> PayloadType.Pending.asJson)
)
}

implicit val decoder: Decoder[Payload] =
Expand All @@ -223,6 +235,9 @@ object ContextRegistryProtocol {

case PayloadType.Panic =>
Decoder[Payload.Panic].tryDecode(cursor)

case PayloadType.Pending =>
Decoder[Payload.Pending].tryDecode(cursor)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ object Runtime {
new JsonSubTypes.Type(
value = classOf[Payload.Panic],
name = "expressionUpdatePayloadPanic"
),
new JsonSubTypes.Type(
value = classOf[Payload.Pending],
name = "expressionUpdatePayloadPending"
)
)
)
Expand All @@ -378,6 +382,11 @@ object Runtime {
*/
case class Value() extends Payload

/** TBD
*/
case class Pending(message: Option[String], progress: Option[Double])
extends Payload;

/** Indicates that the expression was computed to an error.
*
* @param trace the list of expressions leading to the root error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ private void onExpressionReturn(Object result, Node node, EventContext context)
ExpressionValue expressionValue =
new ExpressionValue(
nodeId, result, resultType, cachedType, call, cachedCall, profilingInfo, false);
if (expressionValue.isTypeChanged() || expressionValue.isFunctionCallChanged()) {
syncState.setExpressionUnsync(nodeId);
}
syncState.setExpressionUnsync(nodeId);
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
syncState.setVisualisationUnsync(nodeId);

// Panics are not cached because a panic can be fixed by changing seemingly unrelated code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.enso.polyglot.runtime.Runtime$Api$CreateContextResponse;
import org.enso.polyglot.runtime.Runtime$Api$EditFileNotification;
import org.enso.polyglot.runtime.Runtime$Api$ExecutionFailed;
import org.enso.polyglot.runtime.Runtime$Api$ExpressionUpdates;
import org.enso.polyglot.runtime.Runtime$Api$InitializedNotification;
import org.enso.polyglot.runtime.Runtime$Api$MethodPointer;
import org.enso.polyglot.runtime.Runtime$Api$OpenFileNotification;
Expand All @@ -35,6 +36,8 @@
import scala.Option;
import scala.collection.immutable.List;
import scala.collection.immutable.Seq;
import scala.collection.immutable.Set;
import scala.collection.immutable.Set$;
import scala.collection.immutable.Vector1;

public class IncrementalUpdatesTest {
Expand Down Expand Up @@ -168,7 +171,7 @@ private static String extractPositions(String code, String chars, Map<Character,

Function<Character, UUID> registerRegion = (ch) -> {
int[] beginAndLength = pos.get(ch);
return metadata.addItem(beginAndLength[0], beginAndLength[1]);
return metadata.addItem(beginAndLength[0], beginAndLength[1], null);
};
// foo definition
registerRegion.apply('&');
Expand Down Expand Up @@ -213,10 +216,10 @@ private static String extractPositions(String code, String chars, Map<Character,
)
);

assertSameElements(context.receiveNIgnoreStdLib(4, 10),
assertSameElements(context.receiveNIgnorePendingExpressionUpdates(4, 10, emptySet()),
Response(requestId, new Runtime$Api$PushContextResponse(contextId)),
TestMessages.update(contextId, mainFoo, exprType, new Runtime$Api$MethodPointer("Enso_Test.Test.Main", "Enso_Test.Test.Main", "foo")),
TestMessages.update(contextId, mainRes, ConstantsGen.NOTHING),
TestMessages.update(contextId, mainRes, ConstantsGen.NOTHING, false),
context.executionComplete(contextId)
);
assertEquals(List.newBuilder().addOne(originalOutput), context.consumeOut());
Expand All @@ -230,10 +233,10 @@ private static String extractPositions(String code, String chars, Map<Character,
new Runtime$Api$PushContextRequest(contextId, new Runtime$Api$StackItem$LocalCall(mainFoo))
)
);
assertSameElements(context.receiveN(4, 10),
assertSameElements(context.receiveNIgnorePendingExpressionUpdates(4, 10, emptySet()),
Response(requestId, new Runtime$Api$PushContextResponse(contextId)),
TestMessages.update(contextId, fooX, exprType),
TestMessages.update(contextId, fooRes, exprType),
TestMessages.update(contextId, fooX, exprType, false),
TestMessages.update(contextId, fooRes, exprType, false),
context.executionComplete(contextId)
);
assertEquals(List.newBuilder().addOne(originalOutput), context.consumeOut());
Expand Down Expand Up @@ -265,7 +268,7 @@ private static String extractPositions(String code, String chars, Map<Character,
),
true
)));
return context.receiveN(1, 10);
return context.receiveNIgnorePendingExpressionUpdates(1, 10, emptySet());
}

private List<Runtime$Api$Response> sendExpressionValue(String originalText, String newText) {
Expand All @@ -281,7 +284,7 @@ private static String extractPositions(String code, String chars, Map<Character,
UUID.randomUUID(),
newText
)));
return context.receiveN(1, 10);
return context.receiveNIgnoreExpressionUpdates(1, 10);
}

private <T extends Node> T findLiteralNode(Class<T> type, Map<Class, java.util.List<Node>> nodes) {
Expand All @@ -295,6 +298,11 @@ private static void assertSameElements(List<Runtime$Api$Response> actual, Runtim
assertEquals("Same size: " + actual, seq.length, actual.size());
for (int i = 0; i < seq.length; i++) {
var real = actual.drop(i).head();
if (real instanceof Runtime$Api$Response response) {
if (response.payload() instanceof Runtime$Api$ExpressionUpdates) {
continue;
}
}
assertEquals("Check on #" + i, seq[i], real);
}
}
Expand All @@ -313,6 +321,10 @@ private static <T> Option<T> None() {
return (Option<T>) scala.None$.MODULE$;
}

private static <T> Set<T> emptySet() {
return Set$.MODULE$.empty();
}

private static Runtime$Api$Request Request(UUID id, org.enso.polyglot.runtime.Runtime.ApiRequest request) {
return org.enso.polyglot.runtime.Runtime$Api$Request$.MODULE$.apply(id, request);
}
Expand Down
Loading