Repository navigation
Warn when init_function is combined with cache_directory - #1085
Conversation
The cache key is computed from the submitted function and its arguments only, so it does not reflect the state set by the init_function. Functions which depend on this state can therefore return stale results from the cache. Until this is fixed, warn the user when both options are set. See #1084 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1085 +/- ##
==========================================
+ Coverage 94.26% 94.28% +0.01%
==========================================
Files 39 39
Lines 2180 2187 +7
==========================================
+ Hits 2055 2062 +7
Misses 125 125 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@prabhath-c This should at least give a warning when using the |
Summary
Addresses #1084 by warning the user. This does not fix the underlying caching issue.
The cache key is computed from
fn,argsandkwargsonly. It does not include the state theinit_functionsets up in the worker. Functions that read this state can therefore get stale results from the cache, without any error. Until the cache key accounts for that state, executorlib now emits aUserWarningwheninit_functionandcache_directoryare both set.Changes
check_init_function_with_cache()instandalone/inputcheck.py. It warns when bothinit_functionandcache_directoryare notNone.block_allocation=True:create_single_node_executor(SingleNodeExecutor)create_slurm_executor(SlurmJobExecutor)create_flux_executor(FluxJobExecutor)create_pysqa_block_allocation_scheduler(SlurmClusterExecutor/FluxClusterExecutorwith block allocation)test_inputcheck.py: checks that the warning is raised when both options are set, and that no warning is raised when either one isNone.test_single_cache.py:SingleNodeExecutorwith a statefulinit_functionemits the warning. The test also records the current wrong result[1, 1, 1](the expected result is[1, 2, 3]), so it will fail once Cache returns stale results with block_allocation + init_function: worker memory is not part of the cache key #1084 is properly fixed and will need updating then.Testing
tests/unit/standalone/test_inputcheck.py,tests/unit/executor/test_single_cache.py,test_single_noblock.py,test_single_dependencies.py,test_api.py: pass locally.ruff check/ruff format --checkon the changed source files: clean.tests/unit/standalone/interactive/test_spawner.pyand the MPI executor tests fail locally onmainas well. My local MPI setup runs only one rank, so these failures are unrelated to this PR.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests