How to use the @jupyterlab/services.KernelMessage.isStreamMsg function in @jupyterlab/services

To help you get started, we’ve selected a few @jupyterlab/services examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / messages.spec.ts View on Github external
it('should check for a stream message type', () => {
      let msg = KernelMessage.createMessage({
        msgType: 'stream',
        channel: 'iopub',
        session: 'baz',
        content: {
          name: 'stdout',
          text: 'hello world'
        }
      });
      expect(KernelMessage.isStreamMsg(msg)).to.equal(true);
      expect(KernelMessage.isStreamMsg(iopubStatusMsg)).to.equal(false);
    });
  });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / messages.spec.ts View on Github external
it('should check for a stream message type', () => {
      let msg = KernelMessage.createMessage({
        msgType: 'stream',
        channel: 'iopub',
        session: 'baz',
        content: {
          name: 'stdout',
          text: 'hello world'
        }
      });
      expect(KernelMessage.isStreamMsg(msg)).to.equal(true);
      expect(KernelMessage.isStreamMsg(iopubStatusMsg)).to.equal(false);
    });
  });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / messages.spec.ts View on Github external
it('should check for a stream message type', () => {
      let msg = KernelMessage.createMessage({
        msgType: 'stream',
        channel: 'iopub',
        session: 'baz',
        content: {
          name: 'stdout',
          text: 'hello world'
        }
      });
      expect(KernelMessage.isStreamMsg(msg)).to.equal(true);
      expect(KernelMessage.isStreamMsg(iopubStatusMsg)).to.equal(false);
    });
  });
github jupyterlab / jupyterlab / tests / test-console / src / foreign.spec.ts View on Github external
handler.injected.connect((sender, msg) => {
          if (KernelMessage.isStreamMsg(msg)) {
            called = true;
            promise.resolve(void 0);
          }
        });
        await foreign.kernel.requestExecute({ code, stop_on_error: true }).done;
github jupyterlab / jupyterlab-data-explorer / tests / test-console / src / foreign.spec.ts View on Github external
handler.injected.connect((sender, msg) => {
          if (KernelMessage.isStreamMsg(msg)) {
            called = true;
            promise.resolve(void 0);
          }
        });
        await foreign.kernel.requestExecute({ code, stop_on_error: true }).done;
github jupyterlab / jupyterlab / packages / outputconsole-extension / src / index.ts View on Github external
(_, msg: KernelMessage.IIOPubMessage) => {
            if (
              KernelMessage.isDisplayDataMsg(msg) ||
              KernelMessage.isStreamMsg(msg) ||
              KernelMessage.isErrorMsg(msg)
            ) {
              log.log((msg.content as unknown) as nbformat.IOutput);
            }
          }
        );
github jupyterlab / jupyterlab / packages / logconsole-extension / src / nboutput.ts View on Github external
function logOutput(
      msg: KernelMessage.IIOPubMessage,
      levelNormal: LogLevel,
      levelError: LogLevel
    ) {
      if (
        KernelMessage.isDisplayDataMsg(msg) ||
        KernelMessage.isStreamMsg(msg) ||
        KernelMessage.isErrorMsg(msg) ||
        KernelMessage.isExecuteResultMsg(msg)
      ) {
        const logger = loggerRegistry.getLogger(nb.context.path);
        logger.rendermime = nb.content.rendermime;
        const data: nbformat.IOutput = {
          ...msg.content,
          output_type: msg.header.msg_type
        };
        let level: LogLevel = levelNormal;
        if (
          KernelMessage.isErrorMsg(msg) ||
          (KernelMessage.isStreamMsg(msg) && msg.content.name === 'stderr')
        ) {
          level = levelError;
        }
github JovianML / jovian-py / jovian / jovian_lab_ext / src / NBKernel.ts View on Github external
result.onIOPub = (msg) => {
            if (KernelMessage.isErrorMsg(msg)){
              reject(msg.content);
            } else if (KernelMessage.isStreamMsg(msg)) {
              text += msg.content.text + "\n";
            } else if (KernelMessage.isStatusMsg(msg)){
              if (msg.content.execution_state.toLowerCase() == "idle"){
                resolve(text);
              }
            }
          }
        }
github jupyterlab / jupyterlab / packages / logconsole-extension / src / nboutput.ts View on Github external
if (
        KernelMessage.isDisplayDataMsg(msg) ||
        KernelMessage.isStreamMsg(msg) ||
        KernelMessage.isErrorMsg(msg) ||
        KernelMessage.isExecuteResultMsg(msg)
      ) {
        const logger = loggerRegistry.getLogger(nb.context.path);
        logger.rendermime = nb.content.rendermime;
        const data: nbformat.IOutput = {
          ...msg.content,
          output_type: msg.header.msg_type
        };
        let level: LogLevel = levelNormal;
        if (
          KernelMessage.isErrorMsg(msg) ||
          (KernelMessage.isStreamMsg(msg) && msg.content.name === 'stderr')
        ) {
          level = levelError;
        }
        logger.log({ type: 'output', data, level });
      }
    }