The Noteable API interface
Project description
Origami
Launch, edit, and share Jupyter notebooks in automation.
Install | Getting Started | Documentation | License | Code of Conduct | Contributing
Intro to Origami
Origami is a 🐍 Python library for talking to Noteable notebooks. This is the official way to access the full breadth of API calls and access patterns in async Python for rich programmatic access to notebooks. You can use Noteable for free with a quick signup.
Requirements
Python 3.8+
Installation
For stable release:
pip install noteable-origami
poetry add noteable-origami
For alpha pre-release:
pip install noteable-origami --pre
Getting Started
Warning Developer note: this documentation is written for the 1.0 alpha release. For stable release, see pre-1.0 README
API Tokens
The Noteable API requires an authentication token. You can manage tokens at the Noteable user settings page.
- Log in to Noteable (sign up is free)
- In the User Settings tab, navigate to
API Tokens
and generate a new token
Usage
The example below shows how to create a Notebook, launch a Kernel, add new cells, and execute code.
# Get your API token from the User Settings page by clicking your account name in the upper right
api_token = os.environ['NOTEABLE_TOKEN']
# Client for interacting with Noteables REST API
from origami.clients.api import APIClient
api_client = APIClient(api_token)
# Sanity check your user information
user = await api_client.user_info()
# Choose a project to create the notebook in, here using the ChatGPT plugin default project
project_id = user.origamist_default_project_id
# Create a new Notebook
file = await api_client.create_notebook(project_id=project_id, path="Demo.ipynb")
# Start a Kernel
await api_client.launch_kernel(file.id)
# Client for Real-time Updates (RTU), used with Notebooks
realtime_notebook = await api_client.connect_realtime(file)
# Add a new cell
from origami.models.notebook import CodeCell
cell = CodeCell(source="print('Hello World')")
await realtime_notebook.add_cell(cell)
# Execute the cell. The returned value is a dictionary of Futures. Awaiting those futures will
# block until the cells have completed execution
queued_execution = await realtime_notebook.queue_execution(cell.id)
# The return value of the Futures is the up-to-date cell. If there's output, an output collection id
# will be set on the cell metadata
cells = await asyncio.gather(*queued_execution)
# Grab the output
cell = cells[0]
output_collection = await api_client.get_output_collection(cell.output_collection_id)
print(output_collection.outputs[0].content.raw) # 'Hello World\n'
1.0 Roadmap
Origami 1.0 implies that we have a stable architecture such as a split of APIClient
and RTUClient
and the layout of the RTU modeling. Some syntax may change as Origami is integrated into production components. Any breaking changes will be a minor version bump.
Contributing
See CONTRIBUTING.md.
Open sourced with ❤️ by Noteable for the community.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for noteable_origami-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c607e075eb4521305c3a5b3f337fa4d7bd0954ac4c814ecd62ef3d46537c7fb0 |
|
MD5 | a1d8182419ce27bde663a76ff00884a2 |
|
BLAKE2b-256 | 53bc24bf4dd8b866b25ba36a36738dcde045651a5b07cfcac6e03da254826730 |