MCPcopy Create free account
hub / github.com/cvg/megaflow / parse_args

Function parse_args

config/parser.py:26–46  ·  view source on GitHub ↗

Parse command line arguments and merge them with JSON configuration. This function first parses command line arguments, then loads configuration from a JSON file specified by the 'cfg' argument, and finally merges both configurations with command line arguments taking precedence. P

(parser: argparse.ArgumentParser)

Source from the content-addressed store, hash-verified

24
25
26def parse_args(parser: argparse.ArgumentParser) -> argparse.Namespace:
27 """Parse command line arguments and merge them with JSON configuration.
28
29 This function first parses command line arguments, then loads configuration
30 from a JSON file specified by the 'cfg' argument, and finally merges both
31 configurations with command line arguments taking precedence.
32
33 Parameters
34 ----------
35 parser : argparse.ArgumentParser
36 Argument parser instance with defined arguments.
37
38 Returns
39 -------
40 argparse.Namespace
41 Merged configuration from both command line and JSON file.
42 """
43 entry = parser.parse_args()
44 args = json_to_args(entry.cfg)
45 args.__dict__.update(vars(entry))
46 return args

Callers 3

train_mf.pyFile · 0.90
train_track.pyFile · 0.90
evaluate.pyFile · 0.90

Calls 1

json_to_argsFunction · 0.85

Tested by

no test coverage detected