MCPcopy
hub / github.com/huggingface/datasets / finalize

Method finalize

src/datasets/arrow_writer.py:780–799  ·  view source on GitHub ↗
(self, close_stream=True)

Source from the content-addressed store, hash-verified

778 self.pa_writer.write_table(pa_table, writer_batch_size)
779
780 def finalize(self, close_stream=True):
781 self.write_rows_on_file()
782 # In case current_examples < writer_batch_size, but user uses finalize()
783 self.write_examples_on_file()
784 # If schema is known, infer features even if no examples were written
785 if self.pa_writer is None and self.schema:
786 self._build_writer(self.schema)
787 if self.pa_writer is not None:
788 self.pa_writer.close()
789 self.pa_writer = None
790 if close_stream:
791 self.stream.close()
792 else:
793 if close_stream:
794 self.stream.close()
795 raise SchemaInferenceError("Please pass `features` or at least one example when writing data")
796 logger.debug(
797 f"Done writing {self._num_examples} {self.unit} in {self._num_bytes} bytes {self._path if self._path else ''}."
798 )
799 return self._num_examples, self._num_bytes
800
801
802class ParquetWriter(ArrowWriter):

Callers 15

_save_to_disk_singleMethod · 0.95
_map_singleMethod · 0.95
_prepare_split_singleMethod · 0.80
_prepare_split_singleMethod · 0.80
__init__Method · 0.80
write_arrowMethod · 0.80
data_dir_with_arrowFunction · 0.80
test_writeFunction · 0.80
test_write_with_featuresFunction · 0.80
test_write_with_keysFunction · 0.80
test_write_batchFunction · 0.80

Calls 5

write_rows_on_fileMethod · 0.95
_build_writerMethod · 0.95
closeMethod · 0.80

Tested by 15

data_dir_with_arrowFunction · 0.64
test_writeFunction · 0.64
test_write_with_featuresFunction · 0.64
test_write_with_keysFunction · 0.64
test_write_batchFunction · 0.64
test_write_tableFunction · 0.64
test_write_rowFunction · 0.64
test_write_fileFunction · 0.64