fix WaveformExtractor backwards compatiblity: run backwards compatiblity migration before validating metrics#4509
Conversation
Currently, `_read_old_waveforms_extractor_binary` calls set_params before `_handle_backward_compatibility_on_load`, so validation aborts the load before SI's own migration handler gets to run. This commit changes the order of operations so the migration handler runs first on the parameters as saved on disk, which are then pruned and validated by `make_ext_params_up_to_date` and `set_params`, respectively. Fixes: 4508
|
Is there a test we could add that might help us catch a problem like this in the future. Not a simple change-detector test but a way to validate our backward compatibility better? I don't think that should slow down this PR, but I have always believed we should try to prevent these issues the best we can or we make it clear that we are having a clean break (e.g. we discussed dropping all waveform extractors at one point, but decided against it unless it has changed again). |
Good point Zach - I've been thinking about this a bit. We could do something like: set up a GH action which makes an analyzer for each spikeinterface version, then load/tests it with the latest release. It's on my to do list, but is a bit of a project. Would be nice to set up uv+caching in the CI first, so that quickly installing 10 si versions was fast! |
chrishalcrow
left a comment
There was a problem hiding this comment.
Great, thanks! LGTM and nice that the logic follows the analyzer more closely :)
|
LGTM too! |
|
@galenlynch very good catch thank you! |
|
We have old spike sorting results, and want to be able to read them and more recent spike sorting results in a consistent environment. |
For extensions whose on-disk
params.jsoncontains metric names that were renamed in 0.104 (e.g.peak_to_valley,velocity_above,l_ratio, …), validation raises aValueErrorbefore the compat handler ever runs, which prevents loading these saved metrics.This is because
_read_old_waveforms_extractor_binaryvalidates before migrating:Two things go wrong before the compat handler gets a chance to run:
_set_paramsrejects deprecated names likepeak_to_valleyorl_ratio.make_ext_params_up_to_datestrips anymetric_paramskeys that don't exist in the new defaults: deprecated sub-params (e.g.velocity_above.min_channels_for_velocity) are silently dropped before the compat handler can migrate them to their new names (e.g.velocity_fits.min_channels).This PR changes the order of operations so the migration handler runs first on the raw on-disk parameters, which are then pruned and validated by
make_ext_params_up_to_dateandset_params, respectively. Running the compat handler on the raw on-disk params first is whatSortingAnalyzeralready does for non-legacy folders, so the change would just makeWaveformExtractorhave the same logical flow.Fixes: #4508