Skip to content

Commit

Permalink
Add cli option to control environment
Browse files Browse the repository at this point in the history
Added a fix for #6131 to allow for some testing.
  • Loading branch information
hubertp committed Apr 6, 2023
1 parent 80a7018 commit 31730d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ class ContextFactory {
strictErrors: Boolean = false,
useGlobalIrCacheLocation: Boolean = true,
enableAutoParallelism: Boolean = false,
executionEnvironment: Option[String] = None,
options: java.util.Map[String, String] = java.util.Collections.emptyMap
): PolyglotContext = {
executionEnvironment.foreach { name =>
options.put("enso.ExecutionEnvironment", name)
}
val context = Context
.newBuilder()
.allowExperimentalOptions(true)
Expand Down
19 changes: 17 additions & 2 deletions engine/runner/src/main/scala/org/enso/runner/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ object Main {
private val AUTH_TOKEN = "auth-token"
private val AUTO_PARALLELISM_OPTION = "with-auto-parallelism"
private val SKIP_GRAALVM_UPDATER = "skip-graalvm-updater"
private val EXECUTION_ENVIRONMENT_OPTION = "execution-environment"

private lazy val logger = Logger[Main.type]

Expand Down Expand Up @@ -355,6 +356,16 @@ object Main {
.desc("Skips GraalVM and its components setup during bootstrapping.")
.build

val executionEnvironmentOption = CliOption.builder
.longOpt(EXECUTION_ENVIRONMENT_OPTION)
.hasArg(true)
.numberOfArgs(1)
.argName("name")
.desc(
"Execution environment to use during execution (`live` or `design`)"
)
.build()

val options = new Options
options
.addOption(help)
Expand Down Expand Up @@ -396,6 +407,7 @@ object Main {
.addOptionGroup(cacheOptionsGroup)
.addOption(autoParallelism)
.addOption(skipGraalVMUpdater)
.addOption(executionEnvironmentOption)

options
}
Expand Down Expand Up @@ -540,7 +552,8 @@ object Main {
enableIrCaches: Boolean,
enableAutoParallelism: Boolean,
inspect: Boolean,
dump: Boolean
dump: Boolean,
executionEnvironment: Option[String]
): Unit = {
val file = new File(path)
if (!file.exists) {
Expand Down Expand Up @@ -580,6 +593,7 @@ object Main {
enableIrCaches,
strictErrors = true,
enableAutoParallelism = enableAutoParallelism,
executionEnvironment = executionEnvironment,
options = options
)
if (projectMode) {
Expand Down Expand Up @@ -1092,7 +1106,8 @@ object Main {
shouldEnableIrCaches(line),
line.hasOption(AUTO_PARALLELISM_OPTION),
line.hasOption(INSPECT_OPTION),
line.hasOption(DUMP_GRAPHS_OPTION)
line.hasOption(DUMP_GRAPHS_OPTION),
Option(line.getOptionValue(EXECUTION_ENVIRONMENT_OPTION))
)
}
if (line.hasOption(REPL_OPTION)) {
Expand Down

0 comments on commit 31730d2

Please sign in to comment.