ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.24k stars 807 forks source link

How to export and import configurition? #997

Open eromoe opened 7 years ago

eromoe commented 7 years ago

I don't see any way to do this.

All Command I see is below

    jupyter nbextension list                          # list all configured nbextensions
    jupyter nbextension install --py <packagename>    # install an nbextension from a Python package
    jupyter nbextension enable --py <packagename>     # enable all nbextensions in a Python package
    jupyter nbextension disable --py <packagename>    # disable all nbextensions in a Python package
    jupyter nbextension uninstall --py <packagename>  # uninstall an nbextension in a Python package

Why not add a new command jupyter nbextension export then export a script nbextension_import.sh with content :

jupyter nbextension enable codefolding/main
jupyter nbextension enable AAA
jupyter nbextension enable BBB

or something like requirements.txt to support different platform.

jcb91 commented 7 years ago

Right, there currently isn't a neat way to do this. However, it's not quite as simple as just a list of what's enabled, since the configuration for nbextensions (certainly lots of the ones provided in this repo) can contain more detailed settings than a simple enabled/disabled status.

Also note that in common with other elements of jupyter, nbextensions can be enabled (and configured) in several different config files (one or more system-wide files, a file for the currently-running python installation, and a file for the current user) which the server reads in a set order to determine a definitive config.The jupyter config directories can be found from the output of

jupyter --paths

Directories will vary between OS, and machine settings, but for example on my (Ubuntu 16.04) machine, the relevant bit of output looks like this:

config:
    /home/josh/.jupyter
    /home/josh/miniconda3/envs/jup/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter

The configuration for nbextensions is also stored separately for each view in an nbconfig subdirectory (the notebook, edit, tree, terminals and common views, though most of ours apply to the main notebook view). To find them, you can use the following python snippet:

import glob
import os
from jupyter_core.paths import jupyter_config_path

for d in jupyter_config_path():
    for p in glob.glob(os.path.join(s, 'nbconfig', '*.json'):
        print(p)

which for me gives:

/home/josh/.jupyter/nbconfig/common.json
/home/josh/.jupyter/nbconfig/edit.json
/home/josh/.jupyter/nbconfig/tree.json
/home/josh/.jupyter/nbconfig/notebook.json
/home/josh/miniconda3/envs/jup/etc/jupyter/nbconfig/common.json
/home/josh/miniconda3/envs/jup/etc/jupyter/nbconfig/edit.json
/home/josh/miniconda3/envs/jup/etc/jupyter/nbconfig/tree.json
/home/josh/miniconda3/envs/jup/etc/jupyter/nbconfig/notebook.json

for a total of 8 separate config files, though admittedly most of the useful stuff is in /home/josh/.jupyter/nbconfig/notebook.json :/

I hope that makes sense?

juhasch commented 7 years ago

I think it would be great to have a built-in way to copy configurations. Unfortunately, as @jcb91 has explained it is not that easy.

You could open an issue at the jupyter notebook repo itself. They might already be working on a solution for this. At least your idea would be recorded then as a feature request.

jsrozner commented 4 years ago

How do I add, say, ~/.jupyter/ to the list of paths (in particular for data path)?

At the very least, one could then use dotfile synchronization to share some of the nbextensions across different setups?