You could use the --execute option when you call nbconvert.

On 20 December 2017 at 02:30, Pouya Ghadimi Karahrodi <
[email protected]> wrote:

> Is this resolved ? I am trying to automate a notebook run and conversion
> to pdf.
> The missing step is the save after the notebook run completion.
> I am managing this through commands:
>  %run ./notebook.ipynb --inputParameters
> and then
> subprocess.call(["jupyter", "nbconvert" 
> ,"--to=pdf","--template=template.tplx",
> "notebook.ipynb"])
>
> Having this setup it misses the save and doesn't have the updated fields.
>
> Any suggestion to fix this ?
>
>
> On Friday, October 9, 2015 at 8:54:23 PM UTC+11, Min RK wrote:
>>
>> The kernel should know that it has outstanding requests, so you ought to
>> be able to query that, to determine whether.
>>
>> There isn’t a public API for this information, but this should work for
>> now:
>>
>> finished = (Object.keys(IPython.notebook.kernel._msg_callbacks).length == 0);
>>
>> If you check that value when idle events arrive, it should tell you when
>> the notebook is actually done or not.
>>
>> -MinRK
>> ​
>>
>> On Thu, Oct 8, 2015 at 9:18 PM, Graham Wheeler <[email protected]>
>> wrote:
>>
>>> Hi all
>>>
>>> I'm trying to have a custom.js that will automatically run a notebook
>>> when it gets opened or reloaded, and then hook an event handler when done.
>>>
>>> I'm trying this to start:
>>>
>>> require(['base/js/namespace', 'base/js/events', 'base/js/dialog',
>>> 'base/js/utils', 'base/js/security'], function() {
>>>   $([IPython.events]).on('kernel_ready.Kernel kernel_created.Session
>>> notebook_loaded.Notebook', run_notebook);
>>> });
>>>
>>> That seems to work okay.
>>>
>>> Getting completion event handling seems more tricky. I have:
>>>
>>> function run_notebook() {
>>>   var pageClass = document.body.className;
>>>   if (pageClass.indexOf('notebook_app') >= 0) {
>>>     IPython.notebook.clear_all_output();
>>>     IPython.notebook.execute_all_cells();
>>>
>>>    // My problem is here - how to tell when done.
>>>
>>>    // One attempt - this seems to run over and over
>>>     $([IPython.events]).on('kernel_idle.Kernel', function() {
>>>         checkIfDone();
>>>     });
>>>
>>>     // Another attempt - this doesn't seem to work at all
>>>     setTimeout(5000, function() {
>>>       checkIfDone();
>>>     });
>>>   }
>>> }
>>>
>>> function checkIfDone() {
>>>   if (IPython.notebook.kernel_busy) {
>>>     setTimeout(5000, function() {
>>>       checkIfDone();
>>>     });
>>>   } else {
>>>     console.log('Finished execution');
>>>   }
>>> }
>>>
>>> Is there a better way? Some other event to hook into?
>>>
>>> Thanks!
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Project Jupyter" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/jupyter/0982776e-ea36-447c-a45c-d6c75775cb3f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jupyter/0982776e-ea36-447c-a45c-d6c75775cb3f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jupyter/8f7d5e8e-bcb8-47cf-9616-386126f4bda6%40googlegroups.com
> <https://groups.google.com/d/msgid/jupyter/8f7d5e8e-bcb8-47cf-9616-386126f4bda6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAOvn4qi5__fiH7Me35-zHDxyXj5hicJS%2BNPX3OqJQudgni_L1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to