nbautoexport


Namenbautoexport JSON
Version 0.5.2 PyPI version JSON
download
home_page
SummaryAutomatically export Jupyter notebooks to various file formats (.py, .html, and more) on save.
upload_time2023-07-28 21:10:40
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT
keywords nbautoexport jupyter nbconvert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # nbautoexport

[![Docs Status](https://img.shields.io/badge/docs-stable-informational)](https://nbautoexport.drivendata.org/)
[![PyPI](https://img.shields.io/pypi/v/nbautoexport.svg)](https://pypi.org/project/nbautoexport/)
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/nbautoexport.svg)](https://anaconda.org/conda-forge/nbautoexport)
[![tests](https://github.com/drivendataorg/nbautoexport/workflows/tests/badge.svg?branch=master)](https://github.com/drivendataorg/nbautoexport/actions?query=workflow%3Atests+branch%3Amaster)
[![codecov](https://codecov.io/gh/drivendataorg/nbautoexport/branch/master/graph/badge.svg)](https://codecov.io/gh/drivendataorg/nbautoexport)

> Making it easier to code review Jupyter notebooks, one script at a time.

`nbautoexport` automatically exports Jupyter notebooks to various file formats (.py, .html, and more) upon save while using Jupyter. One great use case is to automatically have script versions of your notebooks to [facilitate code review commenting](https://www.drivendata.co/blog/nbautoexport-jupyter-code-review/).

## Installation

First, you will need to install `nbautoexport`. This should be installed in the same environment you are running Jupyter Notebook or Jupyter Lab from. `nbautoexport` is available either from [PyPI](https://pypi.org/project/nbautoexport/) via `pip` or from [conda-forge](https://github.com/conda-forge/nbautoexport-feedstock) via `conda`.

```bash
pip install nbautoexport
```

```bash
conda install nbautoexport --channel conda-forge
```

Then, to register `nbautoexport` to run automatically while using Jupyter Notebook or Jupyter Lab, run:

```bash
nbautoexport install
```

If you already have a Jupyter server running, you will need to restart it for this to take effect.

## Simple usage

Let's say you have a project and keep your notebooks in a `notebooks/` subdirectory.

To configure that directory for automatic exporting, run the following command:

```bash
nbautoexport configure notebooks
```

This will create a configuration file `notebooks/.nbautoexport`.

If you've set up `nbautoexport` to work with Jupyter (using the `install` command as detailed in the previous section), then any time you save a notebook in Jupyter, a hook will run that checks whether there is a `.nbautoexport` configuration file in the same directory as the notebook. If so, it will use the settings specified in that file to export your notebook. By default, it will generate a script version of your notebook named after the notebook (with the `.py` extension) and saved in the directory `notebooks/script`.

If everything is working, your notebooks directory should end up with files like the below example:

```text
notebooks
├──0.1-ejm-data-exploration.ipynb
├──0.2-ejm-feature-creation.ipynb
└── script
    └── 0.1-ejm-data-exploration.py
    └── 0.2-ejm-feature-creation.py
```

## Configuring export options

The default `.nbautoexport` configuration file looks like this:

```json
{
  "export_formats": [
    "script"
  ],
  "organize_by": "extension"
}
```

Upon save, this will lead to notebooks being exported to scripts which saved to the `notebooks/script` directory.

```text
notebooks
├──0.1-ejm-data-exploration.ipynb
├──0.2-ejm-feature-creation.ipynb
└── script
    └── 0.1-ejm-data-exploration.py
    └── 0.2-ejm-feature-creation.py
```

An alternative way to organize exported files is to create a directory for each notebook. This can be handy for matching both the notebook and subdirectory when tab-completing and then globbing with `*` after the part that completed.

```bash
nbautoexport configure notebooks --organize-by notebook
```

```text
notebooks
├── 0.1-ejm-data-exploration
│   └── 0.1-ejm-data-exploration.py
├── 0.2-ejm-feature-creation
│   └── 0.2-ejm-feature-creation.py
├──0.1-ejm-data-exploration.ipynb
└──0.2-ejm-feature-creation.ipynb
```

If you do not like the settings you selected, you can always change them by either 1) re-running the `nbautoexport` command with new arguments and the `--overwrite` flag, or 2) manually editing the `.nbautoexport` file.

You can also specify as many export formats as you'd like. We support most of the export formats available from [`nbconvert`](https://nbconvert.readthedocs.io/en/latest/), such as `html`, `md`, and `pdf`. To specify formats, use the `--export-format` for each format you want to include.


### Advanced example

```bash
nbautoexport configure sprint_one_notebooks -f script -f html --organize-by extension
```

Upon save, this creates `.py` and `.html` versions of the Jupyter notebooks in `sprint_one_notebooks` folder and results in the following organization:

```text
notebooks
├──0.1-ejm-data-exploration.ipynb
├──0.2-ejm-feature-creation.ipynb
├── script
│   └── 0.1-ejm-data-exploration.py
│   └── 0.1-ejm-features-creation.py
└── html
    └── 0.1-ejm-data-exploration.html
    └── 0.1-ejm-features-creation.html
```

## More functionality

The `nbautoexport` CLI has two additional commands:

- `export` is for ad hoc exporting of a notebook or directory of notebooks
- `clean` (EXPERIMENTAL) will delete files in a directory that are not generated by the current `.nbautoexport` configuration

Use the `--help` flag to see the documentation.

## Command-line help

```bash
nbautoexport --help
```

```text
Usage: nbautoexport [OPTIONS] COMMAND [ARGS]...

  Automatically export Jupyter notebooks to various file formats (.py,
  .html, and more) upon save. One great use case is to automatically have
  script versions of your notebooks to facilitate code review commenting.

  To set up, first use the 'install' command to register nbautoexport with
  Jupyter. If you already have a Jupyter server running, you will need to
  restart it.

  Next, you will need to use the 'configure' command to create a
  .nbautoexport configuration file in the same directory as the notebooks
  you want to have export automatically.

  Once nbautoexport is installed with the first step, exporting will run
  automatically when saving a notebook in Jupyter for any notebook where
  there is a .nbautoexport configuration file in the same directory.

Options:
  --version             Show nbautoexport version.
  --install-completion  Install completion for the current shell.
  --show-completion     Show completion for the current shell, to copy it or
                        customize the installation.

  --help                Show this message and exit.

Commands:
  clean      (EXPERIMENTAL) Remove subfolders/files not matching...
  configure  Create a .nbautoexport configuration file in a directory.
  export     Manually export notebook or directory of notebooks.
  install    Register nbautoexport post-save hook with Jupyter.
```

---

This repository was initially created using [Cookiecutter](https://github.com/audreyr/cookiecutter) with [`audreyr/cookiecutter-pypackage`](https://github.com/audreyr/cookiecutter-pypackage).


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "nbautoexport",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "nbautoexport,jupyter,nbconvert",
    "author": "",
    "author_email": "DrivenData <info@drivendata.org>",
    "download_url": "https://files.pythonhosted.org/packages/18/6c/47566221aaaf7d04da925923fbbacefb24da1c724b32506ceb3d5ed2fbc1/nbautoexport-0.5.2.tar.gz",
    "platform": null,
    "description": "# nbautoexport\n\n[![Docs Status](https://img.shields.io/badge/docs-stable-informational)](https://nbautoexport.drivendata.org/)\n[![PyPI](https://img.shields.io/pypi/v/nbautoexport.svg)](https://pypi.org/project/nbautoexport/)\n[![conda-forge](https://img.shields.io/conda/vn/conda-forge/nbautoexport.svg)](https://anaconda.org/conda-forge/nbautoexport)\n[![tests](https://github.com/drivendataorg/nbautoexport/workflows/tests/badge.svg?branch=master)](https://github.com/drivendataorg/nbautoexport/actions?query=workflow%3Atests+branch%3Amaster)\n[![codecov](https://codecov.io/gh/drivendataorg/nbautoexport/branch/master/graph/badge.svg)](https://codecov.io/gh/drivendataorg/nbautoexport)\n\n> Making it easier to code review Jupyter notebooks, one script at a time.\n\n`nbautoexport` automatically exports Jupyter notebooks to various file formats (.py, .html, and more) upon save while using Jupyter. One great use case is to automatically have script versions of your notebooks to [facilitate code review commenting](https://www.drivendata.co/blog/nbautoexport-jupyter-code-review/).\n\n## Installation\n\nFirst, you will need to install `nbautoexport`. This should be installed in the same environment you are running Jupyter Notebook or Jupyter Lab from. `nbautoexport` is available either from [PyPI](https://pypi.org/project/nbautoexport/) via `pip` or from [conda-forge](https://github.com/conda-forge/nbautoexport-feedstock) via `conda`.\n\n```bash\npip install nbautoexport\n```\n\n```bash\nconda install nbautoexport --channel conda-forge\n```\n\nThen, to register `nbautoexport` to run automatically while using Jupyter Notebook or Jupyter Lab, run:\n\n```bash\nnbautoexport install\n```\n\nIf you already have a Jupyter server running, you will need to restart it for this to take effect.\n\n## Simple usage\n\nLet's say you have a project and keep your notebooks in a `notebooks/` subdirectory.\n\nTo configure that directory for automatic exporting, run the following command:\n\n```bash\nnbautoexport configure notebooks\n```\n\nThis will create a configuration file `notebooks/.nbautoexport`.\n\nIf you've set up `nbautoexport` to work with Jupyter (using the `install` command as detailed in the previous section), then any time you save a notebook in Jupyter, a hook will run that checks whether there is a `.nbautoexport` configuration file in the same directory as the notebook. If so, it will use the settings specified in that file to export your notebook. By default, it will generate a script version of your notebook named after the notebook (with the `.py` extension) and saved in the directory `notebooks/script`.\n\nIf everything is working, your notebooks directory should end up with files like the below example:\n\n```text\nnotebooks\n\u251c\u2500\u25000.1-ejm-data-exploration.ipynb\n\u251c\u2500\u25000.2-ejm-feature-creation.ipynb\n\u2514\u2500\u2500 script\n    \u2514\u2500\u2500 0.1-ejm-data-exploration.py\n    \u2514\u2500\u2500 0.2-ejm-feature-creation.py\n```\n\n## Configuring export options\n\nThe default `.nbautoexport` configuration file looks like this:\n\n```json\n{\n  \"export_formats\": [\n    \"script\"\n  ],\n  \"organize_by\": \"extension\"\n}\n```\n\nUpon save, this will lead to notebooks being exported to scripts which saved to the `notebooks/script` directory.\n\n```text\nnotebooks\n\u251c\u2500\u25000.1-ejm-data-exploration.ipynb\n\u251c\u2500\u25000.2-ejm-feature-creation.ipynb\n\u2514\u2500\u2500 script\n    \u2514\u2500\u2500 0.1-ejm-data-exploration.py\n    \u2514\u2500\u2500 0.2-ejm-feature-creation.py\n```\n\nAn alternative way to organize exported files is to create a directory for each notebook. This can be handy for matching both the notebook and subdirectory when tab-completing and then globbing with `*` after the part that completed.\n\n```bash\nnbautoexport configure notebooks --organize-by notebook\n```\n\n```text\nnotebooks\n\u251c\u2500\u2500 0.1-ejm-data-exploration\n\u2502   \u2514\u2500\u2500 0.1-ejm-data-exploration.py\n\u251c\u2500\u2500 0.2-ejm-feature-creation\n\u2502   \u2514\u2500\u2500 0.2-ejm-feature-creation.py\n\u251c\u2500\u25000.1-ejm-data-exploration.ipynb\n\u2514\u2500\u25000.2-ejm-feature-creation.ipynb\n```\n\nIf you do not like the settings you selected, you can always change them by either 1) re-running the `nbautoexport` command with new arguments and the `--overwrite` flag, or 2) manually editing the `.nbautoexport` file.\n\nYou can also specify as many export formats as you'd like. We support most of the export formats available from [`nbconvert`](https://nbconvert.readthedocs.io/en/latest/), such as `html`, `md`, and `pdf`. To specify formats, use the `--export-format` for each format you want to include.\n\n\n### Advanced example\n\n```bash\nnbautoexport configure sprint_one_notebooks -f script -f html --organize-by extension\n```\n\nUpon save, this creates `.py` and `.html` versions of the Jupyter notebooks in `sprint_one_notebooks` folder and results in the following organization:\n\n```text\nnotebooks\n\u251c\u2500\u25000.1-ejm-data-exploration.ipynb\n\u251c\u2500\u25000.2-ejm-feature-creation.ipynb\n\u251c\u2500\u2500 script\n\u2502   \u2514\u2500\u2500 0.1-ejm-data-exploration.py\n\u2502   \u2514\u2500\u2500 0.1-ejm-features-creation.py\n\u2514\u2500\u2500 html\n    \u2514\u2500\u2500 0.1-ejm-data-exploration.html\n    \u2514\u2500\u2500 0.1-ejm-features-creation.html\n```\n\n## More functionality\n\nThe `nbautoexport` CLI has two additional commands:\n\n- `export` is for ad hoc exporting of a notebook or directory of notebooks\n- `clean` (EXPERIMENTAL) will delete files in a directory that are not generated by the current `.nbautoexport` configuration\n\nUse the `--help` flag to see the documentation.\n\n## Command-line help\n\n```bash\nnbautoexport --help\n```\n\n```text\nUsage: nbautoexport [OPTIONS] COMMAND [ARGS]...\n\n  Automatically export Jupyter notebooks to various file formats (.py,\n  .html, and more) upon save. One great use case is to automatically have\n  script versions of your notebooks to facilitate code review commenting.\n\n  To set up, first use the 'install' command to register nbautoexport with\n  Jupyter. If you already have a Jupyter server running, you will need to\n  restart it.\n\n  Next, you will need to use the 'configure' command to create a\n  .nbautoexport configuration file in the same directory as the notebooks\n  you want to have export automatically.\n\n  Once nbautoexport is installed with the first step, exporting will run\n  automatically when saving a notebook in Jupyter for any notebook where\n  there is a .nbautoexport configuration file in the same directory.\n\nOptions:\n  --version             Show nbautoexport version.\n  --install-completion  Install completion for the current shell.\n  --show-completion     Show completion for the current shell, to copy it or\n                        customize the installation.\n\n  --help                Show this message and exit.\n\nCommands:\n  clean      (EXPERIMENTAL) Remove subfolders/files not matching...\n  configure  Create a .nbautoexport configuration file in a directory.\n  export     Manually export notebook or directory of notebooks.\n  install    Register nbautoexport post-save hook with Jupyter.\n```\n\n---\n\nThis repository was initially created using [Cookiecutter](https://github.com/audreyr/cookiecutter) with [`audreyr/cookiecutter-pypackage`](https://github.com/audreyr/cookiecutter-pypackage).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Automatically export Jupyter notebooks to various file formats (.py, .html, and more) on save.",
    "version": "0.5.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/drivendataorg/nbautoexport/issues",
        "Changelog": "https://nbautoexport.drivendata.org/stable/changelog/",
        "Documentation": "https://nbautoexport.drivendata.org/",
        "Homepage": "https://github.com/drivendataorg/nbautoexport",
        "Repository": "https://github.com/drivendataorg/nbautoexport"
    },
    "split_keywords": [
        "nbautoexport",
        "jupyter",
        "nbconvert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e814bda5b373cf506fed8fd37dd627a3869038a436e808faf8a0a21c899da85c",
                "md5": "c8ab23b01764121d8e22b50300be3e8c",
                "sha256": "ebec5c28451dac96afbdfee74d67ad0be28070ce4228f340e4b745ac817b95c1"
            },
            "downloads": -1,
            "filename": "nbautoexport-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c8ab23b01764121d8e22b50300be3e8c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16768,
            "upload_time": "2023-07-28T21:10:38",
            "upload_time_iso_8601": "2023-07-28T21:10:38.549929Z",
            "url": "https://files.pythonhosted.org/packages/e8/14/bda5b373cf506fed8fd37dd627a3869038a436e808faf8a0a21c899da85c/nbautoexport-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "186c47566221aaaf7d04da925923fbbacefb24da1c724b32506ceb3d5ed2fbc1",
                "md5": "d9deef4ab7a585add812c0811bd9b201",
                "sha256": "3342149ad0a6330b4402d44b94e63bf60d6062b74e31d300e6d1435e990be6ac"
            },
            "downloads": -1,
            "filename": "nbautoexport-0.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d9deef4ab7a585add812c0811bd9b201",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 39941,
            "upload_time": "2023-07-28T21:10:40",
            "upload_time_iso_8601": "2023-07-28T21:10:40.030628Z",
            "url": "https://files.pythonhosted.org/packages/18/6c/47566221aaaf7d04da925923fbbacefb24da1c724b32506ceb3d5ed2fbc1/nbautoexport-0.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-28 21:10:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "drivendataorg",
    "github_project": "nbautoexport",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nbautoexport"
}
        
Elapsed time: 0.10429s