Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/client/jupyter.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import * as message from "@cocalc/util/message";6import { AsyncCall } from "./client";7import type { KernelSpec } from "@cocalc/jupyter/types";89export class JupyterClient {10private async_call: AsyncCall;1112constructor(async_call: AsyncCall) {13this.async_call = async_call;14}1516public async kernels(project_id?: string): Promise<KernelSpec[]> {17const resp = await this.async_call({18message: message.jupyter_kernels({ project_id }),19});20if (resp.error) {21throw Error(resp.error);22}23return resp.kernels;24}2526public async execute({27input,28kernel,29history,30hash,31tag = "",32project_id,33path,34}: {35input?: string;36kernel?: string;37history?: string[];38hash?: string;39tag?: string;40project_id?: string;41path?: string;42}): Promise<{ output: object[]; time: Date; total_time_s: number } | null> {43const resp = await this.async_call({44message: message.jupyter_execute({45hash,46input,47kernel,48history,49tag,50project_id,51path,52}),53});54if (resp.error) {55throw Error(resp.error);56}57return resp;58}59}606162