Skip to content

Commit a7fa2df

Browse files
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.
2 parents ebceb19 + f9d7214 commit a7fa2df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gempy_engine/API/interp_single/_interp_scalar_field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def interpolate_scalar_field(solver_input: SolverInput, options: InterpolationOp
5151

5252
BackendTensor.pykeops_enabled = False
5353
match weights_cached:
54-
case None:
54+
case None :
5555
weights = _solve_and_store_weights(
5656
solver_input=solver_input,
5757
kernel_options=options.kernel_options,

0 commit comments

Comments
 (0)