Path: blob/master/src/packages/conat/service/jupyter.ts
1452 views
/*1Services in a project/compute server for working with a Jupyter notebook.2*/34import { createServiceClient, createServiceHandler } from "./typed";5import type { KernelInfo } from "@cocalc/util/jupyter/types";67const service = "api";89export interface JupyterApi {10signal: (signal: string) => Promise<void>;1112save_ipynb_file: (opts?: {13version?: number;14timeout?: number;15}) => Promise<void>;1617kernel_info: () => Promise<KernelInfo>;1819more_output: (id: string) => Promise<any[]>;2021complete: (opts: { code: string; cursor_pos: number }) => Promise<any>;2223introspect: (opts: {24code: string;25cursor_pos: number;26level: 0 | 1;27}) => Promise<any>;2829store: (opts: { key: string; value?: any }) => Promise<any>;3031comm: (opts: {32msg_id: string;33comm_id: string;34target_name: string;35data: any;36buffers64?: string[];37buffers?: Buffer[];38}) => Promise<void>;3940ipywidgetsGetBuffer: (opts: {41model_id;42buffer_path;43}) => Promise<{ buffer64: string }>;44}4546export type JupyterApiEndpoint = keyof JupyterApi;4748export function jupyterApiClient({49project_id,50path,51timeout,52}: {53project_id: string;54path: string;55timeout?: number;56}) {57return createServiceClient<JupyterApi>({58project_id,59path,60service,61timeout,62});63}6465export async function createConatJupyterService({66path,67project_id,68impl,69}: {70project_id: string;71path: string;72impl: JupyterApi;73}) {74return await createServiceHandler<JupyterApi>({75project_id,76path,77service,78impl,79description: "Jupyter notebook compute API",80});81}828384