Skip to content

Commit d6db325

Browse files
committed
Make version mismatch warning actionable
The old warning told users to downgrade, which is unhelpful when they upgraded intentionally. The new message states both the saved and current versions and tells the user to re-save the object to update it. Closes #4495
1 parent 89381fe commit d6db325

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/spikeinterface/core/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,11 +1144,14 @@ def _load_extractor_from_dict(dic) -> "BaseExtractor":
11441144
extractor_class = _get_class_from_string(class_name)
11451145

11461146
assert extractor_class is not None and class_name is not None, "Could not load spikeinterface class"
1147-
is_old_version = not _check_same_version(class_name, dic["version"])
1147+
module_name = class_name.split(".")[0]
1148+
current_version = importlib.import_module(module_name).__version__
1149+
saved_version = dic["version"]
1150+
is_old_version = not _check_same_version(class_name, saved_version)
11481151
if is_old_version:
11491152
warnings.warn(
1150-
f"Versions are not the same. This might lead to compatibility errors. "
1151-
f"Using {class_name.split('.')[0]}=={dic['version']} is recommended"
1153+
f"This object was saved with {module_name}=={saved_version} and you are running {module_name}=={current_version}. "
1154+
f"To update the saved version, re-save the object with `save()` or `save_to_folder()`/`save_to_zarr()`."
11521155
)
11531156

11541157
if hasattr(extractor_class, "_handle_backward_compatibility"):

0 commit comments

Comments
 (0)