Skip to content

Commit

Permalink
fix jsonl writer (#2860)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jintao-Huang authored Jan 4, 2025
1 parent 581a404 commit 980a93a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions swift/utils/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ def append(self, obj: Union[Dict, List[Dict]]):
else:
obj_list = [obj]
obj_list = check_json_format(obj_list)
for _obj in obj_list:
self._cache_text += f'{json.dumps(_obj, ensure_ascii=False)}\n'
for i, _obj in enumerate(obj_list):
obj_list[i] = json.dumps(_obj, ensure_ascii=False) + '\n'
self._cache_text = ''.join(obj_list)

if len(self._cache_text) >= self.buffer_size:
self._write_buffer()
Expand Down

0 comments on commit 980a93a

Please sign in to comment.