MCPcopy
hub / github.com/PaddlePaddle/ERNIE / get_config

Function get_config

data_processor/utils/argparser.py:409–451  ·  view source on GitHub ↗

Get configuration, which can be specified via a configuration file path or passed through command-line arguments. Args: config_path (str, optional): Path to the configuration file. Default is None. If not specified, the configuration file path must be provided via comma

(config_path=None, **kwargs)

Source from the content-addressed store, hash-verified

407
408
409def get_config(config_path=None, **kwargs):
410 """
411 Get configuration, which can be specified via a configuration file path or passed through command-line arguments.
412
413 Args:
414 config_path (str, optional): Path to the configuration file. Default is None.
415 If not specified, the configuration file path must be provided via command-line arguments.
416 kwargs (dict, optional):
417 Additional configuration fields in the format key=value.
418 Default is an empty dictionary.
419
420 Returns:
421 dict: A dictionary containing the merged configuration information
422 from both the configuration file and the additional fields.
423
424 Raises:
425 None.
426 """
427 if config_path is None:
428 parser = argparse.ArgumentParser()
429 parser.add_argument(
430 "--configs",
431 action="store",
432 nargs="+",
433 required=True,
434 help="Configuration file path",
435 )
436 parser.add_argument(
437 "--kwargs",
438 action="store",
439 nargs="+",
440 default=[],
441 help="Additional configuration fields in the format key=value",
442 )
443 opt = parser.parse_args()
444 configs = [OmegaConf.load(p) for p in opt.configs]
445 configs.append(OmegaConf.from_dotlist(opt.kwargs))
446 config = OmegaConf.merge(*configs)
447 else:
448 extra_processor_config = {"processor_args": kwargs}
449 configs = [OmegaConf.load(config_path), extra_processor_config]
450 config = OmegaConf.merge(*configs)
451 return config

Callers 1

_init_mm_modelMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected