MCPcopy Create free account
hub / github.com/THUDM/GLM / save_json_stream

Method save_json_stream

data_utils/datasets.py:470–481  ·  view source on GitHub ↗
(self, save_path, json_stream)

Source from the content-addressed store, hash-verified

468 self.save_json_stream(path, out_stream())
469
470 def save_json_stream(self, save_path, json_stream):
471 if self.loose_json:
472 with open(save_path, 'w') as f:
473 for i, j in enumerate(json_stream):
474 write_string = ''
475 if i != 0:
476 write_string = '\n'
477 write_string += json.dumps(j)
478 f.write(write_string)
479 else:
480 jsons = [j for j in json_stream]
481 json.dump(jsons, open(save_path, 'w'), separators=(',', ':'))
482
483 def load_json_stream(self, load_path):
484 if not self.loose_json:

Callers 1

writeMethod · 0.95

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected