Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple directories and/or subdirectories in IPython Notebook session?

The IPython documentation pages suggest that opening several different sessions of IPython notebook is the only way to interact with saved notebooks in different directories or subdirectories, but this is not explicitly confirmed anywhere.

I am facing a situation where I might need to interact with hundreds of different notebooks, which are classified according to different properties and stored in subdirectories of a main directory. I have set that main directory (let's call it /main) in the ipython_notebook_config.py configuration file to be the default directory.

When I launch IPython notebook, indeed it displays any saved notebooks that are within /main (but not saved notebooks within subdirectories within /main).

How can I achieve one single IPython dashboard that shows me the notebooks within /main and also shows subdirectories, lets me expand a subdirectory and choose from its contents, or just shows all notebooks from all subdirectories?

Doing this by launching new instances of IPython every time is completely out of the question.

I'm willing to tinker with source code if I have to for this ability. It's an extremely basic sort of feature, we need it, and it's surprising that it's not just the default IPython behavior. For any amount of saved notebooks over maybe 10 or 15, this feature is necessary.

like image 761
ely Avatar asked Jun 13 '12 19:06

ely


People also ask

How do I go to a different directory in Jupyter Notebook?

all you need to do is 1- open command prompt by ( windows + r and type cmd and enter) . 2- navigate the directory that you are seeing at jupyter notebook home. 3- create a link by command mklink /D linkofgyaan D:\Test 4- ıt's done. now you can see it at Jupiter.

What does %% do in Jupyter Notebook?

Both ! and % allow you to run shell commands from a Jupyter notebook. % is provided by the IPython kernel and allows you to run "magic commands", many of which include well-known shell commands. ! , provided by Jupyter, allows shell commands to be run within cells.

Can I run two instances of Jupyter Notebook?

You can run a Jupyter notebook from another Jupyter notebook that has the same type of kernel. For example, you can run a Jupyter notebook with Spark kernel from another Jupyter notebook with Spark kernel. From the left Sidebar, select and right-click on the Jupyter notebook that has to be run from another notebook.

What does %% capture do?

Capturing Output With %%capture IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable. By default, %%capture discards these streams. This is a simple way to suppress unwanted output.


2 Answers

The IPython documentation pages suggest that opening several different sessions of IPython notebook is the only way to interact with saved notebooks in different directories or subdirectories, but this is not explicitly confirmed anywhere.

Yes, this is a current (temporary) limitation of the Notebook server. Multi-directory support is very high on the notebook todo list (unfortunately that list is long, and devs are few and have day jobs), it is just not there yet. By 0.14 (Fall, probably), you should have no reason to be running more than one nb server, but for now that's the only option for multiple directories. All that is missing for a simple first draft is:

  1. Associating individual notebooks with directories (fairly trivial), and
  2. Web UI for simple filesystem navigation (slightly less trivial).

I'm willing to tinker with source code if I have to for this ability

The limiting factor, if you want to poke around in the source, is the NotebookManager, which is associated with a particular directory. If you tweak the list_notebooks() method to handle subdirectories, you are 90% there.

I was curious about this as well, so I tossed together an quick example here that allows you to at least read/run/edit/save notebooks in subdirs (walk depth is limited to 2, but easy to change). Any new notebooks will be in the top-level dir, and there is no UI for moving them around.

like image 89
minrk Avatar answered Sep 26 '22 14:09

minrk


The interface and architecture design issues for multiple directory support (and more generally for "project" support) for iPython notebook are important to get right. A design is described in

IPEP 16: Notebook multi directory dashboard and URL mapping

and is being discussed at IPEP 16: Notebook multi directory dashboard and URL mapping · Issue #3166 · ipython/ipython

like image 22
nealmcb Avatar answered Sep 26 '22 14:09

nealmcb