Run-header rewrite (fix blank-log bug) + live run progress & time-remaining#24
Merged
Conversation
Fixes a log-output race where early run header text could be dropped before the first optimizer/SCF line. The run header is now generated and written synchronously on the main thread with a single atomic `run_output.outputs` assignment, and the background-thread header write was removed. Also expands `format_log_header()` to include richer run provenance (host, Python/PySCF versions, device/machine/thread info, method/functional split, solvation, output dir, export formats, calc ID/timestamp) and adds startup warm-up of cached system info to keep first-click latency low. Adds regression tests to verify atomic header write behavior and stale-log clearing when no molecule is set.
Introduces M-PROGRESS Phase A updates to make long silent compute phases visibly active in the UI. `QuantUIApp` now starts/stops a background elapsed-time ticker and shows a live elapsed chip beside `run_status` during runs. `_LogCapture` gained `set_status()` so calculation modules can update the status label without writing log lines. Adds `log_utils.emit_status()` (duck-typed status updates) and `format_elapsed()` for compact timer display, then wires status heartbeats into optimizer and PES scan silent SCF/gradient loops. Reorganization-energy flows now pass context-specific optimizer status labels. Test coverage was added for elapsed formatting, ticker lifecycle/UI updates, and `emit_status` behavior (including no-op on plain streams).
Extended `attach_scf_cancel_callback` to support an optional per-cycle `progress_cb` alongside cancellation checks, so silent SCF loops can still report heartbeat progress while remaining cancellable. Wired new status emissions into single-point, TDDFT, and NMR flows for key phases (SCF, correlation, excited states, shielding), and added optimizer per-cycle SCF progress messages during geometry steps. Updated cancellation tests to cover progress callback execution and composition with cancel behavior.
Wire performance estimates into the live run ticker by storing estimated duration/confidence on the app and rendering an elapsed chip that can show `~<time> left`, mark low-confidence estimates as `(rough)`, and switch to `longer than estimated` after overrun. Also adds focused app tests covering elapsed-only, remaining-time, low-confidence, and overdue display behavior.
Update the run controls layout to place `run_status` and `_run_elapsed_lbl` in a vertical `VBox` instead of a single horizontal row. This prevents the elapsed/remaining timer chip from crowding or truncating longer status text while keeping the run/cancel controls aligned.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where the pre-step-1 log stream never appeared for large molecules,
rewrites the run header to be instant + information-rich, and adds live run
progress (M-PROGRESS Phase A + B1) so a running calc never looks frozen.
All changes verified in Voilà (large-molecule geometry opt): header prints
instantly, the status + elapsed/remaining readout advance live.
Bug fix — pre-step-1 blank log window
For a large molecule the live log jumped straight to
BFGS: 0 …with no header.Root cause: the header was written via
clear_output()+append_stdout()and abackground-thread
append_stdout(the structured banner) — both unreliable inVoilà (the app already marshals bg-thread
.outputswrites through the io_loopeverywhere else). The long silent gap before the first optimizer step exposed the
race.
Fix: the full header is now built and assigned in a single atomic
run_output.outputs = (…)on the main thread inon_run_clicked(
app_runflow._write_run_header); the fragile bg-thread banner write is removed.get_system_info()islru_cached + warmed at startup so the click stays instant.Run header — logo + provenance banner
The banner now leads with an ASCII
QuantUIwordmark and reports full runprovenance: Calculation ID, UTC timestamp, host, Python/PySCF versions, device
(GPU/CPU), method/functional split (RKS/UKS + functional), basis, solvation, job
type, input structure + atom count, output directory, and export formats.
M-PROGRESS Phase A — live progress visibility (A1–A4)
any silent native phase, for every calc type (
_start/_stop_elapsed_ticker,bg-thread
HTML.valuewrites are thread-safe).verbose=0) optimizer /PES / reorg steps via
log_utils.emit_status+_LogCapture.set_status(updates the status line without cluttering the log).
attach_scf_cancel_callback(..., progress_cb=…)hook.(SCF / TD-DFT solve), and nmr (SCF / GIAO).
M-PROGRESS B1 — total-based time remaining
The elapsed chip folds in the pre-run estimate the app already computes:
⏱ 0:52 · ~0:36 left, marked(rough)for low-confidence estimates, switchingto
longer than estimatedpast the estimate, and degrading to elapsed-only withno history. Honest-by-design (no false precision — the estimator overhaul is
tracked separately under M-PROGRESS Phase C / M-EST).
Layout
Status line and the elapsed/remaining chip are stacked vertically (status on top,
timer below) so the timer never crowds/truncates a longer status line.
Testing
TestRunHeader,TestProgressTicker,TestRemainingTimeChip,TestStatusHeartbeat, and cancel-hook progress tests.test_app+test_code_quality+ calc-module suites pass onquantui-win; ruff + black clean (pinned pre-commit).Updates directed by @NCCU-Schultz-Lab
Code facilitation and PR overview generated with Claude Code