Search in sources :

Example 11 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.

the class MessageCreatorNoResultTest method noResult.

@Test
public void noResult() throws Exception {
    // given
    SimpleEvaluationObject seo = new SimpleEvaluationObject("code");
    seo.setJupyterMessage(new Message());
    seo.finished(OutputCell.HIDDEN);
    // when
    List<MessageHolder> messages = MessageCreator.createMessage(seo);
    // then
    messages.forEach(m -> assertThat(JupyterMessages.EXECUTE_RESULT).isNotEqualTo(m.getMessage().type()));
}
Also used : MessageHolder(com.twosigma.beakerx.kernel.msg.MessageHolder) Message(com.twosigma.beakerx.message.Message) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 12 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.

the class NamespaceClientShowProgressReportingTest method updateProgressReporting.

@Test
public void updateProgressReporting() throws Exception {
    // given
    InternalVariable.setValue(new SimpleEvaluationObject("code"));
    // when
    namespaceClient.showProgressUpdate("msg1", 20);
    namespaceClient.showProgressUpdate("msg2", 40);
    // then
    assertThat(kernel.getPublishedMessages()).isNotEmpty();
}
Also used : SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Example 13 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.

the class CompiledCodeRunner method runCommEvent.

static void runCommEvent(Message message, CommActions action, Widget.ActionPerformed handlerAction) {
    if (message.getContent() != null) {
        Serializable data = message.getContent().get("data");
        if (data != null && data instanceof LinkedHashMap) {
            Object contentObject = ((LinkedHashMap) data).get("content");
            if (contentObject instanceof LinkedHashMap) {
                HashMap content = (LinkedHashMap) contentObject;
                if (handlerAction != null) {
                    final SimpleEvaluationObject seo = initOutput(message);
                    handlerAction.executeAction(content, message);
                    seo.clrOutputHandler();
                }
            }
        }
    }
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) LinkedHashMap(java.util.LinkedHashMap)

Example 14 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.

the class CompiledCodeRunner method initOutput.

private static SimpleEvaluationObject initOutput(Message message) {
    final SimpleEvaluationObject seo = new SimpleEvaluationObject("");
    seo.setJupyterMessage(message);
    seo.setOutputHandler();
    seo.addObserver(KernelManager.get().getExecutionResultSender());
    return seo;
}
Also used : SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)

Example 15 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.

the class InteractiveTest method callInteractWithStringParam.

private void callInteractWithStringParam(String param) throws Exception {
    String code = getInteractiveCode(param);
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    // when
    groovyEvaluator.evaluate(seo, code);
}
Also used : SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)

Aggregations

SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)57 TryResult (com.twosigma.beakerx.TryResult)37 Test (org.junit.Test)33 Message (com.twosigma.beakerx.message.Message)9 KernelTest (com.twosigma.beakerx.KernelTest)7 PlainCode.createSimpleEvaluationObject (com.twosigma.beakerx.kernel.PlainCode.createSimpleEvaluationObject)5 HashMap (java.util.HashMap)4 EvaluatorParameters (com.twosigma.beakerx.kernel.EvaluatorParameters)3 MagicCommandOutput (com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ExecutionException (java.util.concurrent.ExecutionException)3 Plot (com.twosigma.beakerx.chart.xychart.Plot)2 MagicCommandOutcomeItem (com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutcomeItem)2 MessageHolder (com.twosigma.beakerx.kernel.msg.MessageHolder)2 ThreadMXBean (java.lang.management.ThreadMXBean)2 Before (org.junit.Before)2 AutocompleteResult (com.twosigma.beakerx.autocomplete.AutocompleteResult)1 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)1 Code (com.twosigma.beakerx.kernel.Code)1 KernelFunctionality (com.twosigma.beakerx.kernel.KernelFunctionality)1