use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class MagicCommand method executeLastFrame.
@Override
public void executeLastFrame(Code code, KernelFunctionality kernel, Message message, int executionCount) {
MagicCommandOutcomeItem execute = execute(code, executionCount, true);
sendRepliesWithStatus(singletonList(execute), kernel, message, executionCount);
TryResult result = execute.getResult();
SimpleEvaluationObject seo = execute.getSimpleEvaluationObject();
handleResult(seo, result);
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class ExecutionResultSender method update.
@Override
public synchronized void update(Observable o, Object arg) {
SimpleEvaluationObject seo = (SimpleEvaluationObject) o;
if (seo != null) {
List<MessageHolder> message = MessageCreator.createMessage(seo);
message.forEach(job -> {
if (SocketEnum.IOPUB_SOCKET.equals(job.getSocketType())) {
kernel.publish(singletonList(job.getMessage()));
} else if (SocketEnum.SHELL_SOCKET.equals(job.getSocketType())) {
kernel.send(job.getMessage());
}
});
}
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class CompiledCodeRunner method runCompiledCodeAndPublish.
public static void runCompiledCodeAndPublish(Message message, ExecuteCompiledCode handler, Object... params) {
final SimpleEvaluationObject seo = initOutput(message);
InternalVariable.setValue(seo);
KernelManager.get().publish(singletonList(MessageCreator.buildClearOutput(message, true)));
try {
Object result = handler.executeCode(params);
if (result != null) {
List<MIMEContainer> resultString = MIMEContainerFactory.createMIMEContainers(result);
KernelManager.get().publish(singletonList(MessageCreator.buildDisplayData(message, resultString)));
}
} catch (Exception e) {
printError(message, seo, e);
}
seo.clrOutputHandler();
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class CompiledCodeRunner method runCompiledCode.
public static void runCompiledCode(Message message, ExecuteCompiledCode handler, Object... params) {
final SimpleEvaluationObject seo = initOutput(message);
InternalVariable.setValue(seo);
try {
Object result = handler.executeCode(params);
if (result != null) {
MIMEContainerFactory.createMIMEContainers(result);
}
} catch (Exception e) {
printError(message, seo, e);
}
seo.clrOutputHandler();
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class GroovyEvaluatorProgressReportingTest method progressReporting.
@Test
public void progressReporting() throws Exception {
// given
String code = "for ( int i = 0 ; i<5; i++) {\n" + " " + BEAKER_VARIABLE_NAME + ".showProgressUpdate(\"msg\"+i, i)\n" + "}\n" + "\"finished\"";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = groovyEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isEqualTo("finished");
verifyProgressReporting(groovyKernel.getPublishedMessages());
}
Aggregations