https://github.com/noteable-io/papermill-origami
A papermill engine for running Noteable notebooks
https://github.com/noteable-io/papermill-origami
Last synced: 10 months ago
JSON representation
A papermill engine for running Noteable notebooks
- Host: GitHub
- URL: https://github.com/noteable-io/papermill-origami
- Owner: noteable-io
- License: bsd-3-clause
- Created: 2022-05-20T03:48:37.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-29T18:59:12.000Z (over 2 years ago)
- Last Synced: 2025-03-23T22:42:24.262Z (about 1 year ago)
- Language: Python
- Homepage: https://papermill-origami.readthedocs.io
- Size: 1.63 MB
- Stars: 7
- Watchers: 2
- Forks: 4
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# papermill-origami
A papermill engine for running Noteable notebooks
---------
[Install](#installation) | [Getting Started](#getting-started) | [Documentation](https://papermill-origami.readthedocs.io/) | [License](./LICENSE) | [Code of Conduct](./CODE_OF_CONDUCT.md) | [Contributing](./CONTRIBUTING.md)
## Intro to Papermill-Origami
Papermill-Origami is the bridge library between the [Origami Noteable SDK](https://noteable-origami.readthedocs.io/en/latest/) and [Papermill](https://papermill.readthedocs.io/en/latest/). The papermill engine can talk to Noteable APIs to run Notebooks.
## Requirements
Python 3.8+
## Installation
### Poetry
```shell
poetry add papermill-origami
```
### Pip
```shell
pip install papermill-origami
```
## Getting Started
### API Token
Get your access token from your User Settings -> API Tokens
or alternatively you can generate a post request to generate a new token
```
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"
}'
```
### Engine Registration
The `noteable` engine keyword will use the following environment variables by default:
```bash
NOTEABLE_DOMAIN = app.noteable.io
NOTEABLE_TOKEN = MY_TOKEN_VALUE_HERE
```
Then the engine is enabled by running papermill as normal. But now you have access to
the `noteable://` scheme as well as the ability to tell papermill to use Noteable as
the execution location for your notebook.
```python
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
)
```
#### Advanced Setup
For more advanced control or reuse of a NoteableClient SDK object you can use
the async await pattern around a client constructor. This reuses the connection
throughout the life cycle of the context block.
```python
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
See [CONTRIBUTING.md](./CONTRIBUTING.md).
-------
Open sourced with ❤️ by Noteable for the community.