feat(tomo): warn and confirm on manual tomo_scan_resume() when queue has an unfinished job
CI for csaxs_bec / test (push) Successful in 3m8s
CI for csaxs_bec / test (push) Successful in 3m8s
A Ctrl-C abort leaves the queue job 'running'; resuming by hand bypasses the queue and a later tomo_queue_resume() would resume it again. Manual tomo_scan_resume() now lists the unfinished job, hints at tomo_queue_resume(), and asks y/N. tomo_queue_execute() passes from_queue=True to skip the prompt. OMNY port tracked in a TODO doc. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
acc5e3b477
commit
5112672368
5 files changed
+120
-5
No files matched your search
@@ -11,7 +11,7 @@ import types
|
||||
|
||||
import csaxs_bec.bec_ipython_client.plugins.LamNI.lamni as lamni_module
|
||||
import csaxs_bec.bec_ipython_client.plugins.OMNY_shared.tomo_queue_mixin as tomo_queue_mixin
|
||||
from csaxs_bec.bec_ipython_client.plugins.LamNI.lamni import LamNI, LamNIError
|
||||
from csaxs_bec.bec_ipython_client.plugins.LamNI.lamni import LamNI, LamNIError, _ProgressProxy
|
||||
|
||||
|
||||
class _FakeRtx:
|
||||
@@ -159,7 +159,7 @@ def test_tomo_queue_execute_resumes_incomplete_job():
|
||||
|
||||
lamni.tomo_queue_execute()
|
||||
|
||||
assert calls == [("resume", (), {})]
|
||||
assert calls == [("resume", (), {"from_queue": True})]
|
||||
job = lamni._tomo_queue_proxy.as_list()[0]
|
||||
assert job["status"] == "done"
|
||||
|
||||
@@ -302,3 +302,44 @@ def test_at_each_angle_hook_refreshed_after_module_reload(tmp_path, capsys):
|
||||
finally:
|
||||
sys.path.remove(str(tmp_path))
|
||||
sys.modules.pop(module_name, None)
|
||||
|
||||
|
||||
def _resumable_lamni(status=None, answer=True):
|
||||
lamni = make_lamni()
|
||||
calls = []
|
||||
lamni.tomo_scan = lambda *a, **k: calls.append(("scan", a, k))
|
||||
lamni.tomo_type = 2
|
||||
lamni._progress_proxy = _ProgressProxy(lamni.client)
|
||||
lamni.progress["tomo_start_time"] = "2026-01-01T00:00:00"
|
||||
lamni.progress["projection"] = 5
|
||||
lamni.OMNYTools = types.SimpleNamespace(yesno=lambda *a, **k: answer)
|
||||
if status:
|
||||
index = lamni.tomo_queue_add(label="job1")
|
||||
lamni._tomo_queue_proxy.update(index, status=status)
|
||||
return lamni, calls
|
||||
|
||||
|
||||
def test_tomo_scan_resume_no_unfinished_job_does_not_prompt():
|
||||
lamni, calls = _resumable_lamni(answer=False) # would abort if prompted
|
||||
lamni.tomo_scan_resume()
|
||||
assert calls == [("scan", (), {"projection_number": 5})]
|
||||
|
||||
|
||||
def test_tomo_scan_resume_warns_and_aborts_on_no(capsys):
|
||||
lamni, calls = _resumable_lamni(status="running", answer=False)
|
||||
lamni.tomo_scan_resume()
|
||||
assert calls == []
|
||||
out = capsys.readouterr().out
|
||||
assert "unfinished job" in out and "tomo_queue_resume()" in out
|
||||
|
||||
|
||||
def test_tomo_scan_resume_proceeds_on_yes():
|
||||
lamni, calls = _resumable_lamni(status="incomplete", answer=True)
|
||||
lamni.tomo_scan_resume()
|
||||
assert calls == [("scan", (), {"projection_number": 5})]
|
||||
|
||||
|
||||
def test_tomo_scan_resume_from_queue_never_prompts():
|
||||
lamni, calls = _resumable_lamni(status="running", answer=False)
|
||||
lamni.tomo_scan_resume(from_queue=True)
|
||||
assert calls == [("scan", (), {"projection_number": 5})]
|
||||
Reference in new issue
Block a user