Search in sources :

Example 6 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class JupyterHandlerTest method initKernelCommMapWithOneComm.

public static String initKernelCommMapWithOneComm(KernelTest kernelTest) {
    Message openMessage = initOpenMessage();
    String commId = (String) openMessage.getContent().get(COMM_ID);
    String targetName = (String) openMessage.getContent().get(TARGET_NAME);
    Comm comm = new Comm(commId, targetName) {

        @Override
        public void handleMsg(Message parentMessage) {
        }
    };
    kernelTest.addComm(commId, comm);
    return commId;
}
Also used : Message(com.twosigma.beakerx.message.Message) Comm(com.twosigma.beakerx.kernel.comm.Comm)

Example 7 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class NamespaceClient method getAutotranslationComm.

protected Comm getAutotranslationComm() {
    if (autotranslationComm == null) {
        autotranslationComm = new Comm(TargetNamesEnum.BEAKER_AUTOTRANSLATION);
        autotranslationComm.open();
    }
    return autotranslationComm;
}
Also used : Comm(com.twosigma.beakerx.kernel.comm.Comm)

Example 8 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class NamespaceClient method getCodeCells.

public List<CodeCell> getCodeCells(String tagFilter) throws IOException, InterruptedException {
    // first send message to get cells
    Comm c = getCodeCellsComm();
    HashMap<String, Serializable> data = new HashMap<>();
    HashMap<String, Serializable> state = new HashMap<>();
    state.put("name", "CodeCells");
    state.put("value", getJson(tagFilter));
    data.put("state", state);
    data.put("buffer_paths", new HashMap<>());
    c.send(COMM_MSG, Comm.Buffer.EMPTY, new Comm.Data(data));
    // block
    Object cells = getMessageQueue("CodeCells").take();
    return (List<CodeCell>) cells;
}
Also used : Serializable(java.io.Serializable) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) List(java.util.List) Comm(com.twosigma.beakerx.kernel.comm.Comm)

Example 9 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class CommTest method setUp.

@Before
public void setUp() {
    kernel = new KernelTest();
    KernelManager.register(kernel);
    comm = new Comm("targetName");
}
Also used : KernelTest(com.twosigma.beakerx.KernelTest) Comm(com.twosigma.beakerx.kernel.comm.Comm) Before(org.junit.Before)

Example 10 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class InteractiveTest method valueChangeMsgCallback_createDisplayDataMessage.

@Test
public void valueChangeMsgCallback_createDisplayDataMessage() throws Exception {
    // given
    callInteractWithStringParam("\"A\"");
    Comm comm = getCommWidgetByViewName(Text.VIEW_NAME_VALUE);
    // when
    comm.handleMsg(initSyncDataMessage(comm.getCommId(), "TEST"));
    // then
    Message display = SearchMessages.getListMessagesByType(groovyKernel.getPublishedMessages(), JupyterMessages.COMM_MSG).get(2);
    Map date = (Map) display.getContent().get(Comm.DATA);
    Map state = (Map) date.get(Comm.STATE);
    Assertions.assertThat(state).isNotEmpty();
    Assertions.assertThat(state.get("value")).isEqualTo("TEST");
}
Also used : Message(com.twosigma.beakerx.message.Message) Comm(com.twosigma.beakerx.kernel.comm.Comm) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) JupyterHandlerTest(com.twosigma.beakerx.jupyter.handler.JupyterHandlerTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Aggregations

Comm (com.twosigma.beakerx.kernel.comm.Comm)13 Serializable (java.io.Serializable)7 HashMap (java.util.HashMap)5 Message (com.twosigma.beakerx.message.Message)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 KernelTest (com.twosigma.beakerx.KernelTest)2 Header (com.twosigma.beakerx.message.Header)2 Map (java.util.Map)2 KernelHandler (com.twosigma.beakerx.handler.KernelHandler)1 KernelHandlerWrapper.wrapBusyIdle (com.twosigma.beakerx.handler.KernelHandlerWrapper.wrapBusyIdle)1 JupyterHandlerTest (com.twosigma.beakerx.jupyter.handler.JupyterHandlerTest)1 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)1 KernelFunctionality (com.twosigma.beakerx.kernel.KernelFunctionality)1 COMMS (com.twosigma.beakerx.kernel.comm.Comm.COMMS)1 TARGET_NAME (com.twosigma.beakerx.kernel.comm.Comm.TARGET_NAME)1 COMM_INFO_REPLY (com.twosigma.beakerx.kernel.msg.JupyterMessages.COMM_INFO_REPLY)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Before (org.junit.Before)1 Test (org.junit.Test)1