Skip to content

Commit

Permalink
Disable progress reporting in existing runtime tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Feb 25, 2025
1 parent ed6ca37 commit f6156c5
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ private RuntimeOptions() {}
private static final OptionDescriptor ENABLE_GLOBAL_SUGGESTIONS_DESCRIPTOR =
OptionDescriptor.newBuilder(ENABLE_GLOBAL_SUGGESTIONS_KEY, ENABLE_GLOBAL_SUGGESTIONS).build();

public static final String ENABLE_PROGRESS_REPORT = optionName("enableProgressReport");
public static final OptionKey<Boolean> ENABLE_PROGRESS_REPORT_KEY = new OptionKey<>(true);
private static final OptionDescriptor ENABLE_PROGRESS_REPORT_DESCRIPTOR =
OptionDescriptor.newBuilder(ENABLE_PROGRESS_REPORT_KEY, ENABLE_PROGRESS_REPORT).build();

public static final String LANGUAGE_HOME_OVERRIDE = optionName("languageHomeOverride");
public static final OptionKey<String> LANGUAGE_HOME_OVERRIDE_KEY = new OptionKey<>("");
private static final OptionDescriptor LANGUAGE_HOME_OVERRIDE_DESCRIPTOR =
Expand Down Expand Up @@ -156,6 +161,7 @@ private RuntimeOptions() {}
ENABLE_AUTO_PARALLELISM_DESCRIPTOR,
ENABLE_PROJECT_SUGGESTIONS_DESCRIPTOR,
ENABLE_GLOBAL_SUGGESTIONS_DESCRIPTOR,
ENABLE_PROGRESS_REPORT_DESCRIPTOR,
INTERACTIVE_MODE_DESCRIPTOR,
DISABLE_LINTING_DESCRIPTOR,
LANGUAGE_HOME_OVERRIDE_DESCRIPTOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
private final Consumer<ExpressionValue> onComputedCallback;
private final Consumer<ExpressionCall> functionCallCallback;
private final Consumer<ExecutedVisualization> onExecutedVisualizationCallback;
private final Consumer<ExpressionValue> onProgressCallbackOrNull;
private ExecutionProgressObserver progressObserver;

/**
Expand All @@ -55,6 +56,7 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
* @param onCachedCallback the consumer of the cached value events.
* @param functionCallCallback the consumer of function call events.
* @param onExecutedVisualizationCallback the consumer of an executed visualization result.
* @param onProgressCallbackOrNull the consumer of progress events
*/
ExecutionCallbacks(
VisualizationHolder visualizationHolder,
Expand All @@ -66,7 +68,8 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
Consumer<ExpressionValue> onCachedCallback,
Consumer<ExpressionValue> onComputedCallback,
Consumer<ExpressionCall> functionCallCallback,
Consumer<ExecutedVisualization> onExecutedVisualizationCallback) {
Consumer<ExecutedVisualization> onExecutedVisualizationCallback,
Consumer<ExpressionValue> onProgressCallbackOrNull) {
this.visualizationHolder = visualizationHolder;
this.nextExecutionItem = nextExecutionItem;
this.cache = cache;
Expand All @@ -77,6 +80,7 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
this.onComputedCallback = onComputedCallback;
this.functionCallCallback = functionCallCallback;
this.onExecutedVisualizationCallback = onExecutedVisualizationCallback;
this.onProgressCallbackOrNull = onProgressCallbackOrNull;
}

