Search in sources :

Example 16 with Message

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

the class BaseHandler method createReplyMessage.

protected Message createReplyMessage(Message message, Serializable responceData) {
    Message ret = null;
    if (message != null) {
        ret = new Message();
        Map<String, Serializable> commMap = message.getContent();
        ret.setHeader(new Header(COMM_MSG, message.getHeader().getSession()));
        HashMap<String, Serializable> map = new HashMap<>();
        map.put(COMM_ID, getString(commMap, COMM_ID));
        map.put(DATA, responceData);
        ret.setContent(map);
    }
    return ret;
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header) HashMap(java.util.HashMap)

Example 17 with Message

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

the class TimeCellModeMagicCommand method execute.

@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
    Message message = param.getCode().getMessage();
    int executionCount = param.getExecutionCount();
    return time(param.getCommandCodeBlock(), message, executionCount, param.isShowResult());
}
Also used : Message(com.twosigma.beakerx.message.Message)

Example 18 with Message

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

the class TimeItLineModeMagicCommand method execute.

@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
    Message message = param.getCode().getMessage();
    int executionCount = param.getExecutionCount();
    String codeToExecute = param.getCommand().replace(TIMEIT_LINE, "");
    codeToExecute = codeToExecute.replaceAll("(-.)(\\d*\\s)", "");
    try {
        return timeIt(buildTimeItOption(param.getCode()), codeToExecute, message, executionCount, param.isShowResult());
    } catch (IllegalArgumentException e) {
        return new MagicCommandOutput(MagicCommandOutput.Status.ERROR, e.getMessage());
    }
}
Also used : MagicCommandOutput(com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput) Message(com.twosigma.beakerx.message.Message)

Example 19 with Message

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

the class TimeLineModeMagicCommand method execute.

@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
    Message message = param.getCode().getMessage();
    int executionCount = param.getExecutionCount();
    String codeToExecute = param.getCommand().replace(TIME_LINE, "");
    return time(codeToExecute, message, executionCount, param.isShowResult());
}
Also used : Message(com.twosigma.beakerx.message.Message)

Example 20 with Message

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

the class KernelSocketsZMQ method handleControlMsg.

private void handleControlMsg() {
    Message message = readMessage(controlSocket);
    JupyterMessages type = message.getHeader().getTypeEnum();
    if (type.equals(SHUTDOWN_REQUEST)) {
        Message reply = new Message();
        reply.setHeader(new Header(SHUTDOWN_REPLY, message.getHeader().getSession()));
        reply.setParentHeader(message.getHeader());
        reply.setContent(message.getContent());
        sendMsg(controlSocket, Collections.singletonList(reply));
        shutdown();
    }
}
Also used : Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header) JupyterMessages(com.twosigma.beakerx.kernel.msg.JupyterMessages)

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