<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 29, 2014 at 9:05 PM, Jones, Zach H <span dir="ltr"><<a href="mailto:Zach.Jones@netapp.com" target="_blank">Zach.Jones@netapp.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-size:10pt;font-family:Tahoma">
<div style><font face="Arial">I have made some progress in debugging the problems.</font></div>
<div style><font face="Arial"><br>
</font></div>
<div style><font face="Arial">The error with the na_full template was that html_basic.tpl is now basic.tpl.  After correcting to {%- extends basic.tpl -%} my template is working again.</font></div>
<div style><font face="Arial"><br>
</font></div>
<div style><font face="Arial">It looks like the na_report template not being recognized is because there is a error that occurs when loading the template inside nbconvert. </font></div>
<div style><font face="Arial"><br>
</font></div>
<div style><font face="Arial">Are the silent errors by design? Is there a way for me to invoke verbose output during the loading the templates?</font></div></div></div></blockquote><div><br></div><div>The silence is definitely not by design. It may be a side effect of the template discovery code trying a few things before giving up. I will look into it.</div>

<div><br></div><div>-MinRK</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="direction:ltr;font-size:10pt;font-family:Tahoma">
<div style><font face="Arial"><br>
</font></div>
<div style><font face="Arial">Thanks,</font></div>
<div style><font face="Arial">Zach Jones</font></div>
<div style="font-size:16px;font-family:Times New Roman">
<hr>
<div style="direction:ltr"><font face="Tahoma" color="#000000"><b>From:</b> <a href="mailto:ipython-dev-bounces@scipy.org" target="_blank">ipython-dev-bounces@scipy.org</a> [<a href="mailto:ipython-dev-bounces@scipy.org" target="_blank">ipython-dev-bounces@scipy.org</a>] on behalf of Jones, Zach H [<a href="mailto:Zach.Jones@netapp.com" target="_blank">Zach.Jones@netapp.com</a>]<br>


<b>Sent:</b> Saturday, March 29, 2014 8:27 PM<br>
<b>To:</b> <a href="mailto:ipython-dev@scipy.org" target="_blank">ipython-dev@scipy.org</a><br>
<b>Subject:</b> [IPython-dev] Problems using nbconvert with custom templates in IPython2.0-rc1<br>
</font><br>
</div><div><div class="h5">
<div></div>
<div>
<div style="direction:ltr;font-size:10pt;font-family:Tahoma">
<div style="font-size:16px;font-family:Times New Roman">
<div style="direction:ltr"><span style="color:rgb(34,34,34);font-size:small;font-family:arial">All,</span></div>
<div>
<div style="direction:ltr;font-size:10pt;font-family:Tahoma">
<div style="color:rgb(34,34,34);font-family:arial"><font><br>
</font></div>
<div style="color:rgb(34,34,34);font-family:arial"><font>I have been using nbconvert to generate HTML views of notebooks with IPython1.x.  I based my work on this: </font><a href="http://nbviewer.ipython.org/urls/raw.githubusercontent.com/ipython/ipython-in-depth/master/notebooks/07%20-%20NbConvert%20Python%20library.ipynb?create=1#Programatically-make-templates" style="font-family:Tahoma;font-size:10pt" target="_blank">http://nbviewer.ipython.org/urls/raw.githubusercontent.com/ipython/ipython-in-depth/master/notebooks/07%20-%20NbConvert%20Python%20library.ipynb?create=1#Programatically-make-templates</a></div>


