File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 77import weakref
88import json
99import pickle
10- import os
1110import random
1211import string
1312from packaging .version import parse
@@ -951,13 +950,14 @@ def save_to_folder(
951950 folder .mkdir (parents = True , exist_ok = False )
952951
953952 # dump provenance
954- provenance_file = folder / f"provenance.json"
955953 if self .check_serializability ("json" ):
954+ provenance_file = folder / f"provenance.json"
955+ self .dump (provenance_file )
956+ elif self .check_serializability ("pickle" ):
957+ provenance_file = folder / f"provenance.pkl"
956958 self .dump (provenance_file )
957959 else :
958- provenance_file .write_text (
959- json .dumps ({"warning" : "the provenace is not json serializable!!!" }), encoding = "utf8"
960- )
960+ warnings .warn ("The extractor is not serializable to file. The provenance will not be saved." )
961961
962962 self .save_metadata_to_folder (folder )
963963
@@ -1024,7 +1024,6 @@ def save_to_zarr(
10241024 cached: ZarrExtractor
10251025 Saved copy of the extractor.
10261026 """
1027- import zarr
10281027 from .zarrextractors import read_zarr
10291028
10301029 save_kwargs .pop ("format" , None )
Original file line number Diff line number Diff line change @@ -1803,6 +1803,8 @@ def __init__(
18031803 )
18041804 self .add_recording_segment (recording_segment )
18051805
1806+ # to discuss: maybe we could set json serializability to False always
1807+ # because templates could be large!
18061808 if not sorting .check_serializability ("json" ):
18071809 self ._serializability ["json" ] = False
18081810 if parent_recording is not None :
Original file line number Diff line number Diff line change @@ -458,6 +458,9 @@ def __init__(
458458
459459 self .set_probe (drifting_templates .probe , in_place = True )
460460
461+ # templates are too large, we don't serialize them to JSON
462+ self ._serializability ["json" ] = False
463+
461464 self ._kwargs = {
462465 "sorting" : sorting ,
463466 "drifting_templates" : drifting_templates ,
You can’t perform that action at this time.
0 commit comments