Search in sources :

Example 6 with SimpleEvaluationObject

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

the class PlainCode method executeFrame.

@Override
public void executeFrame(Code code, KernelFunctionality kernel, Message message, int executionCount) {
    SimpleEvaluationObject seo = createSimpleEvaluationObject(this.plainCode, kernel, message, executionCount);
    seo.noResult();
    TryResult either = kernel.executeCode(this.plainCode, seo);
    handleResult(seo, either);
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)

Example 7 with SimpleEvaluationObject

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

the class OutputWidgetTest method submitCodeToExecution.

private Message submitCodeToExecution() {
    SimpleEvaluationObject value = new SimpleEvaluationObject("output");
    Message jupyterMessage = new Message();
    value.setJupyterMessage(jupyterMessage);
    InternalVariable.setValue(value);
    return jupyterMessage;
}
Also used : Message(com.twosigma.beakerx.message.Message) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)

Example 8 with SimpleEvaluationObject

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

the class GroovyEvaluatorStackTraceTest method unableToResolveClass.

@Test
public void unableToResolveClass() throws Exception {
    String code = "new IntSlider()";
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    // when
    TryResult evaluate = groovyEvaluator.evaluate(seo, code);
    // then
    assertThat(evaluate.isError()).isTrue();
    System.out.println(evaluate.error());
    assertThat(evaluate.error()).contains("unable to resolve class IntSlider");
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Example 9 with SimpleEvaluationObject

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

the class GroovyOutputContainerTest method shouldAddPlotToOutputContainerTest.

@Test
public void shouldAddPlotToOutputContainerTest() throws Exception {
    // given
    String code = "import com.twosigma.beakerx.groovy.evaluator.ResourceLoaderTest;\n" + "import com.twosigma.beakerx.jvm.object.OutputContainer;\n" + "import com.twosigma.beakerx.chart.xychart.SimpleTimePlot;\n" + "List<Map<?, ?>> rates = ResourceLoaderTest.readAsList(\"tableRowsTest.csv\");\n" + "plot2 = new SimpleTimePlot(rates, [\"m3\", \"y1\"], showLegend:false, initWidth: 300, initHeight: 400)\n" + "new OutputContainer() << plot2";
    // when
    SimpleEvaluationObject evaluationObject = PlainCode.createSimpleEvaluationObject(code, groovyKernel, HEADER_MESSAGE, 1);
    TryResult seo = groovyEvaluatorManager.executeCode(code, evaluationObject);
    // then
    assertThat(seo.result()).isNotNull();
    verifyPlot(groovyKernel.getPublishedMessages());
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 10 with SimpleEvaluationObject

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

the class NamespaceClient method showProgressUpdate.

public synchronized void showProgressUpdate(String message, int progress) {
    SimpleEvaluationObject seo = InternalVariable.getSimpleEvaluationObject();
    seo.structuredUpdate(message, progress);
}
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