execnb


Nameexecnb JSON
Version 0.1.11 PyPI version JSON
download
home_pagehttps://github.com/AnswerDotAI/execnb/
SummaryA description of your project
upload_time2024-12-04 17:35:17
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://AnswerDotAI.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://AnswerDotAI.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://AnswerDotAI.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/AnswerDotAI/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/24/d5/110ed8c5d6ad6dc64ae1bd2677ca93284b9689d70ec0a9129bb2ce5fad67/execnb-0.1.11.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://AnswerDotAI.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://AnswerDotAI.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://AnswerDotAI.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.11",
    "project_urls": {
        "Homepage": "https://github.com/AnswerDotAI/execnb/"
    },
    "split_keywords": [
        "some",
        "keywords"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e98440f1c5b5e7c28de76f33726b48227ea1d06d4b9c8c99779e071bb0f595eb",
                "md5": "2674355fce76574d47aebc2554009b99",
                "sha256": "ab99a761ffe59c45820d67f438b2515380e70da1ff67422223dc1c2688bbd85c"
            },
            "downloads": -1,
            "filename": "execnb-0.1.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2674355fce76574d47aebc2554009b99",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 13577,
            "upload_time": "2024-12-04T17:35:15",
            "upload_time_iso_8601": "2024-12-04T17:35:15.710120Z",
            "url": "https://files.pythonhosted.org/packages/e9/84/40f1c5b5e7c28de76f33726b48227ea1d06d4b9c8c99779e071bb0f595eb/execnb-0.1.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24d5110ed8c5d6ad6dc64ae1bd2677ca93284b9689d70ec0a9129bb2ce5fad67",
                "md5": "c014820f22faab506669c1a3e4331920",
                "sha256": "ebb37688adb5434300c25867c6944b7ca0c5b003cb7f5fdacf89eb7dfe4cf8e8"
            },
            "downloads": -1,
            "filename": "execnb-0.1.11.tar.gz",
            "has_sig": false,
            "md5_digest": "c014820f22faab506669c1a3e4331920",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14915,
            "upload_time": "2024-12-04T17:35:17",
            "upload_time_iso_8601": "2024-12-04T17:35:17.594282Z",
            "url": "https://files.pythonhosted.org/packages/24/d5/110ed8c5d6ad6dc64ae1bd2677ca93284b9689d70ec0a9129bb2ce5fad67/execnb-0.1.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-04 17:35:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AnswerDotAI",
    "github_project": "execnb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "execnb"
}
        
Elapsed time: 0.40156s