Skip to main content

A description of your project

Project description

execnb

CI Deploy to GitHub Pages

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


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.5.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

execnb-0.1.5-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file execnb-0.1.5.tar.gz.

File metadata

  • Download URL: execnb-0.1.5.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for execnb-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9ee029e0e3007c0deedc32723918c5c3bcbb64bb0b08a11fc521485ea361fa4d
MD5 d9d17cd7596bd1bde47b4f4e600c517a
BLAKE2b-256 2df55621e35bc692514db44aea307b5c2e41ac0cd1193b4251c5584e1f6fe6ce

See more details on using hashes here.

File details

Details for the file execnb-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: execnb-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for execnb-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eb5a82efb44fc86e74d2ee2656b8354acc39b751967a3fd9740593d556ea02fd
MD5 38ac454632471d150223941dde6cfe7b
BLAKE2b-256 feaeb16271d6cc0775f7b81e13dad9a9136cc0ca597402a2738a0faa8ef9eefa

See more details on using hashes here.

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