execnb


Nameexecnb JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/fastai/execnb/
SummaryA description of your project
upload_time2024-05-06 00:46:34
maintainerNone
docs_urlNone
authorJeremy Howard
requires_python>=3.7
licenseApache Software License 2.0
keywords some keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # execnb


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

[![CI](https://github.com/fastai/execnb/actions/workflows/test.yaml/badge.svg)](https://github.com/fastai/execnb/actions/workflows/test.yaml)
[![Deploy to GitHub
Pages](https://github.com/fastai/execnb/actions/workflows/deploy.yaml/badge.svg)](https://github.com/fastai/execnb/actions/workflows/deploy.yaml)

## 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`](https://fastai.github.io/execnb/shell.html#captureshell)
to run Jupyter code and capture notebook outputs, without running a
Jupyter server (or even having it installed):

``` python
from execnb.nbio import *
from execnb.shell import *
from fastcore.utils import *
```

``` python
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`](https://fastai.github.io/execnb/shell.html#captureshell.execute):

``` python
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`](https://fastai.github.io/execnb/shell.html#exec_nb):

``` python
!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)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fastai/execnb/",
    "name": "execnb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "some keywords",
    "author": "Jeremy Howard",
    "author_email": "j@fast.ai",
    "download_url": "https://files.pythonhosted.org/packages/18/89/bf1d1b8acef9d6743c55759c89f3a27aff2f7f9946a397fae3d53f5aea2c/execnb-0.1.6.tar.gz",
    "platform": null,
    "description": "# execnb\n\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n[![CI](https://github.com/fastai/execnb/actions/workflows/test.yaml/badge.svg)](https://github.com/fastai/execnb/actions/workflows/test.yaml)\n[![Deploy to GitHub\nPages](https://github.com/fastai/execnb/actions/workflows/deploy.yaml/badge.svg)](https://github.com/fastai/execnb/actions/workflows/deploy.yaml)\n\n## Install\n\nEither:\n\n    pip install execnb\n\nor if you use conda:\n\n    conda install -c fastai execnb\n\n(You can replace `conda` with `mamba` in the line above if you have\nmamba installed.)\n\n## How to use\n\nUse\n[`CaptureShell`](https://fastai.github.io/execnb/shell.html#captureshell)\nto run Jupyter code and capture notebook outputs, without running a\nJupyter server (or even having it installed):\n\n``` python\nfrom execnb.nbio import *\nfrom execnb.shell import *\nfrom fastcore.utils import *\n```\n\n``` python\ns = CaptureShell()\ns.run('1+1')\n```\n\n    [{'data': {'text/plain': ['2']},\n      'metadata': {},\n      'output_type': 'execute_result',\n      'execution_count': 1}]\n\nTo execute a notebook and save it with outputs filled in, use\n[`CaptureShell.execute`](https://fastai.github.io/execnb/shell.html#captureshell.execute):\n\n``` python\ntry:\n    s.execute('../tests/clean.ipynb', 'tmp.ipynb')\n    print(read_nb('tmp.ipynb').cells[1].outputs)\nfinally: Path('tmp.ipynb').unlink()\n```\n\n    [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']}, {'data': {'text/plain': ['2']}, 'execution_count': 3, 'metadata': {}, 'output_type': 'execute_result'}]\n\nYou can also execute notebooks from the command line with\n[`exec_nb`](https://fastai.github.io/execnb/shell.html#exec_nb):\n\n``` python\n!exec_nb --help\n```\n\n    usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]\n                   [--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]\n                   src\n\n    Execute notebook from `src` and save with outputs to `dest`\n\n    positional arguments:\n      src                        Notebook path to read from\n\n    optional arguments:\n      -h, --help                 show this help message and exit\n      --dest DEST                Notebook path to write to (default: )\n      --exc_stop                 Stop on exceptions? (default: False)\n      --inject_code INJECT_CODE  Code to inject into a cell\n      --inject_path INJECT_PATH  Path to file containing code to inject into a cell\n      --inject_idx INJECT_IDX    Cell to replace with `inject_code` (default: 0)\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "A description of your project",
    "version": "0.1.6",
    "project_urls": {
        "Homepage": "https://github.com/fastai/execnb/"
    },
    "split_keywords": [
        "some",
        "keywords"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fbc2f2bf7d821f04556efde49a1af531bdf287b27c19225852287cbfca953300",
                "md5": "b7915827bb70c1c57523672b2ae2bc5c",
                "sha256": "095b74984efe40804a3e9535be3936fa657fd76a1227c2c839672dfc0bb2816a"
            },
            "downloads": -1,
            "filename": "execnb-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b7915827bb70c1c57523672b2ae2bc5c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 14277,
            "upload_time": "2024-05-06T00:46:33",
            "upload_time_iso_8601": "2024-05-06T00:46:33.014464Z",
            "url": "https://files.pythonhosted.org/packages/fb/c2/f2bf7d821f04556efde49a1af531bdf287b27c19225852287cbfca953300/execnb-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1889bf1d1b8acef9d6743c55759c89f3a27aff2f7f9946a397fae3d53f5aea2c",
                "md5": "c9c32a2fdfdc037202537bc94a2650cd",
                "sha256": "289d97107a856344b16c08953d60453b47320b41168060eca3cc2dee504b4e05"
            },
            "downloads": -1,
            "filename": "execnb-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "c9c32a2fdfdc037202537bc94a2650cd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 15256,
            "upload_time": "2024-05-06T00:46:34",
            "upload_time_iso_8601": "2024-05-06T00:46:34.836023Z",
            "url": "https://files.pythonhosted.org/packages/18/89/bf1d1b8acef9d6743c55759c89f3a27aff2f7f9946a397fae3d53f5aea2c/execnb-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-06 00:46:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fastai",
    "github_project": "execnb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "execnb"
}
        
Elapsed time: 0.24982s