runpynb


Namerunpynb JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/lsys/runPyNB
SummaryRun (and time) Jupyter Notebooks for command-line and makefile
upload_time2024-05-01 03:19:08
maintainerLucas Shen
docs_urlNone
authorLucas Shen
requires_pythonNone
licenseMIT
keywords jupyter notebook jupyter command-line makefile make nbconvert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            <div id="top"></div> 

# Run Jupyter notebooks quietly from command-line
[![PyPI](https://img.shields.io/pypi/v/runpynb?color=brightgreen&label=PyPI)](https://pypi.org/project/runpynb/)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/lsys/runpynb?label=Latest%20release)
<br>
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/runpynb?label=Python%203.6%2B)](https://pypi.org/project/runpynb/)
<br>
[![DOI](https://zenodo.org/badge/520408889.svg)](https://zenodo.org/badge/latestdoi/520408889)

`runPyNB` is a quick and dirty utility to run (and time) Jupyter notebooks from command-line and makefiles.

<!------------------- Quickstart ------------------->
## Quickstart
Install from PyPI
```bash
pip install runpynb
```

General usage: `runpynb <notebook(s)> [options]` (".ipynb" not required)

* `runpynb`: Run all notebooks in directory.

    <pre>
    $ runpynb</pre>
    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/runall.gif)

<p align="right">(<a href="#top">back to top</a>)</p>

<!------------------------ Usage ---------------------->
## Usage

* `runpynb <notebook(s)> -q`: Run quietly (`-q`).

    <pre>
    $ runpynb hello.ipynb -q</pre>
    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/be-quiet.gif)
    
* `runpynb <notebook(s)> -qs`: Run quietly (`-q`) as a sequence of workflow (`-s`). Errors (eg in `error.ipynb`) will break the workflow.

    <pre>
    $ runpynb error.ipynb hello.ipynb -qs</pre>
    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/as-sequence.gif)
    
* `runpynb <notebook(s)> -o`: Save output as separate notebook (`-o`), instead of overwriting existing notebook(s).

    <pre>
    $ runpynb hello.ipynb -o</pre>
    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/output-as-separate-notebook.gif)
    
<p align="right">(<a href="#top">back to top</a>)</p>

<!---------------------- Options ---------------------->
## Options
```bash
usage: runpynb [-h] [-t TIMEOUT] [-s] [-o] [-v VERSION] [-q] [notebooks ...]

Run (and time) Jupyter notebooks silently in command-line.

positional arguments:
  notebooks             List of Jupyter notebooks (*.ipynb) to be run
                        (default=all notebooks in path).

optional arguments:
  -h, --help            show this help message and exit
  -t TIMEOUT, --timeout TIMEOUT
                        Seconds until a cell in the notebook timesout, which
                        raises a Timeouterror exception (default is 3000=5
                        mins).
  -s, --sequence        Sequence implicit in notebook lists. If error occurs
                        somewhere, stop entire pipeline.
  -o, --output          Save output as a separate notebook with "-out"-suffix
                        (e.g. *-out.ipynb) instead of overwriting existing
                        file.
  -v VERSION, --version VERSION
                        Version of notebook to return (Default=No conversion).
                        Notebook will be converted if necessary.
  -q, --quiet           Be quiet and don't print messages (including run
                        time). Caution: Does not suppress error messages.
```
<p align="right">(<a href="#top">back to top</a>)</p>


