<p dir="ltr">It occurs to me that one could use JavaScript in custom.js to create a cell and load the magic in that situation (with some complex event handling to make sure everything is loaded and that the kernel is started successfully), but there may be a better way of which I'm not aware.</p>
<p dir="ltr">Thorin</p>
<div class="gmail_quote">On Dec 24, 2015 8:13 AM, Ted Liefeld <liefeld@broadinstitute.org> wrote:<br type='attribution'><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><i><font color="#cccccc">Aside:  Wish I knew how to reply to a thread in the digest on mailman too...</font></i></div><div><br /></div><div>Thomas</div><div><br /></div><div>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.  </div><div><br /></div><div>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?</div><div><br /></div><div>Ted</div><div><br /></div><br /><div><br /></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span style="font-size:12.8px">Date: Wed, 23 Dec 2015 22:27:00 +0000</span></div><div><span style="font-size:12.8px">From: Thomas Kluyver <</span><a href="mailto:takowl@gmail.com" style="font-size:12.8px">takowl@gmail.com</a><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">To: IPython developers list <</span><a href="mailto:ipython-dev@scipy.org" style="font-size:12.8px">ipython-dev@scipy.org</a><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">Subject: Re: [IPython-dev] How to load an extension into every</span></div><div><span style="font-size:12.8px">        notebook on a   server</span></div><div><span style="font-size:12.8px">Message-ID:</span></div><div><span style="font-size:12.8px">        <CAOvn4qgeSpaVVRW4h+</span><span style="font-size:12.8px">jzn19gB6tTXkuY=</span><a href="mailto:QvfK2JLDmqso9MFaQ@mail.gmail.com" style="font-size:12.8px">QvfK2JLDmqso9MFaQ@mail.gmail.com</a><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">Content-Type: text/plain; charset="utf-8"</span></div><div><br style="font-size:12.8px" /></div><div><span style="font-size:12.8px">Looking at the Genepattern code [1], it's using display() to publish data.</span></div><div><span style="font-size:12.8px">The notebook interface will only actually use the Javascript that sends if</span></div><div><span style="font-size:12.8px">it's coming from code run in a cell, so that part of the loading can't work</span></div><div><span style="font-size:12.8px">at startup.</span></div><div><br style="font-size:12.8px" /></div><div><span style="font-size:12.8px">I think we'd probably encourage you to keep putting the command to load the</span></div><div><span style="font-size:12.8px">extension at the top of every notebook, by analogy with a similar situation</span></div><div><span style="font-size:12.8px">we had with pylab. It used to be possible to run "ipython notebook</span></div><div><span style="font-size:12.8px">--pylab", and have a lot of numpy & matplotlib functions pre-loaded into</span></div><div><span style="font-size:12.8px">the namespace. But this produces notebooks which can only be run by someone</span></div><div><span style="font-size:12.8px">starting the notebook server in the same way. We found it better to use a</span></div><div><span style="font-size:12.8px">'%pylab' magic inside the notebook when we want the namespace set up like</span></div><div><span style="font-size:12.8px">that. I think loading the genepattern extension is a similar thing: it's</span></div><div><span style="font-size:12.8px">clearer what's going on when that lives inside the notebook, rather than</span></div><div><span style="font-size:12.8px">hidden in your config.</span></div><div><br style="font-size:12.8px" /></div><div><span style="font-size:12.8px">[1]</span></div><div><a href="https://github.com/genepattern/genepattern-notebook/blob/master/profile/extensions/genepattern.py" style="font-size:12.8px">https://github.com/genepattern/genepattern-notebook/blob/master/profile/extensions/genepattern.py</a></div><div><br style="font-size:12.8px" /></div><div><span style="font-size:12.8px">Thomas</span></div><div><br style="font-size:12.8px" /></div><div><span style="font-size:12.8px">On 23 December 2015 at 22:06, Ted Liefeld <</span><a href="mailto:liefeld@broadinstitute.org" style="font-size:12.8px">liefeld@broadinstitute.org</a><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">wrote:</span></div><div><br style="font-size:12.8px" /></div><div><span style="font-size:12.8px">> I am building a Docker image to have a Jupyter server with the GenePattern</span></div><div><span style="font-size:12.8px">> notebook extension in it.  So far so good except that in every notebook I</span></div><div><span style="font-size:12.8px">> have to enter</span></div><div><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">>      %reload_ext genepattern</span></div><div><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">> into the first cell to make the extension active.  I have been prowling</span></div><div><span style="font-size:12.8px">> through the docs and have tried putting this command in lots of places,</span></div><div><span style="font-size:12.8px">> none of which have worked (e.g. ~/.jupyter/jupyter_notebook_</span><span style="font-size:12.8px">config.py,</span></div><div><span style="font-size:12.8px">>  ~/.ipython/profile_default/</span><span style="font-size:12.8px">startup/ipython_notebook_</span><span style="font-size:12.8px">config.py) both</span></div><div><span style="font-size:12.8px">> normally (ie as above) and also as a config setting</span></div><div><span style="font-size:12.8px">>         c.InteractiveShellApp.exec_</span><span style="font-size:12.8px">lines = ['%reload_ext genepattern']</span></div><div><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">> It seems with all the layers of config I am not finding the right one to</span></div><div><span style="font-size:12.8px">> insert this at. Can anyone point me in the right direction?  My current</span></div><div><span style="font-size:12.8px">> container is using Jupyter 4.0.6, IPython 4.0.1 and Python 3.4.3.</span></div><div><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">> Thanks</span></div><div><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">> Ted</span></div><div><span style="font-size:12.8px">></span></div><div><span style="font-size:12.8px">></span></div></blockquote></div><div><br /><div class="elided-text">On Wed, Dec 23, 2015 at 2:06 PM, Ted Liefeld <span dir="ltr"><<a href="mailto:liefeld@broadinstitute.org">liefeld@broadinstitute.org</a>></span> wrote:<br /><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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<div><br /></div><div>     %reload_ext genepattern</div><div><br /></div><div>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</div><div>        c.InteractiveShellApp.exec_lines = ['%reload_ext genepattern']</div><div><br /></div><div>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.</div><div><br /></div><div>Thanks</div><font color="#888888"></font><div><br /></div><div>Ted</div><div><br clear="all" /><div><br /></div>-- <br /><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:12.8px">Ted Liefeld                                     </span><span style="font-size:12.8px"> UC San Diego</span><br /></div><div>Mesirov Lab                                    <a href="mailto:liefeld@ucsd.edu">liefeld@ucsd.edu</a>                                <br />Office 2A24, BRF-II                        858-534-2010</div><div><br /></div></div></div></div></div></div>
</div></div>
</blockquote></div><br /><br clear="all" /><div><br /></div>-- <br /><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:12.8px">Ted Liefeld                                     </span><span style="font-size:12.8px"> UC San Diego</span><br /></div><div>Mesirov Lab                                    <a href="mailto:liefeld@ucsd.edu">liefeld@ucsd.edu</a>                                <br />Office 2A24, BRF-II                        858-534-2010</div><div><br /></div></div></div></div></div></div>
</div>
</blockquote></div>