Octoframes / jupyter_capture_output

A cellmagic that captures celloutput such as text, image or video to files.
https://octoframes.github.io/jupyter_capture_output/
MIT License
31 stars 0 forks source link

Global capture toggle #14

Closed fecet closed 1 year ago

fecet commented 1 year ago

Can I capture all cells in a notebook to a file? I only care text output

kolibril13 commented 1 year ago

Yes, that is deftly possible! With the current the jupyter_capture_output implementation, you would need to decorate every cell with the capture_text magic. But I guess this is not what you want to do. I can see two cases.

Case 1 Do you want to auto-capture all text output from a cell when the notebook is running? The equivalent to the jupyter cell magic but globally speaking is an IPython input transformer https://discourse.jupyter.org/t/possible-use-cases-of-ipython-input-transformers/17935 So you could implement an equivalent of capture_text for that. To have unique file names, you can add a time-stemp like this

    timestamp = datetime.now().strftime("%Y-%m-%d@%H-%M-%S")
    name = "napari_video" + "@" + timestamp + ".txt"

Case 2 Do you want to capture all text output from a notebook that was already executed? In that case, I would recommend to you to write a script that searches and exports all text outputs. here is a project that might help in implementing something like that: https://github.com/damienmarlier51/Junix

fecet commented 1 year ago

I see, glad to know it's at least possible