A description of your project
Project description
execnb
Install
Either:
pip install execnb
or if you use conda:
conda install -c fastai execnb
(You can replace conda
with mamba
in the line above if you have
mamba installed.)
How to use
Use
CaptureShell
to run Jupyter code and capture notebook outputs, without running a
Jupyter server (or even having it installed):
from execnb.nbio import *
from execnb.shell import *
from fastcore.utils import *
s = CaptureShell()
s.run('1+1')
[{'data': {'text/plain': ['2']},
'metadata': {},
'output_type': 'execute_result',
'execution_count': 1}]
To execute a notebook and save it with outputs filled in, use
CaptureShell.execute
:
try:
s.execute('../tests/clean.ipynb', 'tmp.ipynb')
print(read_nb('tmp.ipynb').cells[1].outputs)
finally: Path('tmp.ipynb').unlink()
[{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': 3, 'metadata': {}, 'output_type': 'execute_result'}]
You can also execute notebooks from the command line with
exec_nb
:
!exec_nb --help
usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
[--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]
src
Execute notebook from `src` and save with outputs to `dest`
positional arguments:
src Notebook path to read from
optional arguments:
-h, --help show this help message and exit
--dest DEST Notebook path to write to (default: )
--exc_stop Stop on exceptions? (default: False)
--inject_code INJECT_CODE Code to inject into a cell
--inject_path INJECT_PATH Path to file containing code to inject into a cell
--inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
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
execnb-0.1.8.tar.gz
(14.6 kB
view details)
Built Distribution
execnb-0.1.8-py3-none-any.whl
(13.2 kB
view details)
File details
Details for the file execnb-0.1.8.tar.gz
.
File metadata
- Download URL: execnb-0.1.8.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64f4aea889125679800351d834c50e4f0fb9025f612b1a346503ef9d5b218312 |
|
MD5 | a347f2e499cd985e9bd8ca6a9f307fec |
|
BLAKE2b-256 | 99221bcfa6ebc6b6db385c5b32bee1871d95fdbd29c2d47685546414bdcd60bc |
File details
Details for the file execnb-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: execnb-0.1.8-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3de90c874d34c9c104407045e4c35e7058f062fc76cf44f87f7a199ba83c3400 |
|
MD5 | ec2495e44c90f093d3eeeda323dff343 |
|
BLAKE2b-256 | 1447c8c31807aed90018742cb0c041acb5e0c2b47ab031e4b2e4457744962c11 |