You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FIX] Reuse weights calculation instead of raising error on hash mismatch (#27)
### TL;DR
Improved weights caching behavior by recalculating weights when hash mismatch occurs instead of raising an error, and added automatic cache directory initialization.
### What changed?
- Modified the behavior in `interpolate_scalar_field` to recalculate weights when a hash mismatch is detected instead of raising a "Cache is corrupted" error
- Added automatic initialization of the weights cache directory in the `compute_model` function by calling `WeightCache.initialize_cache_dir()`
- Added the necessary import for `WeightCache` in the model_api.py file
### How to test?
1. Run a model with caching enabled
2. Modify the model parameters and run again to trigger a hash mismatch
3. Verify that the model recalculates weights instead of raising an error
4. Check that the cache directory is automatically created when running a model
### Why make this change?
This change improves the user experience by making the caching system more robust. Instead of failing with an error when cached weights don't match the current model configuration, the system now gracefully recalculates the weights. Additionally, automatic cache directory initialization prevents errors that could occur if the directory doesn't exist.
0 commit comments