betatim / notebook-as-pdf

Save Jupyter Notebooks as PDF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nbconvert executes notebook twice using PDFviaHTML

alinscodes opened this issue · comments

I realized that when executing my notebook and converting it to PDF, it would execute the notebook twice.

I run the following command. It only happens when I convert to PDFviaHTML.
How do I know it runs twice? The jupyter notebook code saved a text file with the timestamp as the name.
Every time I use the following command it saves 2 files which confirms the behavior.

jupyter-nbconvert --ExecutePreprocessor.timeout=1200 --to PDFviaHTML --TemplateExporter.exclude_input=True --execute "Untitled.ipynb"

image

That is super weird. I wonder why that happens because in notebook-as-pdf's code we never ask for the notebook to be executed nor try to prevent execution. My understanding of the nbconvert APIs that get used is that all they do is convert the notebook (as it currently is) to HTML.

Can you share the notebook for which this happens and does it happen when you try it in this repositories binder?

I used this code to check that it is actually running twice.
Not sure how to use this repository binder.

import time
timestr = time.strftime("%Y%m%d-%H%M%S")
f= open(timestr+".txt","w+")
time.sleep(1.5)

nbconvert==5.6.1
notebook-as-pdf==0.3.1

Thanks for finding this! The problem was that the notebook was getting converted to HTML (and then PDF) twice. Each time it was being converted the "execute preprocessor" was run.