MCPcopy
hub / github.com/hpcaitech/ColossalAI / get_parser

Function get_parser

examples/images/diffusion/main.py:42–157  ·  view source on GitHub ↗
(**parser_kwargs)

Source from the content-addressed store, hash-verified

40
41
42def get_parser(**parser_kwargs):
43 # A function to create an ArgumentParser object and add arguments to it
44
45 def str2bool(v):
46 # A helper function to parse boolean values from command line arguments
47 if isinstance(v, bool):
48 return v
49 if v.lower() in ("yes", "true", "t", "y", "1"):
50 return True
51 elif v.lower() in ("no", "false", "f", "n", "0"):
52 return False
53 else:
54 raise argparse.ArgumentTypeError("Boolean value expected.")
55
56 # Create an ArgumentParser object with specifies kwargs
57 parser = argparse.ArgumentParser(**parser_kwargs)
58
59 # Add various command line arguments with their default values and descriptions
60 parser.add_argument(
61 "-n",
62 "--name",
63 type=str,
64 const=True,
65 default="",
66 nargs="?",
67 help="postfix for logdir",
68 )
69 parser.add_argument(
70 "-r",
71 "--resume",
72 type=str,
73 const=True,
74 default="",
75 nargs="?",
76 help="resume from logdir or checkpoint in logdir",
77 )
78 parser.add_argument(
79 "-b",
80 "--base",
81 nargs="*",
82 metavar="base_config.yaml",
83 help="paths to base configs. Loaded from left-to-right. "
84 "Parameters can be overwritten or added with command-line options of the form `--key value`.",
85 default=list(),
86 )
87 parser.add_argument(
88 "-t",
89 "--train",
90 type=str2bool,
91 const=True,
92 default=False,
93 nargs="?",
94 help="train",
95 )
96 parser.add_argument(
97 "--no-test",
98 type=str2bool,
99 const=True,

Callers 1

main.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…