Skip to content

Fix continuity-analysis NameError in webui and training time log in finetune_csv - #402

Open
ideacobra wants to merge 1 commit into
shiyu-coder:masterfrom
ideacobra:ideacobra-fix-webui-finetune-bugs
Open

ideacobra wants to merge 1 commit into
shiyu-coder:masterfrom
ideacobra:ideacobra-fix-webui-finetune-bugs

Conversation

@ideacobra

Copy link
Copy Markdown

Why

Two small but real bugs turned up during a code review pass over model/, webui/, and finetune*/:

  1. webui/app.py: In save_prediction_results, the continuity-analysis block (which computes last_prediction, first_actual, gaps, and gap percentages) was indented one level too shallow. first_actual and the save_data['analysis']['continuity'] assignment sat outside the if len(prediction_results) > 0 and len(actual_data) > 0 guard, even though they reference last_pred, which is only defined inside that guard. Whenever actual_data was present but prediction_results was empty, this raised a NameError. Because the whole function body is wrapped in a broad try/except, the error was swallowed silently and prediction results simply failed to save, with only a generic log message.

  2. finetune_csv/finetune_tokenizer.py: The end-of-epoch summary logs both "Epoch Time" and "Total Training Time", but both were computed from the same epoch_start_time, which is reset at the top of every epoch loop iteration. As a result, "Total Training Time" always equaled "Epoch Time" instead of accumulating across the whole run, making the logged totals misleading. The sibling script finetune/train_tokenizer.py does this correctly by tracking a separate start_time captured once before the epoch loop; this change brings finetune_csv/finetune_tokenizer.py in line with that pattern.

What changed

  • webui/app.py: Re-nested first_actual and the continuity dict assignment inside the if len(prediction_results) > 0 and len(actual_data) > 0 block so last_pred/first_actual are always defined before use. No behavioral change to the analysis logic itself, just the control flow.
  • finetune_csv/finetune_tokenizer.py: Added start_time = time.time() once before the epoch loop in train_tokenizer, and changed the "Total Training Time" log line to use start_time instead of epoch_start_time.

Verification

  • Both files pass python3 -m py_compile.
  • Manually exercised save_prediction_results with stubbed dependencies for both the previously-crashing case (empty prediction_results with non-empty actual_data) and the normal case (both present), confirming no NameError and correct gap_percentages output.
…e log in finetune_csv

- webui/app.py: last_pred/first_actual continuity analysis block was
  incorrectly indented outside the "if len(prediction_results) > 0"
  check, causing a NameError (silently swallowed by the outer
  try/except) whenever actual_data was present but prediction_results
  was empty. Nest the block correctly so it only runs when both
  last_pred and first_actual are defined.
- finetune_csv/finetune_tokenizer.py: "Total Training Time" was
  computed from epoch_start_time (reset every epoch), so it always
  equaled "Epoch Time". Added a start_time captured once before the
  epoch loop and use it for the total-time log, matching the pattern
  already used in finetune/train_tokenizer.py.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kossto82-ops added a commit to kossto82-ops/Kronos that referenced this pull request Oct 12, 2026
…nce panel

- model: explicit eval() in KronosPredictor, greedy decoding for T<=0
- app: input validation in /api/predict, robust load_data_file (case-insensitive
  columns, sort/dedupe timestamps, synthetic-date flag), fix UnboundLocalError
  in save_prediction_results (upstream shiyu-coder#402)
- app: walk-forward self-evaluation endpoints (/api/evaluate, status, cache)
  with verdict (good/medium/bad) vs no-op baseline, confidence in /api/predict
- ui: confidence panel with traffic light and warning under prediction summary,
  T=0 deterministic option, sampling params shown in summary badge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants