Skip to content

Commit aeb3425

Browse files
tomvdwThe TensorFlow Datasets Authors
authored andcommitted
Add more information to the progress bars in convert_format
PiperOrigin-RevId: 675475792
1 parent bfe289a commit aeb3425

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tensorflow_datasets/scripts/cli/convert_format_utils.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,14 @@ class ShardInstruction:
6161

6262
def convert(self) -> None:
6363
"""Converts the shard to the desired file format."""
64+
6465
def read_in() -> Iterator[type_utils.KeySerializedExample]:
6566
in_dataset = self.in_file_adapter.make_tf_data(filename=self.in_path)
66-
for i, row in tqdm.tqdm(enumerate(in_dataset)):
67+
for i, row in tqdm.tqdm(
68+
enumerate(in_dataset),
69+
unit=' examples',
70+
desc=f'Shard {self.in_path.name}',
71+
):
6772
if self.convert_fn is not None:
6873
yield i, self.convert_fn(row)
6974
else:
@@ -258,7 +263,11 @@ def _convert_dataset(
258263
)
259264

260265
else:
261-
for shard_instruction in shard_instructions:
266+
for shard_instruction in tqdm.tqdm(
267+
shard_instructions,
268+
unit=' shards',
269+
desc=f'Shards in {os.fspath(dataset_dir)}',
270+
):
262271
shard_instruction.convert()
263272

264273

@@ -357,7 +366,9 @@ def _convert_dataset_dirs(
357366
out_dir=out_dir,
358367
)
359368
else:
360-
for dataset_dir, info in found_dataset_versions.items():
369+
for dataset_dir, info in tqdm.tqdm(
370+
found_dataset_versions.items(), unit=' datasets'
371+
):
361372
out_dir = from_to_dirs[dataset_dir]
362373
convert_dataset_fn(
363374
info=info,
@@ -366,7 +377,9 @@ def _convert_dataset_dirs(
366377
)
367378

368379
logging.info('All shards have been converted. Now converting metadata.')
369-
for dataset_dir, info in tqdm.tqdm(found_dataset_versions.items()):
380+
for dataset_dir, info in tqdm.tqdm(
381+
found_dataset_versions.items(), unit=' datasets'
382+
):
370383
out_dir = from_to_dirs[dataset_dir]
371384
logging.info('Converting metadata in %s.', dataset_dir)
372385
convert_metadata(

0 commit comments

Comments
 (0)