跳转到主要内容

值得注意的API接口

项目描述

papermill-origami

A papermill engine for running Noteable notebooks

CI PyPI - License PyPI - Python Version PyPI Code style: black


安装 | 入门 | 文档 | 许可证 | 行为准则 | 贡献

Papermill-Origami简介

Papermill-Origami是Origami Noteable SDKPapermill之间的桥梁库。Papermill引擎可以与Noteable API通信以运行Notebooks。

要求

Python 3.8+

安装

Poetry

poetry add papermill-origami

Pip

pip install papermill-origami

入门

API令牌

从您的用户设置 -> API令牌获取您的访问令牌

或者您也可以生成一个POST请求以生成新的令牌

curl -X 'POST' \
  'https://app.noteable.io/gate/api/v1/tokens' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "ttl": 31536000,
  "name": "my_token"
}'

发动机注册

默认情况下,noteable 引擎关键字将使用以下环境变量

NOTEABLE_DOMAIN = app.noteable.io
NOTEABLE_TOKEN = MY_TOKEN_VALUE_HERE

然后通过正常运行 papermill 启用引擎。但现在您还可以访问 noteable:// 方案,并可以将 Noteable 作为笔记本的执行位置告诉 papermill。

import papermill as pm

file_id = '...'

pm.execute_notebook(
    f'noteable://{file_id}',
    None, # Set no particular output notebook, but a log of the resulting exeuction link still prints
    # This turns on the Noteable API interface
    engine_name='noteable', # exclude this kwarg to run the Notebook locally
)

高级设置

为了更高级的控制或重复使用 NoteableClient SDK 对象,您可以在客户端构造函数周围使用 async await 模式。这将在上下文块的生命周期内重复使用连接。

import papermill as pm
from papermill.iorw import papermill_io
from papermill_origami import ClientConfig, NoteableClient, NoteableHandler 


domain = 'app.noteable.io'
token = MY_TOKEN_VALUE_HERE
file_id = '...'

async with NoteableClient(token, config=ClientConfig(domain=domain)) as client:
    file = await client.get_notebook(file_id)
    papermill_io.register("noteable://", NoteableHandler(client))
    pm.execute_notebook(
        f'noteable://{file_id}',
        None,
        engine_name='noteable',
        # Noteable-specific kwargs
        file=file,
        client=client,
    )

贡献

请参阅 CONTRIBUTING.md


Noteable 开源,并充满爱心地为社区服务。

Boost Data Collaboration with Notebooks

项目详情


下载文件

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

源分发

papermill_origami-0.0.30.tar.gz (28.5 kB 查看哈希值)

上传时间

构建分发

papermill_origami-0.0.30-py3-none-any.whl (35.9 kB 查看哈希值)

上传时间 Python 3

支持者