當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Kernel.getSpecs方法代碼示例

本文整理匯總了TypeScript中@jupyterlab/services.Kernel.getSpecs方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Kernel.getSpecs方法的具體用法?TypeScript Kernel.getSpecs怎麽用?TypeScript Kernel.getSpecs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@jupyterlab/services.Kernel的用法示例。


在下文中一共展示了Kernel.getSpecs方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should throw for a missing kernelspecs parameter', async () => {
   const serverSettings = getRequestHandler(200, {
     default: PYTHON_SPEC.name
   });
   const promise = Kernel.getSpecs(serverSettings);
   await expectFailure(promise, 'No kernelspecs found');
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:7,代碼來源:kernel.spec.ts

示例2: function

document.addEventListener("DOMContentLoaded", function(event) {

    // Connect to the notebook webserver.
    let connectionInfo = {
        baseUrl: BASEURL,
        wsUrl: WSURL
    };
    Kernel.getSpecs(connectionInfo).then(kernelSpecs => {
        (connectionInfo as any).name = kernelSpecs.default;
        return Kernel.startNew(connectionInfo);
    }).then(kernel => {

        // Create a codemirror instance
        let code = require('../widget_code.json').join("\n");
        let inputarea = document.getElementsByClassName("inputarea")[0] as HTMLElement;
        let editor = CodeMirror(inputarea, {
            value: code,
            mode: "python",
            tabSize: 4,
            showCursorWhenSelecting: true,
            viewportMargin: Infinity,
            readOnly: true
        });

        // Create the widget area and widget manager
        let widgetarea = document.getElementsByClassName("widgetarea")[0];
        let manager = new WidgetManager(kernel, widgetarea);

        // Run backend code to create the widgets.  You could also create the
        // widgets in the frontend, like the other widget examples demonstrate.
        kernel.execute({ code: code });
    });
});
開發者ID:cameronoelsen,項目名稱:ipywidgets,代碼行數:33,代碼來源:index.ts

示例3: function

document.addEventListener('DOMContentLoaded', function(event) {

    // Connect to the notebook webserver.
    let connectionInfo = ServerConnection.makeSettings({
        baseUrl: BASEURL,
        wsUrl: WSURL
    });
    Kernel.getSpecs(connectionInfo).then(kernelSpecs => {
        return Kernel.startNew({
            name: kernelSpecs.default,
            serverSettings: connectionInfo
        });
    }).then(kernel => {

        // Create a codemirror instance
        let code = require('../widget_code.json').join('\n');
        let inputarea = document.getElementsByClassName('inputarea')[0] as HTMLElement;
        let editor = CodeMirror(inputarea, {
            value: code,
            mode: 'python',
            tabSize: 4,
            showCursorWhenSelecting: true,
            viewportMargin: Infinity,
            readOnly: true
        });

        // Create the widget area and widget manager
        let widgetarea = document.getElementsByClassName('widgetarea')[0] as HTMLElement;
        let manager = new WidgetManager(kernel, widgetarea);

        // Run backend code to create the widgets.  You could also create the
        // widgets in the frontend, like the other widget examples demonstrate.
        let execution = kernel.requestExecute({ code: code });
        execution.onIOPub = (msg) => {
            // If we have a display message, display the widget.
            if (KernelMessage.isDisplayDataMsg(msg)) {
                let widgetData: any = msg.content.data['application/vnd.jupyter.widget-view+json'];
                if (widgetData !== undefined && widgetData.version_major === 2) {
                    let model = manager.get_model(widgetData.model_id);
                    if (model !== undefined) {
                        model.then(model => {
                            manager.display_model(msg, model);
                        });
                    }
                }
            }
        };
    });
});
開發者ID:SylvainCorlay,項目名稱:ipywidgets,代碼行數:49,代碼來源:index.ts

示例4: function

    xmlhttp.onreadystatechange = function () {
        //Call a function when the state changes.
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            let response = JSON.parse(xmlhttp.responseText);
            // TODO: this will need to be changed to check the status code 429
            // when https://github.com/jupyter/tmpnb/pull/283 is implemented.
            if (response.status === 'full') {
                let widgetarea = document.getElementsByClassName("widgetarea")[0] as HTMLElement;
                widgetarea.innerText = "The tmpnb server does not have any available kernels.";
                throw new Error('Tmpnb does not have any available kernels');
            }
            let serverUrl = baseUrl.concat(JSON.parse(xmlhttp.responseText).url);
            let wsUrl = 'ws:' + serverUrl.split(':').slice(1).join(':');

            // Connect to the notebook webserver.
            let connectionInfo: any = ServerConnection.makeSettings({
                baseUrl: serverUrl,
                wsUrl: wsUrl
            });
            Kernel.getSpecs(connectionInfo).then(kernelSpecs => {
                return Kernel.startNew({name: kernelSpecs.default, serverSettings: connectionInfo});
            }).then(kernel => {

                // Create a codemirror instance
                let code = require('../widget_code.json').join("\n");
                let inputarea = document.getElementsByClassName("inputarea")[0] as HTMLElement;
                let editor = CodeMirror(inputarea, {
                    value: code,
                    mode: "python",
                    tabSize: 4,
                    showCursorWhenSelecting: true,
                    viewportMargin: Infinity,
                    readOnly: true
                });

                // Create the widget area and widget manager
                let widgetarea = document.getElementsByClassName("widgetarea")[0] as HTMLElement;
                let manager = new WidgetManager(kernel, widgetarea);

                // Run backend code to create the widgets.  You could also create the
                // widgets in the frontend, like the other widget examples demonstrate.
                let request = kernel.requestExecute({ code: code });
                request.onIOPub = (msg) => {
                    // If we have a display message, display the widget.
                    console.log(msg);
                }
            });
        }
    }
開發者ID:ssunkara1,項目名稱:ipython_widgets,代碼行數:49,代碼來源:index.ts

示例5: function

    xmlhttp.onreadystatechange = function () {
        //Call a function when the state changes.
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            let serverUrl = baseUrl.concat(JSON.parse(xmlhttp.responseText).url);
            let wsUrl = 'ws:' + serverUrl.split(':').slice(1).join(':');

            // Connect to the notebook webserver.
            let connectionInfo = {
                baseUrl: serverUrl,
                wsUrl: wsUrl
            };
            Kernel.getSpecs(connectionInfo).then(kernelSpecs => {
                (connectionInfo as any).name = kernelSpecs.default;
                return Kernel.startNew(connectionInfo);
            }).then(kernel => {

                // Create a codemirror instance
                let code = require('../widget_code.json').join("\n");
                let inputarea = document.getElementsByClassName("inputarea")[0] as HTMLElement;
                let editor = CodeMirror(inputarea, {
                    value: code,
                    mode: "python",
                    tabSize: 4,
                    showCursorWhenSelecting: true,
                    viewportMargin: Infinity,
                    readOnly: true
                });

                // Create the widget area and widget manager
                let widgetarea = document.getElementsByClassName("widgetarea")[0];
                let manager = new WidgetManager(kernel, widgetarea);

                // Run backend code to create the widgets.  You could also create the
                // widgets in the frontend, like the other widget examples demonstrate.
                kernel.execute({ code: code });
            });
        }
    }
開發者ID:cameronoelsen,項目名稱:ipywidgets,代碼行數:38,代碼來源:index.ts


注:本文中的@jupyterlab/services.Kernel.getSpecs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。