(self, text: str)
| 82 | self._append(obj, gather_obj=gather_obj) |
| 83 | |
| 84 | def _write_buffer(self, text: str): |
| 85 | if not text: |
| 86 | return |
| 87 | assert self.is_write_rank, f'self.is_write_rank: {self.is_write_rank}' |
| 88 | try: |
| 89 | os.makedirs(os.path.dirname(self.fpath), exist_ok=True) |
| 90 | with open(self.fpath, 'a', encoding=self.encoding) as f: |
| 91 | f.write(text) |
| 92 | except Exception: |
| 93 | if self.strict: |
| 94 | raise |
| 95 | logger.error(f'Cannot write content to jsonl file. text: {text}') |
| 96 | |
| 97 | |
| 98 | def append_to_jsonl(fpath: str, |