[IPython-dev] How to load an extension into every notebook on a server

Ian Stokes Rees ijstokes at alumni.uwaterloo.ca
Sat Jan 2 13:25:41 EST 2016


Hi Ted (and Thomas),

At Continuum we are also interested in having pre-configured notebook 
environments and are actively working with the Jupyter team to figure 
out good ways of enabling "universal" configuration of extensions in 
Jupyter 4 (for others: prior to the complete reworking of the 
"extension" mechanism which will arrive with Jupyter 5).

I'm offline now, otherwise I'd provide you with some links to the 
discussion, but you can dig up a reference if you look at the JEP area 
of the Jupyter GitHub repos.  I think this is the link:

https://github.com/jupyter/enhancement-proposals/pull/7

That is probably way too much detail for what you're looking for, but I, 
for one, would like to come up with a solution that would make your 
GeneExpression extension "pre-loadable" with no extra work on the part 
of the user.

Cheers,

Ian

On 12/24/15 8:13 AM, Ted Liefeld wrote:
> /Aside:  Wish I knew how to reply to a thread in the digest on mailman 
> too.../
>
> Thomas
>
> what you says makes sense about having the magic be explicit in the 
> notebook.  For the Docker server though I'd still like to not have to 
> make users remember to insert it themselves  because they have just 
> started the GP-noteook-jupyter container so they (or at least I) would 
> expect it to just work.
>
> So whats your opinion of if I were to modify the jupyter in the 
> container (assuming its possible) to make the default empty python 3 
> notebook have one cell at its top with the magic line in it?
>
> Ted
>
>
>
>     Date: Wed, 23 Dec 2015 22:27:00 +0000
>     From: Thomas Kluyver <takowl at gmail.com <mailto:takowl at gmail.com>>
>     To: IPython developers list <ipython-dev at scipy.org
>     <mailto:ipython-dev at scipy.org>>
>     Subject: Re: [IPython-dev] How to load an extension into every
>             notebook on a  server
>     Message-ID:
>     <CAOvn4qgeSpaVVRW4h+jzn19gB6tTXkuY=QvfK2JLDmqso9MFaQ at mail.gmail.com <mailto:QvfK2JLDmqso9MFaQ at mail.gmail.com>>
>     Content-Type: text/plain; charset="utf-8"
>
>     Looking at the Genepattern code [1], it's using display() to
>     publish data.
>     The notebook interface will only actually use the Javascript that
>     sends if
>     it's coming from code run in a cell, so that part of the loading
>     can't work
>     at startup.
>
>     I think we'd probably encourage you to keep putting the command to
>     load the
>     extension at the top of every notebook, by analogy with a similar
>     situation
>     we had with pylab. It used to be possible to run "ipython notebook
>     --pylab", and have a lot of numpy & matplotlib functions
>     pre-loaded into
>     the namespace. But this produces notebooks which can only be run
>     by someone
>     starting the notebook server in the same way. We found it better
>     to use a
>     '%pylab' magic inside the notebook when we want the namespace set
>     up like
>     that. I think loading the genepattern extension is a similar
>     thing: it's
>     clearer what's going on when that lives inside the notebook,
>     rather than
>     hidden in your config.
>
>     [1]
>     https://github.com/genepattern/genepattern-notebook/blob/master/profile/extensions/genepattern.py
>
>     Thomas
>
>     On 23 December 2015 at 22:06, Ted Liefeld
>     <liefeld at broadinstitute.org <mailto:liefeld at broadinstitute.org>>
>     wrote:
>
>     > I am building a Docker image to have a Jupyter server with the GenePattern
>     > notebook extension in it.  So far so good except that in every notebook I
>     > have to enter
>     >
>     >      %reload_ext genepattern
>     >
>     > into the first cell to make the extension active.  I have been prowling
>     > through the docs and have tried putting this command in lots of places,
>     > none of which have worked (e.g. ~/.jupyter/jupyter_notebook_config.py,
>     >~/.ipython/profile_default/startup/ipython_notebook_config.py) both
>     > normally (ie as above) and also as a config setting
>     > c.InteractiveShellApp.exec_lines = ['%reload_ext genepattern']
>     >
>     > It seems with all the layers of config I am not finding the right one to
>     > insert this at. Can anyone point me in the right direction?  My current
>     > container is using Jupyter 4.0.6, IPython 4.0.1 and Python 3.4.3.
>     >
>     > Thanks
>     >
>     > Ted
>     >
>     >
>
>
> On Wed, Dec 23, 2015 at 2:06 PM, Ted Liefeld 
> <liefeld at broadinstitute.org <mailto:liefeld at broadinstitute.org>> wrote:
>
>     I am building a Docker image to have a Jupyter server with the
>     GenePattern notebook extension in it.  So far so good except that
>     in every notebook I have to enter
>
>          %reload_ext genepattern
>
>     into the first cell to make the extension active.  I have been
>     prowling through the docs and have tried putting this command in
>     lots of places, none of which have worked (e.g.
>     ~/.jupyter/jupyter_notebook_config.py,
>      ~/.ipython/profile_default/startup/ipython_notebook_config.py)
>     both normally (ie as above) and also as a config setting
>             c.InteractiveShellApp.exec_lines = ['%reload_ext genepattern']
>
>     It seems with all the layers of config I am not finding the right
>     one to insert this at. Can anyone point me in the right
>     direction?  My current container is using Jupyter 4.0.6, IPython
>     4.0.1 and Python 3.4.3.
>
>     Thanks
>
>     Ted
>
>
>     -- 
>     Ted Liefeld  UC San Diego
>     Mesirov Lab liefeld at ucsd.edu <mailto:liefeld at ucsd.edu>
>     Office 2A24, BRF-II 858-534-2010 <tel:858-534-2010>
>
>
>
>
> -- 
> Ted Liefeld  UC San Diego
> Mesirov Lab liefeld at ucsd.edu <mailto:liefeld at ucsd.edu>
> Office 2A24, BRF-II  858-534-2010
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> https://mail.scipy.org/mailman/listinfo/ipython-dev

Ian Stokes-Rees
617.942.0218

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20160102/ef390330/attachment.html>


More information about the IPython-dev mailing list