Package: nbautoexport
nbautoexportMaking it easier to code review Jupyter notebooks, one script at a time.nbautoexportautomatically 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 tofacilitate code review commenting.InstallationFirst, you will need to installnbautoexport. This should be installed in the same environment you are running Jupyter Notebook or Jupyter Lab from.nbautoexportis available either fromPyPIviapipor fromconda-forgeviaconda.pipinstallnbautoexportcondainstallnbautoexport--channelconda-forgeThen, to registernbautoexportto run automatically while using Jupyter Notebook or Jupyter Lab, run:nbautoexportinstallIf you already have a Jupyter server running, you will need to restart it for this to take effect.Simple usageLet's say you have a project and keep your notebooks in anotebooks/subdirectory.To configure that directory for automatic exporting, run the following command:nbautoexportconfigurenotebooksThis will create a configuration filenotebooks/.nbautoexport.If you've set upnbautoexportto work with Jupyter (using theinstallcommand 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.nbautoexportconfiguration 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.pyextension) and saved in the directorynotebooks/script.If everything is working, your notebooks directory should end up with files like the below example: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.pyConfiguring export optionsThe default.nbautoexportconfiguration file looks like this:{"export_formats":["script"],"organize_by":"extension"}Upon save, this will lead to notebooks being exported to scripts which saved to thenotebooks/scriptdirectory.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.pyAn 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.nbautoexportconfigurenotebooks--organize-bynotebooknotebooks
├── 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.ipynbIf you do not like the settings you selected, you can always change them by either 1) re-running thenbautoexportcommand with new arguments and the--overwriteflag, or 2) manually editing the.nbautoexportfile.You can also specify as many export formats as you'd like. We support most of the export formats available fromnbconvert, such ashtml,md, andpdf. To specify formats, use the--export-formatfor each format you want to include.Advanced examplenbautoexportconfiguresprint_one_notebooks-fscript-fhtml--organize-byextensionUpon save, this creates.pyand.htmlversions of the Jupyter notebooks insprint_one_notebooksfolder and results in the following organization: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.htmlMore functionalityThenbautoexportCLI has two additional commands:exportis for ad hoc exporting of a notebook or directory of notebooksclean(EXPERIMENTAL) will delete files in a directory that are not generated by the current.nbautoexportconfigurationUse the--helpflag to see the documentation.Command-line helpnbautoexport--helpUsage: 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 usingCookiecutterwithaudreyr/cookiecutter-pypackage.