<!----------------- Project status ----------------->
## Status
[![Documentation Status](https://readthedocs.org/projects/runpynb/badge/?version=latest)](https://runpynb.readthedocs.io/en/latest/?badge=latest)
<br>
[![Build Status](https://app.travis-ci.com/LSYS/runPyNB.svg?branch=main)](https://app.travis-ci.com/LSYS/runPyNB)
<br>
[![Tests](https://github.com/LSYS/runPyNB/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/LSYS/runPyNB/branch/main/graph/badge.svg?token=ZtC2IJ07Fa)](https://codecov.io/gh/LSYS/runPyNB)
<br>
[![CI](https://github.com/LSYS/runPyNB/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/build.yml)
<br>
[![CLI](https://github.com/LSYS/runPyNB/actions/workflows/cli.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/cli.yml)
<br>
[![Doclinks](https://github.com/LSYS/runPyNB/actions/workflows/doclinks.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/doclinks.yml)
<p align="right">(<a href="#top">back to top</a>)</p>
<br>


<!---------------------- About --------------------->
## More on this package

This is a lightweight package that wraps around the official Jupyter [`nbformat`](https://nbformat.readthedocs.io/en/latest/) and [`nbconvert`](https://nbconvert.readthedocs.io/en/latest/) modules.

My workflow involves using [`Jupyter notebooks`](https://jupyter.org/) to clean, and analyze data.
I use this utility to run notebooks silently from the command-line and [`Makefiles`](#usage-with-makefiles) (without converting from `.ipynb` files to `.py` files). 

Related packages are [`guoquan/runnb`](https://github.com/guoquan/runnb) and [`vinayak-mehta/nbcommands`](https://github.com/vinayak-mehta/nbcommands) with a planned enhancement `nbtime` to run Jupyter notebooks from command-line.
<p align="right">(<a href="#top">back to top</a>)</p>

<!---------------------- Build --------------------->
## Usage with Makefiles
A minimal workflow where `get-data.ipynb` takes 5000 seconds to prepare `data.csv`.
And where `analyze.ipynb` uses `data.csv` to produce `output.png`.
```makefile
.DEFAULT_GOAL := output.png

data.csv: get-data.ipynb
	runpynb $^ -t 5000
	
output.png: analyze.ipynb data.csv
	runpynb $< 
```
<p align="right">(<a href="#top">back to top</a>)</p>


<!-------------------- License ------------------->
## License
This package is licensed under the [MIT License](https://github.com/LSYS/runPyNB/blob/main/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lsys/runPyNB",
    "name": "runpynb",
    "maintainer": "Lucas Shen",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "lucas@lucasshen.com",
    "keywords": "jupyter notebook, jupyter, command-line, makefile, make, nbconvert",
    "author": "Lucas Shen",
    "author_email": "lucas@lucasshen.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/ca/bfe18173e778350e837ef4b2bcdf1c67381e7c93a99e8682a37279d38bfb/runpynb-0.3.0.tar.gz",
    "platform": null,
    "description": "<div id=\"top\"></div> \n\n# Run Jupyter notebooks quietly from command-line\n[![PyPI](https://img.shields.io/pypi/v/runpynb?color=brightgreen&label=PyPI)](https://pypi.org/project/runpynb/)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/lsys/runpynb?label=Latest%20release)\n<br>\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/runpynb?label=Python%203.6%2B)](https://pypi.org/project/runpynb/)\n<br>\n[![DOI](https://zenodo.org/badge/520408889.svg)](https://zenodo.org/badge/latestdoi/520408889)\n\n`runPyNB` is a quick and dirty utility to run (and time) Jupyter notebooks from command-line and makefiles.\n\n<!------------------- Quickstart ------------------->\n## Quickstart\nInstall from PyPI\n```bash\npip install runpynb\n```\n\nGeneral usage: `runpynb <notebook(s)> [options]` (\".ipynb\" not required)\n\n* `runpynb`: Run all notebooks in directory.\n\n    <pre>\n    $ runpynb</pre>\n    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/runall.gif)\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n<!------------------------ Usage ---------------------->\n## Usage\n\n* `runpynb <notebook(s)> -q`: Run quietly (`-q`).\n\n    <pre>\n    $ runpynb hello.ipynb -q</pre>\n    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/be-quiet.gif)\n    \n* `runpynb <notebook(s)> -qs`: Run quietly (`-q`) as a sequence of workflow (`-s`). Errors (eg in `error.ipynb`) will break the workflow.\n\n    <pre>\n    $ runpynb error.ipynb hello.ipynb -qs</pre>\n    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/as-sequence.gif)\n    \n* `runpynb <notebook(s)> -o`: Save output as separate notebook (`-o`), instead of overwriting existing notebook(s).\n\n    <pre>\n    $ runpynb hello.ipynb -o</pre>\n    ![](https://raw.githubusercontent.com/lsys/runpynb/main/assets/_docs/output-as-separate-notebook.gif)\n    \n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n<!---------------------- Options ---------------------->\n## Options\n```bash\nusage: runpynb [-h] [-t TIMEOUT] [-s] [-o] [-v VERSION] [-q] [notebooks ...]\n\nRun (and time) Jupyter notebooks silently in command-line.\n\npositional arguments:\n  notebooks             List of Jupyter notebooks (*.ipynb) to be run\n                        (default=all notebooks in path).\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -t TIMEOUT, --timeout TIMEOUT\n                        Seconds until a cell in the notebook timesout, which\n                        raises a Timeouterror exception (default is 3000=5\n                        mins).\n  -s, --sequence        Sequence implicit in notebook lists. If error occurs\n                        somewhere, stop entire pipeline.\n  -o, --output          Save output as a separate notebook with \"-out\"-suffix\n                        (e.g. *-out.ipynb) instead of overwriting existing\n                        file.\n  -v VERSION, --version VERSION\n                        Version of notebook to return (Default=No conversion).\n                        Notebook will be converted if necessary.\n  -q, --quiet           Be quiet and don't print messages (including run\n                        time). Caution: Does not suppress error messages.\n```\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n<!----------------- Project status ----------------->\n## Status\n[![Documentation Status](https://readthedocs.org/projects/runpynb/badge/?version=latest)](https://runpynb.readthedocs.io/en/latest/?badge=latest)\n<br>\n[![Build Status](https://app.travis-ci.com/LSYS/runPyNB.svg?branch=main)](https://app.travis-ci.com/LSYS/runPyNB)\n<br>\n[![Tests](https://github.com/LSYS/runPyNB/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/LSYS/runPyNB/branch/main/graph/badge.svg?token=ZtC2IJ07Fa)](https://codecov.io/gh/LSYS/runPyNB)\n<br>\n[![CI](https://github.com/LSYS/runPyNB/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/build.yml)\n<br>\n[![CLI](https://github.com/LSYS/runPyNB/actions/workflows/cli.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/cli.yml)\n<br>\n[![Doclinks](https://github.com/LSYS/runPyNB/actions/workflows/doclinks.yml/badge.svg?branch=main)](https://github.com/LSYS/runPyNB/actions/workflows/doclinks.yml)\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n<br>\n\n\n<!---------------------- About --------------------->\n## More on this package\n\nThis is a lightweight package that wraps around the official Jupyter [`nbformat`](https://nbformat.readthedocs.io/en/latest/) and [`nbconvert`](https://nbconvert.readthedocs.io/en/latest/) modules.\n\nMy workflow involves using [`Jupyter notebooks`](https://jupyter.org/) to clean, and analyze data.\nI use this utility to run notebooks silently from the command-line and [`Makefiles`](#usage-with-makefiles) (without converting from `.ipynb` files to `.py` files). \n\nRelated packages are [`guoquan/runnb`](https://github.com/guoquan/runnb) and [`vinayak-mehta/nbcommands`](https://github.com/vinayak-mehta/nbcommands) with a planned enhancement `nbtime` to run Jupyter notebooks from command-line.\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n<!---------------------- Build --------------------->\n## Usage with Makefiles\nA minimal workflow where `get-data.ipynb` takes 5000 seconds to prepare `data.csv`.\nAnd where `analyze.ipynb` uses `data.csv` to produce `output.png`.\n```makefile\n.DEFAULT_GOAL := output.png\n\ndata.csv: get-data.ipynb\n\trunpynb $^ -t 5000\n\t\noutput.png: analyze.ipynb data.csv\n\trunpynb $< \n```\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n<!-------------------- License ------------------->\n## License\nThis package is licensed under the [MIT License](https://github.com/LSYS/runPyNB/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Run (and time) Jupyter Notebooks for command-line and makefile",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/lsys/runPyNB"
    },
    "split_keywords": [
        "jupyter notebook",
        " jupyter",
        " command-line",
        " makefile",
        " make",
        " nbconvert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ccabfe18173e778350e837ef4b2bcdf1c67381e7c93a99e8682a37279d38bfb",
                "md5": "27e761e244986b8ba9c50b73a748802f",
                "sha256": "e6cc75b365acbac68949c53b23ccaf7ee588299a90c418d925d260ed8368031a"
            },
            "downloads": -1,
            "filename": "runpynb-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "27e761e244986b8ba9c50b73a748802f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6227,
            "upload_time": "2024-05-01T03:19:08",
            "upload_time_iso_8601": "2024-05-01T03:19:08.308911Z",
            "url": "https://files.pythonhosted.org/packages/6c/ca/bfe18173e778350e837ef4b2bcdf1c67381e7c93a99e8682a37279d38bfb/runpynb-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-01 03:19:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lsys",
    "github_project": "runPyNB",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "runpynb"
}
        
Elapsed time: 0.25713s