Auto-save periodically during nbconvert

My understanding is that jupyter nbconvert doesn’t even save on a per cell basis, let alone as the cell progresses. See the last paragraph of my reply here where I suggest papermill if you want to look in as the run progress on a per cell basis. I don’t know how papermill handles outputting mid-cell execution.

There are some places where you have to do above and beyond the standard notebook cell model to accomplish what you need. Traditionally, jupyter notebooks aren’t ideal for long-running compute tasks (and there are efforts to address that such as this way to attach a sub-console to visualize intermediary results of a long-running computation); however, you are already partly addressing that shortcoming by executing the notebook on the command line. With some additional different approaches it usually can be adapted to still accomplish what you need. For example, it may be better to set up what is taking 16 hours to have logging steps where the progress you need to monitor is mirrored in an external log/text file (or other output forms) at times you control. You can also add in clean-up of that mirrored content at the end of the cell run so you aren’t necessarily permanently duplicating stdout or output. Or still using that approach of adding logging & mirroring, package things up into a script you can run separate from the notebook and then make output files that you then integrate into the notebook as documentation of that code run. Ideally, you can run that script behind a screen (or similar tech) and reattach to it and monitor it to your heart’s content using ps or other monitoring you’ve built in. Even if you don’t run the script separate packaging it up as a script you can run from inside the notebook with %run or %run -i, while adding the external logging or mirroring of output you want to monitor may suffice.

1 Like