fix(LamNI): don't block the tomo queue on the fine-alignment check

tomo_queue_execute() runs queued scans unattended, potentially for
hours -- tomo_scan()'s fine-alignment prompt would block forever there
with nobody watching. Add interactive: bool = True; when False (queue
use), the check no longer prompts or aborts -- it prints a bold red
warning, waits 10s, and always proceeds.

Also remove the outer "bec.active_account != ''" short-circuit that
hard-coded tomo_id=0 for an empty account without even attempting
registration -- always call add_sample_database() now and let
TomoIDManager.register() (test-host registration, previous commit)
decide the right outcome instead of pre-empting it here.
This commit is contained in:
x01dc
2026-07-27 17:01:52 +02:00
parent 64f5a57fa1
commit 1159b018f0
@@ -1631,7 +1631,12 @@ class LamNI(TomoQueueMixin, LamNIAlignmentMixin, LamNIOpticsMixin, LamniGuiTools
return angle, subtomo_number
def tomo_scan(
self, subtomo_start=1, start_angle=None, projection_number=None, force: bool = False
self,
subtomo_start=1,
start_angle=None,
projection_number=None,
force: bool = False,
interactive: bool = True,
):
"""Start a tomo scan.
@@ -1639,7 +1644,13 @@ class LamNI(TomoQueueMixin, LamNIAlignmentMixin, LamNIOpticsMixin, LamniGuiTools
subtomo_start (int): For tomo_type 1, the sub-tomogram to start from. Defaults to 1.
start_angle (float, optional): Override starting angle of the first sub-tomogram.
projection_number (int, optional): For tomo_types 2 and 3, resume from this index.
force: skip the fine-alignment check below without prompting.
force: skip the fine-alignment check below entirely (no warning at all).
interactive: if True (default, normal CLI use), the fine-alignment
check prompts and can abort. If False (used by
tomo_queue_execute() for unattended queued runs, where
input() would just hang forever with nobody watching), the
check instead prints a bold warning, waits 10s, and always
proceeds -- it never aborts or raises.
"""
self.lamnigui_show_progress()
@@ -1656,34 +1667,40 @@ class LamNI(TomoQueueMixin, LamNIAlignmentMixin, LamNIOpticsMixin, LamniGuiTools
or (self.tomo_type == 2 and projection_number is None)
or (self.tomo_type == 3 and projection_number is None)
):
if not self.corr_pos_x:
if not self._confirm_sequence_override(
if not self.corr_pos_x and not force:
warning = (
"No fine (ptycho) alignment correction is loaded -- the "
"sample centre will drift across projection angles "
"uncorrected. Fine for a large FOV that doesn't need it; "
"otherwise run tomo_alignment_scan() and "
"read_additional_correction() first.",
force,
):
print("Aborting tomo scan.")
return
# bec.active_account is already a plain str, not bytes -- .decode()
# crashes with AttributeError. Also guard against no active
# e-account (empty string, e.g. a dev/sim session not logged into
# a real account) rather than trying to register a sample under
# one -- mirrors Flomni.tomo_scan()'s equivalent check exactly.
if bec.active_account != "":
self.tomo_id = self.add_sample_database(
self.sample_name,
str(datetime.date.today()),
bec.active_account,
bec.queue.next_scan_number,
"lamni",
"test additional info",
"BEC",
"read_additional_correction() first."
)
else:
self.tomo_id = 0
if interactive:
if not self._confirm_sequence_override(warning, force=False):
print("Aborting tomo scan.")
return
else:
self.OMNYTools.printredbold(f"WARNING: {warning}")
self.OMNYTools.printredbold(
"Proceeding automatically in 10 s (unattended/queued run)..."
)
time.sleep(10)
# bec.active_account is already a plain str, not bytes -- .decode()
# crashes with AttributeError. Always attempt registration (even
# for an empty/test account) and let add_sample_database() ->
# TomoIDManager.register() decide production vs. test-server vs.
# genuine-failure fallback -- this used to short-circuit straight
# to tomo_id=0 for an empty account, which also skipped the
# test-server registration path entirely.
self.tomo_id = self.add_sample_database(
self.sample_name,
str(datetime.date.today()),
bec.active_account or "",
bec.queue.next_scan_number,
"lamni",
"test additional info",
"BEC",
)
self.write_pdf_report()
self.progress["tomo_start_time"] = datetime.datetime.now().isoformat()
# reset stale estimates from any previous scan, otherwise the GUI