Skip to content

Commit 02b8c36

Browse files
committed
only run when no errors in __exit__, cleaned README.md
1 parent 6a0b945 commit 02b8c36

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# MagicPickle
2-
`magicpickle` allows you to transfer pickled representations of objects between local and remote instances of scripts, providing a near-seamless way of write code which both accesses data stored remotely and visualizes it locally. This avoids the need to:
2+
`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:
33
- store, load, and sync intermediate data representations between local and remote machines
44
- use X11 forwarding/VNC with noticable latency
55

66
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.
77

8-
Note that `magicpickle` assumes that each `mp.save` is associated with a single `mp.load` in the same script (assumes that both local and remote instances have the same control flow).
8+
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.
99

1010
## Installation
1111
```pip install magicpickle```

magicpickle/magicpickle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def __enter__(self):
7777
return self
7878

7979
def __exit__(self, exc_type, exc_value, traceback):
80-
if not self.is_local:
80+
# only run when no errors
81+
if exc_type is None and self.is_remote:
8182
joblib.dump(self.store, self.store_path, compress=self.compress)
8283
command = f"wormhole send {self.store_path}"
8384
subprocess.run(command.split(), check=True)
@@ -90,5 +91,5 @@ def load(self):
9091
return self.store.pop(0)
9192

9293
def save(self, obj):
93-
assert not self.is_local, "Cannot save in local mode"
94+
assert self.is_remote, "Cannot save in local mode"
9495
self.store.append(obj)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "magicpickle"
3-
version = "0.0.2"
3+
version = "0.0.3"
44
description = "A wrapper around magic-wormhole and joblib to send pickled objects across the internet."
55
readme = "README.md"
66
license = {file = "LICENSE"}

0 commit comments

Comments
 (0)