-
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
Run node in a different execution environment #11173
Merged
mergify
merged 27 commits into
develop
from
wip/db/10719-run-node-in-a-different-context
Oct 9, 2024
Merged
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
108b230
DRAFT: execution config
4e6 d79a9fd
DRAFT: thread local
4e6 75a66c8
DRAFT: cache invalidation
4e6 3994fe3
refactor: RuntimeRecomputeTest
4e6 a55f906
update: language server api
4e6 169e386
doc: update language server api
4e6 95f2c13
update: truffle boundaries
4e6 a25b2e5
misc: javafmt
4e6 b5ed0c0
feat: ExpressionExecutionState
4e6 1b8b9f8
DRAFT: interrupt test
4e6 7df660f
Merge branch 'develop' into wip/db/10719-run-node-in-a-different-context
4e6 1be1988
test: interruption
4e6 cd365aa
fix: native image
4e6 ff97389
misc: javafmt
4e6 4662720
DRAFT: ContextThreadLocal
4e6 e77618c
Merge branch 'develop' into wip/db/10719-run-node-in-a-different-context
4e6 4250a3b
update: callbacks interface
4e6 0ccd2cd
misc: javafmt
4e6 c05283d
remove: getRootNode
4e6 51b3e6c
rename: execution environment getters
4e6 220605e
refactor: resetExecutionEnvironment
4e6 21f8675
misc: cleanup ExecutionConfig
4e6 4d29bfa
remove: ExecutionEnvironmentReference
4e6 c5b3c0c
refactor: ContextThreadLocal execution environment
4e6 6d64253
misc: fmt
4e6 9eeb917
fix: ExecutionConfig compilation
4e6 398827f
Merge branch 'develop' into wip/db/10719-run-node-in-a-different-context
4e6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
56 changes: 56 additions & 0 deletions
56
...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,56 @@ | ||
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<>(); | ||
JaroslavTulach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 getExpressionExecutionEnvironment(UUID expressionId) { | ||
return expressionConfigs.get(expressionId); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
No, we do not want to expose
getRootNode()
. It is only used by:and corresponding setter. Just call it
getExecutionEnvironment()
andsetExecutionEnvironment
.Btw. There already is setExceptionEnvironment below why we have two ways of doing the same thing? Can you document the methods and describe different among them?