File tree Expand file tree Collapse file tree 5 files changed +8
-19
lines changed
tensorflow_datasets/scripts Expand file tree Collapse file tree 5 files changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def mock_cwd(path: epath.PathLike) -> Iterator[None]:
83
83
def _build (cmd_flags : str , mock_download_and_prepare : bool = True ) -> List [str ]:
84
84
"""Executes `tfds build {cmd_flags}` and returns the list of generated ds."""
85
85
# Execute the command
86
- args = main .parse_flags (f'tfds build { cmd_flags } ' .split ())
86
+ args = main ._parse_flags (f'tfds build { cmd_flags } ' .split ())
87
87
88
88
original_dl_and_prepare = tfds .core .DatasetBuilder .download_and_prepare
89
89
@@ -325,7 +325,7 @@ def test_download_only():
325
325
),
326
326
)
327
327
def test_make_download_config (args : str , download_config_kwargs ):
328
- args = main .parse_flags (f'tfds build x { download_config_kwargs } ' .split ())
328
+ args = main ._parse_flags (f'tfds build x { download_config_kwargs } ' .split ())
329
329
actual = build_lib ._make_download_config (args , dataset_name = 'x' )
330
330
# Ignore the beam runner
331
331
actual .replace (beam_runner = None )
Original file line number Diff line number Diff line change 42
42
FLAGS = flags .FLAGS
43
43
44
44
45
- def parse_flags (argv : List [str ]) -> argparse .Namespace :
45
+ def _parse_flags (argv : List [str ]) -> argparse .Namespace :
46
46
"""Command lines flag parsing."""
47
47
argv = flag_utils .normalize_flags (argv ) # See b/174043007 for context.
48
48
@@ -102,7 +102,7 @@ def main(args: argparse.Namespace) -> None:
102
102
103
103
def launch_cli () -> None :
104
104
"""Parse arguments and launch the CLI main function."""
105
- app .run (main , flags_parser = parse_flags )
105
+ app .run (main , flags_parser = _parse_flags )
106
106
107
107
108
108
if __name__ == '__main__' :
Original file line number Diff line number Diff line change @@ -28,4 +28,4 @@ def _check_exit(status=0, message=None):
28
28
# Argparse call `sys.exit(0)` when `--version` is passed.
29
29
with mock .patch ('sys.exit' , _check_exit ):
30
30
version_flag = '--version'
31
- main .main (main .parse_flags (['' , version_flag ]))
31
+ main .main (main ._parse_flags (['' , version_flag ]))
Original file line number Diff line number Diff line change 23
23
24
24
25
25
def _run_cli (cmd : str ) -> None :
26
- main .main (main .parse_flags (['' ] + cmd .split ()))
26
+ main .main (main ._parse_flags (['' ] + cmd .split ()))
27
27
28
28
29
29
def test_new_without_args (capsys ):
Original file line number Diff line number Diff line change 13
13
# See the License for the specific language governing permissions and
14
14
# limitations under the License.
15
15
16
- r"""Wrapper around `tfds build` and `tfds build_croissant` ."""
16
+ r"""Wrapper around `tfds build`."""
17
17
18
18
import argparse
19
19
from typing import List
35
35
36
36
def _parse_flags (argv : List [str ]) -> argparse .Namespace :
37
37
"""Command lines flag parsing."""
38
- parser = argparse .ArgumentParser (
39
- description = 'Runs either `tfds build` or `tfds build_croissant`.'
40
- )
41
- parser .add_argument ('--croissant' , action = 'store_true' )
42
- args , other_argv = parser .parse_known_args (argv )
43
-
44
- if args .croissant :
45
- build_cmd = 'build_croissant'
46
- else :
47
- build_cmd = 'build'
48
-
49
- return main_cli .parse_flags ([other_argv [0 ], build_cmd ] + other_argv [1 :])
38
+ return main_cli ._parse_flags ([argv [0 ], 'build' ] + argv [1 :]) # pylint: disable=protected-access
50
39
51
40
52
41
_display_warning = True
You can’t perform that action at this time.
0 commit comments