Skip to content

outputDir can be keyed on its last folders: asPath(dir, nParentDirs) - #33

Merged
eliotmcintire merged 2 commits into
modsForFireSensefrom
cache-key-paths
Nov 16, 2026
Merged

eliotmcintire merged 2 commits into
modsForFireSensefrom
cache-key-paths

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

The folder climate data is written to is part of the cache key, so a cache built on one computer does not match on another where the folder has a different prefix. This lets the folder be given so that only its last few components count, and documents how.

Affects: nothing changes unless a run passes the folder this way; then its event cache keys no longer hold the machine-specific prefix (they change once). Results are unchanged.

Technical details

Defect. outputDir (canClimateData.R:45) is keyed as the character string the run passes, so the absolute path (FireSenseTesting global.R:165, from .basePath) is in the key of every init. The module cannot drop it: in a hindcast it is the shared <hindcast>/<ELF>/climate folder that fireSimulator_validation reads, and an event cache hit for a new folder writes nothing there. A first version of this PR used cacheKey = FALSE; that is reverted.

Fix. No module code changes. reproducible::asPath(dir, nParentDirs) already makes Cache digest only the last nParentDirs + 1 components of a path, and the module already uses it for climatePathOut. A parameter given as a Path is digested that way in the event key (checked: the same <hindcast>/<ELF>/climate under two different prefixes is one key; another hindcast is a different key; a plain absolute path is keyed in full, as before). The parameter description now says so. A run passes outputDir = reproducible::asPath(<folder>, 2). NEWS.md has a bullet. Event keys change once for runs that switch.

Reuses: reproducible::asPath() (its nParentDirs digest); new: nothing (no new function or parameter; a relative-base parameter is not needed because asPath already keys the relative part).

Tests. test-outputDirKey.R: Init() writes under a Path outputDir; a stand-in module with the same parameter and a cached init gives one cache entry for the same relative folder under two prefixes, a second for another hindcast, a third for a plain path. These tests describe the existing mechanism, so they also pass on base code (the change here is the documented use). Full suite (convertToPackage + test_local as the testthat-module workflow; scratch library, SpaDES.core development 3.2.1.9069, climateData modsForFireSense): branch 0 failures, 0 errors, 1 skip (97 passed; the skip is the existing TODO in test-Init-layerNames.R); base 0, 0, 1 skip (92 passed).

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

… = FALSE)

A path or core count that differs between machines made the same run a cache miss on another machine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Nov 16, 2026
…er's last components; drop cacheKey = FALSE

An outputDir that is a shared hindcast climate folder must still miss for another folder, as a hit writes nothing there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire changed the title outputDir is not part of the event cache key outputDir can be keyed on its last folders: asPath(dir, nParentDirs) Nov 16, 2026
@eliotmcintire
eliotmcintire merged commit 4e56732 into modsForFireSense Nov 16, 2026
6 checks passed
@eliotmcintire
eliotmcintire deleted the cache-key-paths branch November 16, 2026 20:14
eliotmcintire added a commit that referenced this pull request Nov 16, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant