Skip to content

Key the climate cache on the shared outputDir when it is set - #32

Open
eliotmcintire wants to merge 1 commit into
modsForFireSensefrom
fix-outputDir-cache
Open

eliotmcintire wants to merge 1 commit into
modsForFireSensefrom
fix-outputDir-cache

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

A shared climate folder set for hindcasts was never used: every year job restored its own 3.2 GB copy of the climate rasters instead. This makes the cached result depend on that folder when one is set, so the files land in it.

Affects: runs that set outputDir now write and reuse the climate rasters there; runs that leave it unset behave as before.

Technical details

Defect: canClimateData.R Init(), the prepClimateLayers() |> Cache(omitArgs = c("srcdir", "dstdir")) call (line ~279). dstdir was always omitted from the key, so an entry made with the per-run folder (outputPath(sim)/climate) was hit when outputDir pointed at a shared folder. reproducible then restores file-backed rasters relative to the run's outputPath, so the shared folder was created but stayed empty. reproducible behaves as designed.

Fix: sharedOut is computed once (the existing is.null/is.na test on P(sim)$outputDir), used for climatePathOut and for omitArgs = c("srcdir", if (!sharedOut) "dstdir"). Unset outputDir keeps the relocatable default. NEWS entry added; no version bump.

With outputDir set the key holds that absolute path, so a cache entry is per machine and moving the folder recomputes once; concurrent jobs wait on the per-key Cache lock, so one computes.

Reuses: the existing outputDir is.null/is.na test (now sharedOut) and the existing cacheCallsOf helper in test-cacheOmitArgs.R; new: nothing (no new function).

Tests: test-cacheOmitArgs.R evaluates the call's omitArgs with sharedOut FALSE (both folders omitted, all formals) and TRUE (dstdir keyed, srcdir omitted). Full module suite via testthat::test_dir, with the module folder named canClimateData: base 30 tests, 1 failure (the new test); branch 30 tests, 0 failures, 1 skip.

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire added bug Something isn't working backwards compatible Existing code and results keep working unchanged labels Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant