MCPcopy Create free account
hub / github.com/apple/axlearn / _parse

Function _parse

axlearn/cli/utils_test.py:17–35  ·  view source on GitHub ↗
(argv: list[str])

Source from the content-addressed store, hash-verified

15
16
17def _parse(argv: list[str]) -> argparse_flags.argparse.Namespace:
18 kwargs = dict(inherited_absl_flags=FlagValues())
19 root = CommandGroup("root", argv=argv, **kwargs)
20 root.add_flag("--root", undefok=True, action="store_true")
21 root.add_flag("--root_default", undefok=True, default="some_value")
22
23 child1 = CommandGroup("child1", parent=root, **kwargs)
24 child1.add_flag("--child1", undefok=True, action="store_true")
25 grandchild1 = CommandGroup("grandchild1", parent=child1, **kwargs)
26 grandchild1.add_cmd_from_module("command1", module="axlearn.cli.testdata.dummy", **kwargs)
27 grandchild1.add_cmd_from_module(
28 "command2", module="axlearn.cli.testdata.dummy", filter_argv="undefok|.*default", **kwargs
29 )
30
31 child2 = CommandGroup("child2", parent=root, **kwargs)
32 # All leaf commands must support --child2.
33 child2.add_flag("--child2", undefok=False, action="store_true", required=True)
34 child2.add_cmd_from_module("command2", module="axlearn.cli.testdata.dummy", **kwargs)
35 return root.parse_known_args()
36
37
38def _run(args: argparse_flags.argparse.Namespace) -> tuple[int, str, str]:

Callers 8

test_basicMethod · 0.85
test_helpMethod · 0.85
test_invoke_basicMethod · 0.85
test_invoke_requiredMethod · 0.85
test_invoke_unknownMethod · 0.85
test_invoke_undefokMethod · 0.85
test_invoke_defaultMethod · 0.85
test_filter_argvMethod · 0.85

Calls 4

add_flagMethod · 0.95
add_cmd_from_moduleMethod · 0.95
parse_known_argsMethod · 0.95
CommandGroupClass · 0.90

Tested by

no test coverage detected