<div style="color:rgb(34,34,34);font-family:arial"><font><br>
</font></div>
<div style="color:rgb(34,34,34);font-family:arial"><font>This work great with IPython1.x but is now not working with IPython2.0-rc.  I am hoping you can help me sort through my errors.</font></div>
<div style="color:rgb(34,34,34);font-family:arial"><font><br>
</font></div>
<div style="color:rgb(34,34,34);font-family:arial"><font>The code looks like this:</font></div>
<div style="color:rgb(34,34,34)"><font face="Courier New">extra_tpls = DictLoader({'na_full': ..., 'na_report', ...})<br>
</font></div>
<div style="color:rgb(34,34,34)">
<div><font face="Courier New">c = Config()</font></div>
<div><font face="Courier New">c.HTMLExporter.default_template = 'na_report'</font></div>
</div>
<div style="color:rgb(34,34,34)"><font face="Courier New">exportHTML = HTMLExporter(config=c, extra_loaders=[extra_tpls])<br>
</font></div>
<div style="color:rgb(34,34,34)"><font face="Courier New">exportHTML.from_notebook_node(nb)<br>
</font></div>
<div style="color:rgb(34,34,34)"><font face="Courier New"><br>
</font></div>
<div style="color:rgb(34,34,34)"><font face="arial">My DictLoader contains two templates:</font></div>
<div style="color:rgb(34,34,34)">
<ul style="font-family:arial;font-size:10pt">
<li><span style="font-family:arial;font-size:small">na_full extends html_basic.tpl</span></li><li><span style="font-family:arial;font-size:small">na_report extends display_priority.tpl</span></li></ul>
</div>
<div style="color:rgb(34,34,34);font-family:arial"><font>I get errors with either template, but each template is different.</font></div>
<div style="color:rgb(34,34,34);font-family:arial"><font><br>
</font></div>
<div style="color:rgb(34,34,34);font-family:arial"><font>For na_full, it looks like html_basic.tpl cannot be found:</font></div>
<div style="color:rgb(34,34,34)">
<div style="min-width:11ex;padding:0px 0.4em;margin:0px;text-align:right;line-height:1.21429em;color:rgb(0,0,0)">
</div>
<div style="padding:0.4em 0.4em 0px;color:rgb(0,0,0);line-height:1.21429em">
<pre style="padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;white-space:pre-wrap;border:0px;vertical-align:baseline"><font face="Courier New"><span style="color:rgb(139,0,0)">---------------------------------------------------------------------------</span>
<span style="color:rgb(139,0,0)">TemplateNotFound</span>                          Traceback (most recent call last)
<span style="color:rgb(0,100,0)"><ipython-input-23-008e826165f9></span> in <span style="color:rgb(70,130,180)"><module><span style="color:rgb(0,0,139)">()</span>
<span style="color:rgb(0,100,0)">----> 1<span style="color:rgb(165,42,42)"> </span>exportHTML</span><span style="color:rgb(165,42,42)">.</span></span>from_notebook_node<span style="color:rgb(165,42,42)">(</span>nb<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>

<span style="color:rgb(0,100,0)">/x/eng/rtpperf/python2.7-Debian-unstable-x86_64-tst/local/lib/python2.7/site-packages/IPython/nbconvert/exporters/templateexporter.pyc</span> in <span style="color:rgb(70,130,180)">from_notebook_node<span style="color:rgb(0,0,139)">(self, nb, resources, **kw)</span>
<span style="color:rgb(0,100,0)">    213</span> <span style="color:rgb(165,42,42)"></span></span>
<span style="color:rgb(0,100,0)">    214</span>         <span style="color:rgb(0,100,0)">if</span> self<span style="color:rgb(165,42,42)">.</span>template <span style="color:rgb(0,100,0)">is</span> <span style="color:rgb(0,100,0)">not</span> None<span style="color:rgb(165,42,42)">:</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">--> 215<span style="color:rgb(165,42,42)">             </span>output</span> <span style="color:rgb(165,42,42)">=</span> self<span style="color:rgb(165,42,42)">.</span>template<span style="color:rgb(165,42,42)">.</span>render<span style="color:rgb(165,42,42)">(</span>nb<span style="color:rgb(165,42,42)">=</span>nb_copy<span style="color:rgb(165,42,42)">,</span> resources<span style="color:rgb(165,42,42)">=</span>resources<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    216</span>         <span style="color:rgb(0,100,0)">else</span><span style="color:rgb(165,42,42)">:</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    217</span>             <span style="color:rgb(0,100,0)">raise</span> IOError<span style="color:rgb(165,42,42)">(</span><span style="color:rgb(0,0,139)">'template file "%s" could not be found'</span> <span style="color:rgb(165,42,42)">%</span> self<span style="color:rgb(165,42,42)">.</span>template_file<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>

<span style="color:rgb(0,100,0)">/x/eng/rtpperf/python2.7-Debian-unstable-x86_64-tst/local/lib/python2.7/site-packages/jinja2/environment.pyc</span> in <span style="color:rgb(70,130,180)">render<span style="color:rgb(0,0,139)">(self, *args, **kwargs)</span>
<span style="color:rgb(0,100,0)">    967</span>         <span style="color:rgb(0,100,0)">except</span> </span>Exception<span style="color:rgb(165,42,42)">:</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    968</span>             exc_info <span style="color:rgb(165,42,42)">=</span> sys<span style="color:rgb(165,42,42)">.</span>exc_info<span style="color:rgb(165,42,42)">(</span><span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">--> 969<span style="color:rgb(165,42,42)">         <span style="color:rgb(0,100,0)">return</span> </span>self</span><span style="color:rgb(165,42,42)">.</span>environment<span style="color:rgb(165,42,42)">.</span>handle_exception<span style="color:rgb(165,42,42)">(</span>exc_info<span style="color:rgb(165,42,42)">,</span> True<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    970</span> <span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    971</span>     <span style="color:rgb(0,100,0)">def</span> stream<span style="color:rgb(165,42,42)">(</span>self<span style="color:rgb(165,42,42)">,</span> <span style="color:rgb(165,42,42)">*</span>args<span style="color:rgb(165,42,42)">,</span> <span style="color:rgb(165,42,42)">**</span>kwargs<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)">:</span><span style="color:rgb(165,42,42)"></span>

<span style="color:rgb(0,100,0)">/x/eng/rtpperf/python2.7-Debian-unstable-x86_64-tst/local/lib/python2.7/site-packages/jinja2/environment.pyc</span> in <span style="color:rgb(70,130,180)">handle_exception<span style="color:rgb(0,0,139)">(self, exc_info, rendered, source_hint)</span>
<span style="color:rgb(0,100,0)">    740</span>             </span>self<span style="color:rgb(165,42,42)">.</span>exception_handler<span style="color:rgb(165,42,42)">(</span>traceback<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    741</span>         exc_type<span style="color:rgb(165,42,42)">,</span> exc_value<span style="color:rgb(165,42,42)">,</span> tb <span style="color:rgb(165,42,42)">=</span> traceback<span style="color:rgb(165,42,42)">.</span>standard_exc_info<span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">--> 742<span style="color:rgb(165,42,42)">         </span>reraise</span><span style="color:rgb(165,42,42)">(</span>exc_type<span style="color:rgb(165,42,42)">,</span> exc_value<span style="color:rgb(165,42,42)">,</span> tb<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    743</span> <span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    744</span>     <span style="color:rgb(0,100,0)">def</span> join_path<span style="color:rgb(165,42,42)">(</span>self<span style="color:rgb(165,42,42)">,</span> template<span style="color:rgb(165,42,42)">,</span> parent<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)">:</span><span style="color:rgb(165,42,42)"></span>

<span style="color:rgb(0,100,0)"><template></span> in <span style="color:rgb(70,130,180)">top-level template code<span style="color:rgb(0,0,139)">()</span>

<span style="color:rgb(139,0,0)">TemplateNotFound</span>: html_basic.tpl</span></font></pre>
</div>
</div>
<div style="color:rgb(34,34,34);font-family:arial"><font><br>
</font></div>
<div style="color:rgb(34,34,34)"><font style="font-family:arial">For na_report, it looks like that it is not being found:<br>
</font>
<div style="font-family:monospace;min-width:11ex;padding:0px 0.4em;margin:0px;text-align:right;line-height:1.21429em;color:rgb(0,0,0)">
</div>
<div style="padding:0.4em 0.4em 0px;color:rgb(0,0,0);line-height:1.21429em">
<pre style="padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;white-space:pre-wrap;border:0px;vertical-align:baseline"><font><font face="Courier New"><span style="color:rgb(139,0,0)">---------------------------------------------------------------------------</span>
<span style="color:rgb(139,0,0)">IOError</span>                                   Traceback (most recent call last)
<span style="color:rgb(0,100,0)"><ipython-input-20-008e826165f9></span> in <span style="color:rgb(70,130,180)"><module><span style="color:rgb(0,0,139)">()</span>
<span style="color:rgb(0,100,0)">----> 1<span style="color:rgb(165,42,42)"> </span>exportHTML</span><span style="color:rgb(165,42,42)">.</span></span>from_notebook_node<span style="color:rgb(165,42,42)">(</span>nb<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>

<span style="color:rgb(0,100,0)">/x/eng/rtpperf/python2.7-Debian-unstable-x86_64-tst/local/lib/python2.7/site-packages/IPython/nbconvert/exporters/templateexporter.pyc</span> in <span style="color:rgb(70,130,180)">from_notebook_node<span style="color:rgb(0,0,139)">(self, nb, resources, **kw)</span>
<span style="color:rgb(0,100,0)">    215</span>             </span>output <span style="color:rgb(165,42,42)">=</span> self<span style="color:rgb(165,42,42)">.</span>template<span style="color:rgb(165,42,42)">.</span>render<span style="color:rgb(165,42,42)">(</span>nb<span style="color:rgb(165,42,42)">=</span>nb_copy<span style="color:rgb(165,42,42)">,</span> resources<span style="color:rgb(165,42,42)">=</span>resources<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    216</span>         <span style="color:rgb(0,100,0)">else</span><span style="color:rgb(165,42,42)">:</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">--> 217<span style="color:rgb(165,42,42)">             <span style="color:rgb(0,100,0)">raise</span> </span>IOError</span><span style="color:rgb(165,42,42)">(</span><span style="color:rgb(0,0,139)">'template file "%s" could not be found'</span> <span style="color:rgb(165,42,42)">%</span> self<span style="color:rgb(165,42,42)">.</span>template_file<span style="color:rgb(165,42,42)">)</span><span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    218</span>         <span style="color:rgb(0,100,0)">return</span> output<span style="color:rgb(165,42,42)">,</span> resources<span style="color:rgb(165,42,42)"></span>
<span style="color:rgb(0,100,0)">    219</span> <span style="color:rgb(165,42,42)"></span>

<span style="color:rgb(139,0,0)">IOError</span>: template file "html_na_report" could not be found</font><font face="Helvetica Neue, Helvetica, Arial, sans-serif">
</font></font></pre>
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif"><font><br>
</font></div>
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif"><font>I have also tried using the FileSystemLoader from jinja2 as well.  It loads the templates and I get the same errors.</font></div>
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif"><font><br>
</font></div>
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif"><font>Thanks for your help,</font></div>
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif"><font>Zach Jones</font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>

</div>

<br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br></div></div>