@Override
Expand All @@ -95,13 +99,18 @@ public Object findCachedResult(IdExecutionService.Info info) {
callOnCachedCallback(nodeId, result);
return result;
} else {
if (cache.getPreferences().get(nodeId) == CachePreferences.Kind.BINDING_EXPRESSION) {
refreshObserver(
ExecutionProgressObserver.startComputation(
nodeId,
(progress) -> {
callOnNotCachedCallback(nodeId, progress);
}));
if (onProgressCallbackOrNull != null) {
if (cache.getPreferences().get(nodeId) == CachePreferences.Kind.BINDING_EXPRESSION) {
var newObserver =
ExecutionProgressObserver.startComputation(
nodeId,
(progress) -> {
CompilerDirectives.transferToInterpreter();
var expressionValue = ExpressionValue.progress(nodeId, progress, null);
onProgressCallbackOrNull.accept(expressionValue);
});
refreshObserver(newObserver);
}
}
}

Expand Down Expand Up @@ -201,12 +210,6 @@ private void callOnCachedCallback(UUID nodeId, Object result) {
onCachedCallback.accept(expressionValue);
}

@CompilerDirectives.TruffleBoundary
private void callOnNotCachedCallback(UUID nodeId, double amount) {
var expressionValue = ExpressionValue.progress(nodeId, amount);
onCachedCallback.accept(expressionValue);
}

private void executeOneshotExpressions(UUID nodeId, Object result, IdExecutionService.Info info) {
OneshotExpression oneshotExpression = getOneshotExpression(nodeId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public void execute(
if (src == null) {
throw new SourceNotFoundException(call.getFunction().getName());
}

var callbacks =
new ExecutionCallbacks(
visualizationHolder,
Expand All @@ -197,7 +198,8 @@ public void execute(
onCachedCallback,
onComputedCallback,
funCallCallback,
onExecutedVisualizationCallback);
onExecutedVisualizationCallback,
this.context.isProgressReportEnabled() ? onComputedCallback : null);
Optional<EventBinding<ExecutionEventNodeFactory>> eventNodeFactory =
idExecutionInstrument.map(
service ->
Expand Down Expand Up @@ -371,6 +373,8 @@ public Object callFunctionWithInstrument(
(value) -> context.getLogger().finest("_ON_CACHED_VALUE " + value.getExpressionId());
Consumer<ExecutedVisualization> onExecutedVisualizationCallback = (value) -> {};
ExpressionExecutionState expressionExecutionState = new ExpressionExecutionState();
Consumer<ExpressionValue> onProgressCallback =
(value) -> context.getLogger().finest("_ON_PROGRESS " + value.getExpressionId());

var callbacks =
new ExecutionCallbacks(
Expand All @@ -383,7 +387,8 @@ public Object callFunctionWithInstrument(
onCachedCallback,
onComputedCallback,
funCallCallback,
onExecutedVisualizationCallback);
onExecutedVisualizationCallback,
onProgressCallback);
Optional<EventBinding<ExecutionEventNodeFactory>> eventNodeFactory =
idExecutionInstrument.map(
service -> service.bind(module, entryCallTarget, callbacks, this.timer));
Expand Down Expand Up @@ -704,7 +709,7 @@ public ExpressionValue(
this.wasCached = wasCached;
}

static ExpressionValue progress(UUID nodeId, double amount) {
static ExpressionValue progress(UUID nodeId, double amount, String msg) {
return new ExpressionValue(nodeId, amount, null, null, null, null, null, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,9 @@ object ProgramExecutionSupport {
)(implicit ctx: RuntimeContext): Unit = {
val expressionId = value.getExpressionId
if (value.isProgressUpdate()) {
val msg = null;
val p = Api.ExpressionUpdate.Payload.Pending(
None,
Option(msg),
Some(value.getValue().asInstanceOf[Double])
)
ctx.endpoint.sendToClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BuiltinTypesTest
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class RuntimeAsyncCommandsTest
"false"
)
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RuntimeErrorsTest
.option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(RuntimeOptions.STRICT_ERRORS, "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class RuntimeExecutionEnvironmentTest
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(RuntimeServerInfo.ENABLE_OPTION, "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class RuntimeInstrumentTest
.option(RuntimeOptions.LOG_LEVEL, "WARNING")
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class RuntimeRecomputeTest
)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(RuntimeOptions.STRICT_ERRORS, "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class RuntimeRefactoringTest
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RuntimeServerTest
)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(RuntimeOptions.STRICT_ERRORS, "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class RuntimeTypesTest
)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(RuntimeOptions.STRICT_ERRORS, "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class RuntimeVisualizationsTest extends AnyFlatSpec with Matchers {
(!sequentialExecution).toString
)
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_PROGRESS_REPORT, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_EXECUTION_TIMER, "false")
.option(RuntimeServerInfo.ENABLE_OPTION, "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,16 @@ public boolean isProjectSuggestionsEnabled() {
return getOption(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS_KEY);
}

/**
* Gather information about progress. Should execution observe events from Enso Progress API and
* report them?
*
* @return true if progress reporting is on
*/
public boolean isProgressReportEnabled() {
return getOption(RuntimeOptions.ENABLE_PROGRESS_REPORT_KEY);
}

/**
* Checks whether global caches are to be used.
*
Expand Down

0 comments on commit f6156c5

Please sign in to comment.