Skip to main content

The Noteable API interface

Project description

Origami


Launch, edit, and share Jupyter notebooks in automation.

CI codecov code coverage PyPI - License PyPI - Python Version PyPI Code style: black


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.

  1. Log in to Noteable (sign up is free)
  2. 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.

Boost Data Collaboration with Notebooks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noteable_origami-1.0.0.tar.gz (34.0 kB view hashes)

Uploaded Source

Built Distribution

noteable_origami-1.0.0-py3-none-any.whl (42.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page