Skip to main content

用于记录和遥测使用数据的 JupyterLab 库

项目描述

jupyterlab_telemetry

Github 操作状态

用于记录和遥测使用数据的 JupyterLab 库

该扩展由一个以服务器扩展命名的 Python 包和一个以 前端库jupyterlab_telemetry 命名的 NPM 包组成。@jupyterlab/jupyterlab-telemetry

要求

  • JupyterLab >= 3.0

安装

要安装服务器扩展,请执行:

pip install jupyterlab_telemetry

要安装前端库,"@jupyterlab/jupyterlab-telemetry": "^1.0.0"请在package.json.

卸载

要删除服务器扩展,请执行:

pip uninstall jupyterlab_telemetry

要删除前端库,请"@jupyterlab/jupyterlab-telemetry": "^1.0.0"从package.json.

疑难解答

如果您已安装前端库,但无法连接到遥测端点,请检查是否启用了服务器扩展:

jupyter server extension list

用法

定义可以从EventLog

import { EventLog } from '@jupyterlab/jupyterlab-telemetry';

function consoleHandler(el: EventLog, events: EventLog.RecordedEvent[]) {
  console.log(`[Handler1] Received events ${JSON.stringify(events)}`);
}

function consoleHandler2(el: EventLog, events: EventLog.RecordedEvent[]) {
  console.log(`[Handler2] Received events ${JSON.stringify(events)}`);
}

创建 EventLog 的实例并配置处理程序和其他选项EventLog.IOptions

const el = new EventLog({
  handlers: [consoleHandler, consoleHandler2],
  allowedSchemas: [
    'org.jupyter.foo',
    'org.jupyterlab.commands.docmanager:open'
  ],
  commandRegistry: app.commands,
  commandEmitIntervalSeconds: 2
});

recordEvents通过接口发送自定义事件。如果commandRegistry实例已通过,EventLog则将订阅在 JupyterLab 应用程序中执行的命令,并将列入白名单的命令发送到每个配置的处理程序。

el.recordEvent({
  schema: 'org.jupyter.foo',
  version: 1,
  body: {
    foo: 'bar'
  }
});

使用后处理事件日志

el.dispose();

贡献

开发安装

注意:您将需要 NodeJS 来构建扩展包。

该jlpm命令是与 JupyterLab 一起安装的 JupyterLab 的固定版本 yarn。您可以使用 yarn或npm代替jlpm以下。

# Clone the repo to your local environment
git clone https://github.com/jupyterlab/jupyterlab-telemetry.git

# Change directory to the jupyterlab-telemetry directory
cd jupyterlab-telemetry

# Install package in development mode
pip install -e .

# Server extension must be manually installed in develop mode
jupyter server extension enable jupyterlab_telemetry

# Build the Typescript source after making changes
jlpm build

测试

服务器扩展具有 python 测试,可以在推送新更改之前对其进行更新和测试。

# Install the test dependencies
pip install .[test]

# Run the tests
pytest

前端库jest用于测试,并设置为在test目标运行时产生测试覆盖率。

# To run the tests with coverage
jlpm test

开发卸载

# 必须在开发模式下手动禁用服务器扩展
jupyter 服务器扩展禁用 jupyterlab_telemetry
pip uninstall jupyterlab_telemetry

打包扩展

见发布

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

jupyterlab_telemetry-1.0.3.tar.gz (16.5 kB 查看哈希)

已上传 source

内置分布

jupyterlab_telemetry-1.0.3-py3-none-any.whl (6.7 kB 查看哈希)

已上传 py3