Commit a7fa2df
authored
[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.1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
0 commit comments