-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run node in a different execution environment (#11173)
close #10719 Changelog: - add: optional `expressionConfigs` parameter to the `executionContext/recompute` request - update: `IdExecutionInstrument` allowing to run a single node in a specified execution environment - refactor: move tests related to the recompute request to a separate test suite. Otherwise the `RuntimeServerTest` is becoming too bloated # Important Notes The updated `executionContext/recompute` request. ```typescript interface ExecutionContextRecomputeParameters { /** The execution context identifier. */ contextId: ContextId; /** The expressions that will be invalidated before the execution. * * Only the provided expression ids are invalidated excluding the dependencies. */ invalidatedExpressions?: "all" | ExpressionId[]; /** The execution environment that will be used in the execution. */ executionEnvironment?: ExecutionEnvironment; /** The execution configurations for particular expressions. * * The provided expressions will be invalidated from the cache with the * dependencies. The result of the execution will stay in the cache until the * cache is invalidated by editing the node or other means. */ expressionConfigs?: ExpressionConfig[]; } interface ExpressionConfig { /** The expression identifier. */ expressionId: ExpressionId; /** The execution environment that should be used to run this expression. */ executionEnvironment?: ExecutionEnvironment; } ``` #### Use cases - to re-run a single node without re-running the dependent nodes (subtree), put the node id in the `invalidatedExpressions` parameter. - to re-run a node with dependent nodes (subtree), put the node id in the `expressionConfigs` parameter with empty `executionEnvironment` - to re-run a node in a different execution environment, put the node id in the `expressionConfigs` and specify the `executionEnvieronment`
- Loading branch information
Showing
32 changed files
with
2,157 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
engine/language-server/src/main/scala/org/enso/languageserver/runtime/ExpressionConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.enso.languageserver.runtime | ||
|
||
import org.enso.polyglot.runtime.Runtime.Api | ||
|
||
import java.util.UUID | ||
|
||
/** The expression configuration used in the recompute request. | ||
* | ||
* @param expressionId the expression identifier | ||
* @param executionEnvironment the execution environment used to run this expression | ||
*/ | ||
case class ExpressionConfig( | ||
expressionId: UUID, | ||
executionEnvironment: Option[ExecutionEnvironments.ExecutionEnvironment] | ||
) { | ||
|
||
/** Convert this expression config to the runtime API. */ | ||
def toApi: Api.ExpressionConfig = | ||
Api.ExpressionConfig( | ||
expressionId, | ||
executionEnvironment.map(ExecutionEnvironments.toApi) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...time-instrument-common/src/main/java/org/enso/interpreter/instrument/ExecutionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.enso.interpreter.instrument; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import org.enso.interpreter.runtime.state.ExecutionEnvironment; | ||
import org.enso.polyglot.runtime.Runtime$Api$ExecutionEnvironment; | ||
import org.enso.polyglot.runtime.Runtime$Api$ExpressionConfig; | ||
import scala.Option; | ||
import scala.collection.immutable.Seq; | ||
|
||
/** | ||
* The program execution config. | ||
* | ||
* @param executionEnvironment the global execution environment of the program | ||
* @param expressionConfigs execution configs for each expression | ||
*/ | ||
public record ExecutionConfig( | ||
ExecutionEnvironment executionEnvironment, Map<UUID, ExecutionEnvironment> expressionConfigs) { | ||
|
||
public static ExecutionConfig empty() { | ||
return new ExecutionConfig(null, Collections.emptyMap()); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static ExecutionConfig create( | ||
Object executionEnvironmentOption1, Object expressionConfigs1) { | ||
Map<UUID, ExecutionEnvironment> expressionConfigsBuilder = new HashMap<>(); | ||
Option<Runtime$Api$ExecutionEnvironment> executionEnvironmentOption = | ||
(Option<Runtime$Api$ExecutionEnvironment>) executionEnvironmentOption1; | ||
Seq<Runtime$Api$ExpressionConfig> expressionConfigs = | ||
(Seq<Runtime$Api$ExpressionConfig>) expressionConfigs1; | ||
expressionConfigs.foreach( | ||
expressionConfig -> { | ||
expressionConfig | ||
.executionEnvironment() | ||
.foreach( | ||
executionEnvironment -> { | ||
expressionConfigsBuilder.put( | ||
expressionConfig.expressionId(), | ||
ExecutionEnvironment.forName(executionEnvironment.name())); | ||
return null; | ||
}); | ||
return null; | ||
}); | ||
|
||
ExecutionEnvironment executionEnvironment = | ||
executionEnvironmentOption | ||
.map(env -> ExecutionEnvironment.forName(env.name())) | ||
.getOrElse(() -> null); | ||
|
||
return new ExecutionConfig(executionEnvironment, expressionConfigsBuilder); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...rument-common/src/main/java/org/enso/interpreter/instrument/ExpressionExecutionState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.enso.interpreter.instrument; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import org.enso.interpreter.runtime.state.ExecutionEnvironment; | ||
|
||
public final class ExpressionExecutionState { | ||
|
||
private final Map<UUID, ExecutionEnvironment> expressionConfigs; | ||
|
||
public ExpressionExecutionState() { | ||
this.expressionConfigs = new HashMap<>(); | ||
} | ||
|
||
public ExpressionExecutionState(Map<UUID, ExecutionEnvironment> expressionConfigs) { | ||
this.expressionConfigs = expressionConfigs; | ||
} | ||
|
||
public void setExpressionConfigs(Map<UUID, ExecutionEnvironment> expressionConfigs) { | ||
this.expressionConfigs.putAll(expressionConfigs); | ||
} | ||
|
||
public void setExpressionExecuted(UUID expressionId) { | ||
expressionConfigs.remove(expressionId); | ||
} | ||
|
||
public ExecutionEnvironment getExecutionEnvironment(UUID expressionId) { | ||
return expressionConfigs.get(expressionId); | ||
} | ||
} |
Oops, something went wrong.