Skip to content

Run-header rewrite (fix blank-log bug) + live run progress & time-remaining#24

Merged
NCCU-Schultz-Lab merged 5 commits into
mainfrom
output-stream-fix
Jul 18, 2026
Merged

Run-header rewrite (fix blank-log bug) + live run progress & time-remaining#24
NCCU-Schultz-Lab merged 5 commits into
mainfrom
output-stream-fix

Conversation

@NCCU-Schultz-Lab

Copy link
Copy Markdown
Collaborator

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 a
background-thread append_stdout (the structured banner) — both unreliable in
Voilà (the app already marshals bg-thread .outputs writes through the io_loop
everywhere 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 in on_run_clicked
(app_runflow._write_run_header); the fragile bg-thread banner write is removed.
get_system_info() is lru_cached + warmed at startup so the click stays instant.

Run header — logo + provenance banner

The banner now leads with an ASCII QuantUI wordmark and reports full run
provenance: 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)

  • A1 — universal elapsed-time ticker chip that advances every ~1 s through
    any silent native phase, for every calc type (_start/_stop_elapsed_ticker,
    bg-thread HTML.value writes are thread-safe).
  • A2 — per-step stage heartbeats for the (silent, verbose=0) optimizer /
    PES / reorg steps via log_utils.emit_status + _LogCapture.set_status
    (updates the status line without cluttering the log).
  • A3 — per-SCF-cycle heartbeat during silent SCF, via the shared
    attach_scf_cancel_callback(..., progress_cb=…) hook.
  • A4 — stage markers across session_calc (SCF / MP2 / CCSD / (T)), tddft
    (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, switching
to longer than estimated past the estimate, and degrading to elapsed-only with
no 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

  • New: TestRunHeader, TestProgressTicker, TestRemainingTimeChip,
    TestStatusHeartbeat, and cancel-hook progress tests.
  • Full test_app + test_code_quality + calc-module suites pass on
    quantui-win; ruff + black clean (pinned pre-commit).

Updates directed by @NCCU-Schultz-Lab
Code facilitation and PR overview generated with Claude Code

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.
@NCCU-Schultz-Lab
NCCU-Schultz-Lab merged commit c3877c5 into main Jul 18, 2026
5 checks passed
@NCCU-Schultz-Lab
NCCU-Schultz-Lab deleted the output-stream-fix branch July 18, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant