File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020
2121_ENCODER_FILE_SUFFIX = ".encoder"
2222_ENCODER_FILE_FORMAT_VERSION = 1
23+ _ENCODER_FILE_FORMAT_VERSION_COMPATIBILITY : dict [tuple [int , int ], bool ] = {
24+ # TODO: when the next _ENCODER_FILE_FORMAT_VERSION comes, check if
25+ # it's forward / backward compatible, then add entries like:
26+ # (1, 2): True, # version 1 can read files from version 2
27+ #
28+ # However, (2, 1) might not be True!!
29+ }
2330_ENCODER_STATE_KEYS = frozenset (
2431 {
2532 "encoder_class" ,
@@ -530,6 +537,8 @@ def load_from_disk(
530537 state = joblib .load (path )
531538 if not isinstance (state , dict ) or not _ENCODER_STATE_KEYS .issubset (state ):
532539 raise ValueError (f"File { path } is not a valid .encoder file." )
540+ # TODO: in the future, verify format version by checking
541+ # compatibility via _ENCODER_FILE_FORMAT_VERSION_COMPATIBILITY
533542 if state ["encoder_class" ] != cls .__name__ :
534543 raise ValueError (
535544 f"File { path } was saved by { state ['encoder_class' ]} . "
You can’t perform that action at this time.
0 commit comments