@@ -761,6 +761,10 @@ def load(file_path: Union[str, Path], base_folder: Optional[Union[Path, str, boo
761761 * save (...) a folder which contain data + json (or pickle) + metadata.
762762
763763 """
764+ error_msg = (
765+ f"{ file_path } is not a file or a folder. It should point to either a json, pickle file or a "
766+ "folder that is the result of extractor.save(...)"
767+ )
764768 if not is_path_remote (file_path ):
765769 file_path = Path (file_path )
766770
@@ -776,7 +780,8 @@ def load(file_path: Union[str, Path], base_folder: Optional[Union[Path, str, boo
776780 with open (file_path , "rb" ) as f :
777781 d = pickle .load (f )
778782 else :
779- raise ValueError (f"Impossible to load { file_path } " )
783+ raise ValueError (error_msg )
784+
780785 if "warning" in d :
781786 print ("The extractor was not serializable to file" )
782787 return None
@@ -793,27 +798,22 @@ def load(file_path: Union[str, Path], base_folder: Optional[Union[Path, str, boo
793798
794799 extractor = read_zarr (folder )
795800 else :
796- # the is spikeinterface <=0.94.0
797- # a folder came with 'cached .json'
801+ # For backward compatibility (v <=0.94) we check for the cached.json/pkl/pickle files
802+ # In later versions (v>0.94) we use the si_folder .json file
798803 for dump_ext in ("json" , "pkl" , "pickle" ):
799804 f = folder / f"cached.{ dump_ext } "
800805 if f .is_file ():
801806 file = f
802807
803- # spikeinterface>=0.95.0
804808 f = folder / f"si_folder.json"
805809 if f .is_file ():
806810 file = f
807811
808812 if file is None :
809- raise ValueError (f"This folder is not a cached folder { file_path } " )
813+ raise ValueError (error_msg )
810814 extractor = BaseExtractor .load (file , base_folder = folder )
811815
812816 else :
813- error_msg = (
814- f"{ file_path } is not a file or a folder. It should point to either a json, pickle file or a "
815- "folder that is the result of extractor.save(...)"
816- )
817817 raise ValueError (error_msg )
818818 else :
819819 # remote case - zarr
0 commit comments