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

Method dump

detrsmpl/data/data_structures/human_data.py:268–295  ·  view source on GitHub ↗

Dump keys and items to an npz file. Args: npz_path (str): Path to a dumped npz file. overwrite (bool, optional): Whether to overwrite if there is already a file. Defaults to True. Raises: ValueError

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

Source from the content-addressed store, hash-verified

266 self.__set_default_values__()
267
268 def dump(self, npz_path: str, overwrite: bool = True):
269 """Dump keys and items to an npz file.
270
271 Args:
272 npz_path (str):
273 Path to a dumped npz file.
274 overwrite (bool, optional):
275 Whether to overwrite if there is already a file.
276 Defaults to True.
277
278 Raises:
279 ValueError:
280 npz_path does not end with '.npz'.
281 FileExistsError:
282 When overwrite is False and file exists.
283 """
284 if not check_path_suffix(npz_path, ['.npz']):
285 raise ValueError('Not an npz file.')
286 if not overwrite:
287 if check_path_existence(npz_path, 'file') == Existence.FileExist:
288 raise FileExistsError
289 dict_to_dump = {
290 '__key_strict__': self.__key_strict__,
291 '__data_len__': self.__data_len__,
292 '__keypoints_compressed__': self.__keypoints_compressed__,
293 }
294 dict_to_dump.update(self)
295 np.savez_compressed(npz_path, **dict_to_dump)
296
297 def get_sliced_cache(self, slice_size=10) -> List:
298 """Slice the whole HumanData into pieces for HumanDataCacheWriter.

Callers 10

evaluateMethod · 0.45
evaluateMethod · 0.45
dump_by_pickleMethod · 0.45
collect_results_cpuFunction · 0.45
inferenceMethod · 0.45
inferenceMethod · 0.45
inferenceMethod · 0.45

Calls 3

check_path_suffixFunction · 0.90
check_path_existenceFunction · 0.90
updateMethod · 0.45

Tested by 1

collect_results_cpuFunction · 0.36