Skip to content

Commit 73f926a

Browse files
fineguyThe TensorFlow Datasets Authors
authored andcommitted
Add a dry_run flag to the TFDS CLI.
PiperOrigin-RevId: 670516954
1 parent e4c4eb4 commit 73f926a

File tree

1 file changed

+10
-2
lines changed
  • tensorflow_datasets/scripts/cli

1 file changed

+10
-2
lines changed

tensorflow_datasets/scripts/cli/main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def _parse_flags(argv: List[str]) -> argparse.Namespace:
5555
action='version',
5656
version='TensorFlow Datasets: ' + tfds.__version__,
5757
)
58+
parser.add_argument(
59+
'--dry_run',
60+
action='store_true',
61+
help='If True, print the parsed arguments.',
62+
)
5863
parser.set_defaults(subparser_fn=lambda _: parser.print_help())
5964
# Register sub-commands
6065
subparser = parser.add_subparsers(title='command')
@@ -96,8 +101,11 @@ def main(args: argparse.Namespace) -> None:
96101
new_stream = tfds.core.utils.tqdm_utils.TqdmStream()
97102
python_handler.setStream(new_stream)
98103

99-
# Launch the subcommand defined in the subparser (or default to print help)
100-
args.subparser_fn(args)
104+
if args.dry_run:
105+
print(args)
106+
else:
107+
# Launch the subcommand defined in the subparser (or default to print help)
108+
args.subparser_fn(args)
101109

102110

103111
def launch_cli() -> None:

0 commit comments

Comments
 (0)