Skip to main content

Capture output from JupyterLab

Project description

jupyter-caputure-output

A cell magic that captures jupyter cell output

JupyterLight

Install

Requires Python >=3.8

pip install jupyter_capture_output

Example

https://user-images.githubusercontent.com/44469195/199723257-ee428f53-d576-47be-93b9-d6ab98c46d8e.mov

import jupyter_capture_output
%%capture_text --path "foo.txt"
print("Hello World")
import matplotlib.pyplot as plt
%%capture_img --path "foo.png bar.png"
plt.plot([1,2],[10,20])
plt.show()
plt.plot([3,4],[-10,-20])
plt.show()
%%capture_img  --path "foo.jpg bar.jpg" --compression 50
plt.plot([1,2],[10,20], color = "r")
plt.show()
plt.plot([3,4],[-10,-20],color = "r")
plt.show()

Implemented

  • %%capture_text -> to .txt file with text output
  • %%capture_code -> to .py file with cell content
  • %%capture_img -> to .png or .jpg with image output
  • %%capture_video -> to .mp4 file with the video output

Use cases

  • matplotlib, scipy, PIL , cv2, manim etc. have their own APIs to save images. With this package, one just have to learn one line of code and can use it to save all kind of image outputs made by different packages.

  • When tweaking plots, one can use this cell magic to track the process, so to say a visual version control system.

  • In context of Science, one can generate log files of experiments with this package. As the cell magic is always on the top of the cell, it's easy to see in which cells log files are generated and in which not.

  • This can be used to create sheet cheats, e.g. this math-functions-cheat-sheet website was generated from a jupyter notebook using a derivative of this capture package.

  • This package will also auto-generate the folder-tree of subdirectories for you.

Changelog

0.0.9

  • support python 3.11

0.0.8

  • Add capture_code magic. Because this is not cell output but cell content, it might be worth to think about renaming this project from capture-output to only capture or even capture-content.
  • remove experimental_capture_video_first_last and experimental_video_thumbnail again. This package is not the right place for that.

0.0.7

  • Add relative path support and automatically create paths if they don't exist yet.

Add some experimental magic, but this will likely be removed in future versions:

    • experimental_capture_video_first_last captures video and extracts first and last frame from it. Useful for post-processing of videos in other video editors. Needs ffmpeg installed
  • experimental_video_thumbnail extracts video from the Jupyter cell output, and replaces it with an image thumbnail of the video -> useful for Version control. Needs matplotlib and ffmpeg installed

0.0.6

better regex in capture video change example images to dogs

0.0.5

Remove debugging code Add JupyterLiteDemo

0.0.4

Add Text and Video capture cell magic update example

0.0.3

Setup automatic release action.

0.0.2

Update example

0.0.1

Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_capture_output-0.0.10.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

jupyter_capture_output-0.0.10-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_capture_output-0.0.10.tar.gz.

File metadata

  • Download URL: jupyter_capture_output-0.0.10.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-1034-azure

File hashes

Hashes for jupyter_capture_output-0.0.10.tar.gz
Algorithm Hash digest
SHA256 2e44c49054368797b4448c1a51a4d54558dc87b6cc7f53a09e757b02f200727f
MD5 122d19df2b586cb1300cd504b4b00758
BLAKE2b-256 f472a923237e022d773544e3e36bb1bf3017f9a6203d9700f8831fc5b13a070c

See more details on using hashes here.

File details

Details for the file jupyter_capture_output-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_capture_output-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 709ba4bde7e74dee2a3e40f005fa50c5520bb1993f85e880c7fbafc234de8797
MD5 51ffe18483ff9489f32aa4dd6d609f7d
BLAKE2b-256 cdce88de12ec2eba758b0223f51f51697bc65618dee25a45d385f1795aa1ab39

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page