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

Method parse_dict

data_processor/utils/argparser.py:395–406  ·  view source on GitHub ↗

Alternative helper method that does not use `argparse` at all, instead uses a dict and populating the dataclass types.

(self, args: dict)

Source from the content-addressed store, hash-verified

393 return self.common_parse(args, return_remaining_strings)
394
395 def parse_dict(self, args: dict) -> Tuple[DataClass, ...]:
396 """
397 Alternative helper method that does not use `argparse` at all, instead uses a dict and populating the dataclass
398 types.
399 """
400 outputs = []
401 for dtype in self.dataclass_types:
402 keys = {f.name for f in dataclasses.fields(dtype) if f.init}
403 inputs = {k: v for k, v in args.items() if k in keys}
404 obj = dtype(**inputs)
405 outputs.append(obj)
406 return (*outputs,)
407
408
409def get_config(config_path=None, **kwargs):

Callers 3

_init_mm_modelMethod · 0.95
mainFunction · 0.95
_parse_argsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected