MagicPickle
magicpickle allows you to transfer pickled representations of objects between local and remote instances of scripts, providing a near-seamless way to write code which both accesses data stored remotely and visualizes it locally. This avoids the need to:
- store, load, and sync intermediate data representations between local and remote machines
- use X11 forwarding/VNC with noticable latency
Internally, magicpickle uses joblib to pickle and unpickle objects, and magic-wormhole to transfer the pickled data between local and remote instances of a script.
Note that magicpickle assumes that each mp.save is associated with a single mp.load in the same script; it assumes that both local and remote instances have the same control flow.
Installation
pip install magicpickle
Usage
Check the docstrings in src/magicpickle.py for more information. Example use:
from magicpickle import MagicPickle
with MagicPickle(MY_LOCAL_HOSTNAME) as mp: # or MagicPickle(func_that_returns_true_if_local)
if mp.is_remote: # or mp.is_local
mp.save("hello")
else:
print(mp.load())
Tmux
tmux_magicpickle.py is a script that scrapes your panes and automatically enters the magic-wormhole code for you. Add the following to your ~/.tmux.conf to use it:
bind-key g run-shell "python3 PATH_TO/tmux_magicpickle.py"
to add the prefix + g binding.
Gotchas
To allow the pickling of lambda functions, prefix your script with
import dill as pickle
To allow the loading of pickled CUDA tensors onto a CPU, prefix your script with
import torch
# https://stackoverflow.com/a/78399538/10702372
torch.serialization.register_package(0, lambda x: x.device.type, lambda x, _: x.cpu())
Metadata
Release files for magicpickle 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| magicpickle-0.0.6.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| magicpickle-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / magicpickle-0.0.6.tar.gz
| Download URL | magicpickle-0.0.6.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
646760833d0974ccbe0974dc449b0f0f5fad46b4bcbf6afa651051a091bd776b
|
|
BLAKE2b-256 checksum How to use checksums |
70e1b88dfce38eb85810a2f93ae008b27040bda7a9cf3b1c404e437dcead7e43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / magicpickle-0.0.6-py3-none-any.whl
| Download URL | magicpickle-0.0.6-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71497b1517825085b58a658911980d49e69a54b0853821abfc67560b828ba55d
|
|
BLAKE2b-256 checksum How to use checksums |
0f40a27d09ba561a25f79356ee936d737bca4395bff81c6cee35a3463d23dcf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|