Skip to main content

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.11

  • add support for embedded videos.

0.0.10

  • use importlib.metadata

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

Metadata

Release files for jupyter-capture-output 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyter-capture-output 0.0.11
File Size Uploaded Provenance Actions
jupyter_capture_output-0.0.11.tar.gz 4.8 kB Without provenance Details for jupyter_capture_output-0.0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jupyter-capture-output 0.0.11
File Interpreter ABI Platform Actions
jupyter_capture_output-0.0.11-py3-none-any.whl Python 3 none any Details for jupyter_capture_output-0.0.11-py3-none-any.whl

Total release size: 10.4 kB

Release files / jupyter_capture_output-0.0.11.tar.gz

Download URL jupyter_capture_output-0.0.11.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d087b77e17606aa978745b7f4e1f2d1cdfad81ae7784bbbfd0a9e0b0f6073831
BLAKE2b-256 checksum
How to use checksums
308353e580804f18143d4da96439116e01cac0c737944d62acd0eb3b6cb21ad7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.16 Linux/5.15.0-1035-azure

Release files / jupyter_capture_output-0.0.11-py3-none-any.whl

Download URL jupyter_capture_output-0.0.11-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d219295d2397e6ab6bc524de67ce14a30328c08d77449ef854577c36fb9493f
BLAKE2b-256 checksum
How to use checksums
08d59eeb49a20d78b77afccc3d7d310114bb7890572d8265381c4ccef0ed57e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.16 Linux/5.15.0-1035-azure

Security for jupyter-capture-output 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page