Skip to content

Fix review comments: backtest-only fold coverage, null_converter safety, CHRONOS_MAX_RETRIES clarity, retry tests#247

Merged
smdp2000ofc merged 3 commits into
som/chronos-best-model-fixfrom
copilot/sub-pr-246
Apr 30, 2026
Merged

Fix review comments: backtest-only fold coverage, null_converter safety, CHRONOS_MAX_RETRIES clarity, retry tests#247
smdp2000ofc merged 3 commits into
som/chronos-best-model-fixfrom
copilot/sub-pr-246

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Addresses four reviewer concerns from the previous PR: a type-safety bug in null_converter, ambiguous retry documentation, fold coverage logic incorrectly including future forecast IDs, and missing unit tests for the retry path.

null_converter() — type-safe NULL string check

x == "NULL" coerces non-character scalars and can propagate NA into an if condition. Changed to identical(x, "NULL"):

# before — unsafe for numeric/logical/NA inputs
if (is.na(x) || x == "NULL")

# after — exact, no coercion
if (is.na(x) || identical(x, "NULL"))

CHRONOS_MAX_RETRIES — clarify retry vs attempt semantics

CHRONOS_MAX_RETRIES = 3 means 3 retries, 4 total attempts. Updated the constant comment and send_chronos_request docstring to state this explicitly. Loop behavior is unchanged.

final_models.R — exclude future forecast ID from fold coverage

train_test_id_list includes Train_Test_ID == 1 (future forecast). Using it as the denominator for back test fold coverage unfairly excluded models that produced back tests but not future output. Changed to:

back_test_id_list <- setdiff(train_test_id_list, 1)
expected_back_test_fold_count <- length(back_test_id_list)

Also vectorized the per-model warning (list-columns via summarise/mutate) to avoid O(N×M) repeated filtering, added expected_back_test_fold_count == 0 edge-case handling, and ensured the empty partial_models_tbl carries all expected columns.

New tests

  • send_chronos_request: 5 tests with mocked httr::POST and a no-op backoff_wait — connection error exhaustion (exactly 4 attempts), 429→success, 500→success, non-retryable 4xx (1 attempt), and total-attempt boundary (CHRONOS_MAX_RETRIES + 1).
  • null_converter: 7 tests covering NULL, zero-length, "NULL" string, NA variants, normal values, multi-element vectors, and non-character scalars.

Copilot AI and others added 2 commits April 30, 2026 17:38
…, backtest-only fold coverage, retry tests

Agent-Logs-Url: https://github.com/microsoft/finnts/sessions/fbb0b01c-29a0-4759-a221-760420544afa

Co-authored-by: smdp2000ofc <236835326+smdp2000ofc@users.noreply.github.com>
…lumns

Agent-Logs-Url: https://github.com/microsoft/finnts/sessions/fbb0b01c-29a0-4759-a221-760420544afa

Co-authored-by: smdp2000ofc <236835326+smdp2000ofc@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix null backtest fold and best model selection Fix review comments: backtest-only fold coverage, null_converter safety, CHRONOS_MAX_RETRIES clarity, retry tests Apr 30, 2026
Copilot AI requested a review from smdp2000ofc April 30, 2026 17:40
@smdp2000ofc smdp2000ofc marked this pull request as ready for review April 30, 2026 17:57
@smdp2000ofc smdp2000ofc merged commit 0299f2d into som/chronos-best-model-fix Apr 30, 2026
1 check passed
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.

2 participants