Search in sources :

Example 1 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class MessageCreator method buildDisplayData.

public static Message buildDisplayData(Message message, List<MIMEContainer> mimes) {
    Message reply = initMessage(DISPLAY_DATA, message);
    reply.setContent(new HashMap<>());
    reply.getContent().put("metadata", new HashMap<>());
    HashMap<String, Object> map3 = new HashMap<>();
    mimes.forEach(mimeItem -> map3.put(mimeItem.getMime().asString(), mimeItem.getData()));
    reply.getContent().put("data", map3);
    return reply;
}
Also used : Message(com.twosigma.beakerx.message.Message) HashMap(java.util.HashMap) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)

Example 2 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class MessageCreator method buildOutputMessage.

public static Message buildOutputMessage(Message message, String text, boolean hasError) {
    Message reply = initMessage(STREAM, message);
    reply.setContent(new HashMap<>());
    reply.getContent().put(NAME, hasError ? STDERR : STDOUT);
    reply.getContent().put(TEXT, text);
    logger.debug("Console output:", "Error: " + hasError, text);
    return reply;
}
Also used : Message(com.twosigma.beakerx.message.Message)

Example 3 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class MessageCreator method getExecutionStateMessage.

private static Message getExecutionStateMessage(Message parentMessage, String state) {
    Map<String, Serializable> map1 = new HashMap<String, Serializable>(1);
    map1.put(EXECUTION_STATE, state);
    Message reply = initMessage(STATUS, parentMessage);
    reply.setContent(map1);
    return reply;
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) HashMap(java.util.HashMap)

Example 4 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class MessageCreator method createMessage.

public static synchronized List<MessageHolder> createMessage(SimpleEvaluationObject seo) {
    logger.debug("Creating message response message from: " + seo);
    Message message = seo.getJupyterMessage();
    List<MessageHolder> ret = new ArrayList<>();
    if (isConsoleOutputMessage(seo)) {
        ret.addAll(createConsoleResult(seo, message));
    } else if (isError(seo.getStatus())) {
        ret.addAll(createError(seo, message));
    } else if (isFinish(seo.getStatus()) && seo.isShowResult()) {
        ret.addAll(createFinish(seo, message));
    } else {
        logger.debug("Unhandled status of SimpleEvaluationObject : " + seo.getStatus());
    }
    return ret;
}
Also used : Message(com.twosigma.beakerx.message.Message) ArrayList(java.util.ArrayList)

Example 5 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class MessageCreator method buildClearOutput.

public static Message buildClearOutput(Message message, boolean wait) {
    Message reply = initMessage(CLEAR_OUTPUT, message);
    reply.setContent(new HashMap<>());
    reply.getContent().put("wait", wait);
    reply.getContent().put("metadata", new HashMap<>());
    return reply;
}
Also used : Message(com.twosigma.beakerx.message.Message)

Aggregations

Message (com.twosigma.beakerx.message.Message)270 Test (org.junit.Test)170 KernelTest (com.twosigma.beakerx.KernelTest)121 EvaluatorResultTestWatcher.waitForIdleMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage)64 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)57 Code (com.twosigma.beakerx.kernel.Code)55 Serializable (java.io.Serializable)36 MessageFactoryTest.getExecuteRequestMessage (com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage)35 EvaluatorResultTestWatcher.waitForErrorMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage)28 MessageTest (com.twosigma.beakerx.message.MessageTest)27 Map (java.util.Map)26 HashMap (java.util.HashMap)24 Header (com.twosigma.beakerx.message.Header)23 MessageAssertions.verifyExecuteReplyMessage (com.twosigma.MessageAssertions.verifyExecuteReplyMessage)19 EvaluatorResultTestWatcher.waitForSentMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage)19 PlainCode (com.twosigma.beakerx.kernel.PlainCode)14 KernelExecutionTest (com.twosigma.beakerx.KernelExecutionTest)13 EvaluatorResultTestWatcher.waitForUpdateMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)13 LinkedHashMap (java.util.LinkedHashMap)12 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)11