Skip to content

Keep the whole spread-fit ledger out of the data-prep cache key - #76

Merged
eliotmcintire merged 1 commit into
developmentfrom
fix/ledger-out-of-inputObjects-key
Oct 17, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
fix/ledger-out-of-inputObjects-key

Conversation

@eliotmcintire

Copy link
Copy Markdown
Collaborator

Hindcasts and refits redid an hour or two of data preparation per region whenever a new fit was saved anywhere. This stops that, while the later steps that do use the fit still re-run when this region's fit changes.

Affects: No change to results. Data preparation is reused across fits and hindcasts; each region rebuilds once more because the cache key changes once.

Technical details

Defect: fireSense_dataPrepFit.R:244 declared expectsInput("spreadFitPreRun"). SpaDES.core puts every expected input already in the sim into the .inputObjects cache key (simInit, suppliedElsewhere), and fireSense_ELFs puts the whole ledger (rows of all ELFs) there first, so any ELF's new fit missed the cache. .inputObjects and the functions it calls never read spreadFitPreRun (grep: only Init() uses it).

Fix: the expectsInput is gone (createsOutput kept, its description now explains why). The protection it gave stays through .useCacheArgs: dataPrepBuild, prepIgnitionFitData, prepEscapeFitData and prepSpreadFitData each add spreadFitPreRun = sim$spreadFitPreRun to .cacheExtra. SpaDES.core evaluates quoted entries in .runEvent() (R/simulation-spades.R ~1595, eval(envir = environment())), where sim is the live simList; the chaining path (R/cacheChainingJump.R ~240) also evaluates with sim. Init() (line ~411) always assigns sim$spreadFitPreRun (the CacheGeo rows within this study area, or NULL for a held-out fold), and it runs in init, which schedules all later events, so the key is this ELF's rows only, never the whole ledger.

Tests: new test-ledgerNotInInputObjectsKey.R (not an input; .inputObjects does not read it; Init() assigns it unconditionally; each event's .cacheExtra digests the same for the same rows and differently for a new own row or NULL; a ledger differing only in another ELF's rows gives the same readSpreadFitLedger() result for this study area). test-metadata.R updated. Branch: 108 tests, 0 failures, 1 skipped (fixture); base with the new file: 2 of the new tests fail. checkDocFiles/codoc clean; R CMD check (no manual, no tests) has no errors and one WARNING about an import replaced during package conversion, unrelated to this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_019T7wFP7tXPDaRn42BFLzjr

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotmcintire eliotmcintire added the bug Something isn't working label Oct 17, 2026
@eliotmcintire
eliotmcintire merged commit 45ad3a6 into development Oct 17, 2026
8 checks passed
@eliotmcintire
eliotmcintire deleted the fix/ledger-out-of-inputObjects-key branch October 17, 2026 16:09
eliotmcintire added a commit that referenced this pull request Oct 17, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019T7wFP7tXPDaRn42BFLzjr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant