MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / dump_by_pickle

Method dump_by_pickle

detrsmpl/data/data_structures/human_data.py:1085–1116  ·  view source on GitHub ↗

Dump keys and items to a pickle file. It's a secondary dump method, when a HumanData instance is too large to be dumped by self.dump() Args: pkl_path (str): Path to a dumped pickle file. overwrite (bool, optional): Whether to o

(self, pkl_path: str, overwrite: bool = True)

Source from the content-addressed store, hash-verified

1083 self.__keypoints_compressed__ = False
1084
1085 def dump_by_pickle(self, pkl_path: str, overwrite: bool = True) -> None:
1086 """Dump keys and items to a pickle file. It's a secondary dump method,
1087 when a HumanData instance is too large to be dumped by self.dump()
1088
1089 Args:
1090 pkl_path (str):
1091 Path to a dumped pickle file.
1092 overwrite (bool, optional):
1093 Whether to overwrite if there is already a file.
1094 Defaults to True.
1095
1096 Raises:
1097 ValueError:
1098 npz_path does not end with '.pkl'.
1099 FileExistsError:
1100 When overwrite is False and file exists.
1101 """
1102 if not check_path_suffix(pkl_path, ['.pkl']):
1103 raise ValueError('Not an pkl file.')
1104 if not overwrite:
1105 if check_path_existence(pkl_path, 'file') == Existence.FileExist:
1106 raise FileExistsError
1107 dict_to_dump = {
1108 '__key_strict__': self.__key_strict__,
1109 '__data_len__': self.__data_len__,
1110 '__keypoints_compressed__': self.__keypoints_compressed__,
1111 }
1112 dict_to_dump.update(self)
1113 with open(pkl_path, 'wb') as f_writeb:
1114 pickle.dump(dict_to_dump,
1115 f_writeb,
1116 protocol=pickle.HIGHEST_PROTOCOL)
1117
1118 def load_by_pickle(self, pkl_path: str) -> None:
1119 """Load data from pkl_path and update them to self.

Callers

nothing calls this directly

Calls 4

check_path_suffixFunction · 0.90
check_path_existenceFunction · 0.90
updateMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected