runplz 4.2.0__tar.gz → 4.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {runplz-4.2.0/runplz.egg-info → runplz-4.2.2}/PKG-INFO +1 -1
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/ssh_common.py +30 -1
- runplz-4.2.2/runplz/version.py +1 -0
- {runplz-4.2.0 → runplz-4.2.2/runplz.egg-info}/PKG-INFO +1 -1
- {runplz-4.2.0 → runplz-4.2.2}/runplz.egg-info/SOURCES.txt +1 -0
- runplz-4.2.2/tests/test_output_salvage.py +181 -0
- runplz-4.2.0/runplz/version.py +0 -1
- {runplz-4.2.0 → runplz-4.2.2}/LICENSE +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/MANIFEST.in +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/README.md +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/pyproject.toml +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/__init__.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/_bootstrap.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/_cli.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/app.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/__init__.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/_ssh_common.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/aws.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/brev.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/docker.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/gcp.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/listing.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/local.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/modal.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/provisioning.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/registry.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/backends/ssh.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/bootstrap.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/cli.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/config.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/excludes.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/image.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/logcapture.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/runs.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz/selector.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz.egg-info/dependency_links.txt +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz.egg-info/entry_points.txt +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz.egg-info/requires.txt +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/runplz.egg-info/top_level.txt +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/setup.cfg +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_app_extras.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_bootstrap.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_bootstrap_imports.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_brev_backend.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_cli.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_cli_retries.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_cloud_backends.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_cloud_catalogue.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_cloud_consistency.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_cloud_ps.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_compat_shims.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_conftest_guard.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_coverage_branches.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_default_entrypoint.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_e2e_fake_cloud.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_e2e_localhost.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_inactivity_watchdog.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_kill.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_lifecycle_edges.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_lifecycle_matrix.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_local_backend.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_logcapture.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_modal_backend.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_preconditions.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_provider_blocklist.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_ps.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_public_api.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_rsync_faults.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_runplz.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_runs_cli.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_scripts.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_selector.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_selector_minimums.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_ssh_backend.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_ssh_common.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_ssh_faults.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_ssh_options.py +0 -0
- {runplz-4.2.0 → runplz-4.2.2}/tests/test_transport_retries.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: runplz
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.2
|
|
4
4
|
Summary: Tiny Modal-shaped job harness — one declaration, multiple backends (local Docker / Brev / Modal)
|
|
5
5
|
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -3160,6 +3160,7 @@ def dispatch_to_target(
|
|
|
3160
3160
|
container_name: Optional[str] = None
|
|
3161
3161
|
exit_code: Optional[int] = None
|
|
3162
3162
|
failure_tail = ""
|
|
3163
|
+
synced = False
|
|
3163
3164
|
try:
|
|
3164
3165
|
if mode == "container":
|
|
3165
3166
|
exit_code = run_container_mode(
|
|
@@ -3211,17 +3212,45 @@ def dispatch_to_target(
|
|
|
3211
3212
|
inactivity_action=inactivity_action,
|
|
3212
3213
|
ssh_opts=ssh_opts,
|
|
3213
3214
|
)
|
|
3215
|
+
# On the success path a failed sync is a real error: the run produced
|
|
3216
|
+
# results and we could not collect them.
|
|
3214
3217
|
rsync_down(target, host_out, remote_run=remote_run, ssh_opts=ssh_opts)
|
|
3218
|
+
synced = True
|
|
3215
3219
|
finally:
|
|
3216
3220
|
# Grab the log tail before the container goes away — `docker rm`
|
|
3217
3221
|
# wipes it, and a provisioning caller is about to delete the box.
|
|
3218
|
-
if exit_code is
|
|
3222
|
+
if exit_code is None or exit_code != 0:
|
|
3219
3223
|
failure_tail = fetch_failure_tail(
|
|
3220
3224
|
target=target,
|
|
3221
3225
|
container_name=container_name,
|
|
3222
3226
|
remote_run=remote_run,
|
|
3223
3227
|
ssh_opts=ssh_opts,
|
|
3224
3228
|
)
|
|
3229
|
+
if not synced:
|
|
3230
|
+
# Something is already unwinding — a runtime cap, a stream error,
|
|
3231
|
+
# a box reclaimed mid-run. Whatever the job managed to write is
|
|
3232
|
+
# often the only evidence of what went wrong, and `max_runtime_seconds`
|
|
3233
|
+
# exists precisely to salvage a wedged run (#150). Everything inside
|
|
3234
|
+
# this `try` happens after rsync_up proved the box reachable, so a
|
|
3235
|
+
# sync here is worth attempting.
|
|
3236
|
+
#
|
|
3237
|
+
# Best-effort on purpose: an exception is on its way out and must
|
|
3238
|
+
# not be replaced by an rsync error naming the wrong problem.
|
|
3239
|
+
try:
|
|
3240
|
+
rsync_down(target, host_out, remote_run=remote_run, ssh_opts=ssh_opts)
|
|
3241
|
+
except Exception as exc: # noqa: BLE001
|
|
3242
|
+
print(
|
|
3243
|
+
f"+ warning: could not collect outputs after failure: "
|
|
3244
|
+
f"{type(exc).__name__}: {exc}",
|
|
3245
|
+
flush=True,
|
|
3246
|
+
)
|
|
3247
|
+
if failure_tail:
|
|
3248
|
+
print(
|
|
3249
|
+
f"--- last {FAILURE_TAIL_LINES} lines of remote output ---\n"
|
|
3250
|
+
f"{failure_tail}\n"
|
|
3251
|
+
f"--- end remote output ---",
|
|
3252
|
+
flush=True,
|
|
3253
|
+
)
|
|
3225
3254
|
if container_name is not None:
|
|
3226
3255
|
try:
|
|
3227
3256
|
ssh_capture(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "4.2.2"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: runplz
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.2
|
|
4
4
|
Summary: Tiny Modal-shaped job harness — one declaration, multiple backends (local Docker / Brev / Modal)
|
|
5
5
|
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""Outputs survive the failure paths that were meant to salvage them (#150).
|
|
2
|
+
|
|
3
|
+
`max_runtime_seconds` is documented as a kill-switch for a wedged job — the
|
|
4
|
+
case where whatever the run managed to write is often the only evidence of
|
|
5
|
+
what went wrong. It discarded exactly that: `rsync_down` sat inside the
|
|
6
|
+
`try` *after* the runner, so a cap raise skipped the sync entirely, and
|
|
7
|
+
`exit_code` was still None so the `finally` did not even fetch the failure
|
|
8
|
+
tail. On a provisioning backend the box was then torn down with the results
|
|
9
|
+
still on it.
|
|
10
|
+
|
|
11
|
+
These drive the real `dispatch_to_target`, stubbing only the boundary calls,
|
|
12
|
+
so the ordering under test is the ordering that ships.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from unittest import mock
|
|
16
|
+
|
|
17
|
+
import pytest
|
|
18
|
+
|
|
19
|
+
from runplz import App, Image
|
|
20
|
+
from runplz.backends import ssh_common as sc
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _app(tmp_path):
|
|
24
|
+
repo = tmp_path / "repo"
|
|
25
|
+
repo.mkdir(parents=True, exist_ok=True)
|
|
26
|
+
(repo / "job.py").write_text("# job\n")
|
|
27
|
+
app = App("vision")
|
|
28
|
+
|
|
29
|
+
@app.function(image=Image.from_registry("ubuntu:22.04"))
|
|
30
|
+
def train(): # pragma: no cover - never executed
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
fn = app.functions["train"]
|
|
34
|
+
fn.module_file = str(repo / "job.py")
|
|
35
|
+
app.repo_root = repo
|
|
36
|
+
return app, fn
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _dispatch(tmp_path, *, runner, mode="container"):
|
|
40
|
+
"""Run dispatch_to_target with everything before the run stubbed out."""
|
|
41
|
+
app, fn = _app(tmp_path)
|
|
42
|
+
patches = {
|
|
43
|
+
"prepare_remote_run": mock.DEFAULT,
|
|
44
|
+
"ensure_remote_rsync": mock.DEFAULT,
|
|
45
|
+
"rsync_up": mock.DEFAULT,
|
|
46
|
+
"check_preconditions": mock.DEFAULT,
|
|
47
|
+
"rsync_down": mock.DEFAULT,
|
|
48
|
+
"fetch_failure_tail": mock.DEFAULT,
|
|
49
|
+
"build_remote_run_manifest": mock.DEFAULT,
|
|
50
|
+
}
|
|
51
|
+
with mock.patch.multiple(sc, **patches) as mocks:
|
|
52
|
+
mocks["fetch_failure_tail"].return_value = "Traceback: boom"
|
|
53
|
+
with mock.patch.object(sc, "run_container_mode", side_effect=runner):
|
|
54
|
+
try:
|
|
55
|
+
sc.dispatch_to_target(
|
|
56
|
+
app=app,
|
|
57
|
+
function=fn,
|
|
58
|
+
args=[],
|
|
59
|
+
kwargs={},
|
|
60
|
+
target="box",
|
|
61
|
+
backend="ssh",
|
|
62
|
+
mode=mode,
|
|
63
|
+
)
|
|
64
|
+
except BaseException as exc: # noqa: BLE001
|
|
65
|
+
return mocks, exc
|
|
66
|
+
return mocks, None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_a_capped_run_still_collects_its_partial_outputs(tmp_path):
|
|
70
|
+
"""The bug: `rsync_down` never ran when the cap fired, so a long training
|
|
71
|
+
run terminated at its deadline lost every checkpoint it had written."""
|
|
72
|
+
|
|
73
|
+
def capped(**kwargs):
|
|
74
|
+
raise RuntimeError("Remote run exceeded max_runtime_seconds=5")
|
|
75
|
+
|
|
76
|
+
mocks, raised = _dispatch(tmp_path, runner=capped)
|
|
77
|
+
|
|
78
|
+
assert isinstance(raised, RuntimeError)
|
|
79
|
+
assert "max_runtime_seconds" in str(raised)
|
|
80
|
+
mocks["rsync_down"].assert_called_once()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_the_original_failure_is_not_replaced_by_a_sync_error(tmp_path):
|
|
84
|
+
"""A box reclaimed mid-run cannot sync. The user must still be told why
|
|
85
|
+
the run died, not handed an rsync error naming the wrong problem."""
|
|
86
|
+
|
|
87
|
+
def capped(**kwargs):
|
|
88
|
+
raise RuntimeError("Remote run exceeded max_runtime_seconds=5")
|
|
89
|
+
|
|
90
|
+
app, fn = _app(tmp_path)
|
|
91
|
+
with mock.patch.multiple(
|
|
92
|
+
sc,
|
|
93
|
+
prepare_remote_run=mock.DEFAULT,
|
|
94
|
+
ensure_remote_rsync=mock.DEFAULT,
|
|
95
|
+
rsync_up=mock.DEFAULT,
|
|
96
|
+
check_preconditions=mock.DEFAULT,
|
|
97
|
+
build_remote_run_manifest=mock.DEFAULT,
|
|
98
|
+
fetch_failure_tail=mock.DEFAULT,
|
|
99
|
+
):
|
|
100
|
+
with (
|
|
101
|
+
mock.patch.object(sc, "rsync_down", side_effect=OSError("host unreachable")),
|
|
102
|
+
mock.patch.object(sc, "run_container_mode", side_effect=capped),
|
|
103
|
+
pytest.raises(RuntimeError, match="max_runtime_seconds"),
|
|
104
|
+
):
|
|
105
|
+
sc.dispatch_to_target(
|
|
106
|
+
app=app,
|
|
107
|
+
function=fn,
|
|
108
|
+
args=[],
|
|
109
|
+
kwargs={},
|
|
110
|
+
target="box",
|
|
111
|
+
backend="ssh",
|
|
112
|
+
mode="container",
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_the_failure_tail_is_fetched_when_the_run_raised(tmp_path):
|
|
117
|
+
"""`exit_code` is still None on a raise, and the old gate was
|
|
118
|
+
`exit_code is not None and exit_code != 0` — so the one path that most
|
|
119
|
+
needed the remote log tail was the one that never fetched it."""
|
|
120
|
+
|
|
121
|
+
def capped(**kwargs):
|
|
122
|
+
raise RuntimeError("Remote run exceeded max_runtime_seconds=5")
|
|
123
|
+
|
|
124
|
+
mocks, _ = _dispatch(tmp_path, runner=capped)
|
|
125
|
+
mocks["fetch_failure_tail"].assert_called_once()
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_the_tail_is_surfaced_rather_than_computed_and_dropped(tmp_path, capsys):
|
|
129
|
+
"""Fetching it and discarding it would be worse than not fetching: the
|
|
130
|
+
raised error carries no tail, so it has to reach stdout."""
|
|
131
|
+
|
|
132
|
+
def capped(**kwargs):
|
|
133
|
+
raise RuntimeError("Remote run exceeded max_runtime_seconds=5")
|
|
134
|
+
|
|
135
|
+
_dispatch(tmp_path, runner=capped)
|
|
136
|
+
assert "Traceback: boom" in capsys.readouterr().out
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_a_successful_run_syncs_exactly_once(tmp_path):
|
|
140
|
+
"""The salvage must not double-sync a healthy run."""
|
|
141
|
+
mocks, raised = _dispatch(tmp_path, runner=lambda **kw: 0)
|
|
142
|
+
assert raised is None
|
|
143
|
+
mocks["rsync_down"].assert_called_once()
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def test_a_failed_sync_on_a_successful_run_is_still_an_error(tmp_path):
|
|
147
|
+
"""The success path stays strict. A run that produced results and could
|
|
148
|
+
not deliver them has failed, and swallowing that would lose outputs
|
|
149
|
+
silently — the failure mode this whole issue is about."""
|
|
150
|
+
app, fn = _app(tmp_path)
|
|
151
|
+
with mock.patch.multiple(
|
|
152
|
+
sc,
|
|
153
|
+
prepare_remote_run=mock.DEFAULT,
|
|
154
|
+
ensure_remote_rsync=mock.DEFAULT,
|
|
155
|
+
rsync_up=mock.DEFAULT,
|
|
156
|
+
check_preconditions=mock.DEFAULT,
|
|
157
|
+
build_remote_run_manifest=mock.DEFAULT,
|
|
158
|
+
fetch_failure_tail=mock.DEFAULT,
|
|
159
|
+
):
|
|
160
|
+
with (
|
|
161
|
+
mock.patch.object(sc, "rsync_down", side_effect=OSError("disk full")),
|
|
162
|
+
mock.patch.object(sc, "run_container_mode", return_value=0),
|
|
163
|
+
pytest.raises(OSError, match="disk full"),
|
|
164
|
+
):
|
|
165
|
+
sc.dispatch_to_target(
|
|
166
|
+
app=app,
|
|
167
|
+
function=fn,
|
|
168
|
+
args=[],
|
|
169
|
+
kwargs={},
|
|
170
|
+
target="box",
|
|
171
|
+
backend="ssh",
|
|
172
|
+
mode="container",
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def test_a_nonzero_exit_syncs_once_not_twice(tmp_path):
|
|
177
|
+
"""A run that fails normally already synced on the success path; the
|
|
178
|
+
salvage branch must not run again for it."""
|
|
179
|
+
mocks, raised = _dispatch(tmp_path, runner=lambda **kw: 3)
|
|
180
|
+
assert isinstance(raised, RuntimeError)
|
|
181
|
+
mocks["rsync_down"].assert_called_once()
|
runplz-4.2.0/runplz/version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "4.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|