MCPcopy Index your code
hub / github.com/tensorflow/datasets / write

Method write

tensorflow_datasets/core/writer.py:367–378  ·  view source on GitHub ↗

Writes given example. The given example is not directly written to the shard, but to a temporary file (or memory). The finalize() method writes all the shards. Args: key (int|bytes): the key associated with the example. Used for shuffling. example: the Example to write to t

(self, key: int | bytes, example: Example)

Source from the content-addressed store, hash-verified

365 self._example_writer = example_writer
366
367 def write(self, key: int | bytes, example: Example):
368 """Writes given example.
369
370 The given example is not directly written to the shard, but to a
371 temporary file (or memory). The finalize() method writes all the shards.
372
373 Args:
374 key (int|bytes): the key associated with the example. Used for shuffling.
375 example: the Example to write to the shard.
376 """
377 serialized_example = self._serializer.serialize_example(example=example)
378 self._shuffler.add(key, serialized_example)
379
380 def finalize(self) -> tuple[list[int], int]:
381 """Effectively writes examples to the shards."""

Callers 15

_writeMethod · 0.95
_build_from_generatorMethod · 0.95
write_examplesMethod · 0.45
write_examplesMethod · 0.45
writeMethod · 0.45
finalizeMethod · 0.45
_write_final_shardMethod · 0.45
add_exampleMethod · 0.45
addMethod · 0.45
rewrite_zipFunction · 0.45

Calls 2

serialize_exampleMethod · 0.45
addMethod · 0.45

Tested by 5

_writeMethod · 0.76
check_outputFunction · 0.36
test_mock_fsFunction · 0.36
test_mock_fs_gcsFunction · 0.36
test_get_art_absMethod · 0.36