MCPcopy Index your code
hub / github.com/modelscope/modelscope / check_config

Function check_config

modelscope/utils/config.py:694–717  ·  view source on GitHub ↗

Check whether configuration file is valid, If anything wrong, exception will be raised. Args: cfg (str or ConfigDict): Config file path or config object. is_training: indicate if checking training related elements

(cfg: Union[str, ConfigDict], is_training=False)

Source from the content-addressed store, hash-verified

692
693
694def check_config(cfg: Union[str, ConfigDict], is_training=False):
695 """ Check whether configuration file is valid, If anything wrong, exception will be raised.
696
697 Args:
698 cfg (str or ConfigDict): Config file path or config object.
699 is_training: indicate if checking training related elements
700 """
701
702 if isinstance(cfg, str):
703 cfg = Config.from_file(cfg)
704
705 def check_attr(attr_name, msg=''):
706 assert hasattr(cfg, attr_name), f'Attribute {attr_name} is missing from ' \
707 f'{ModelFile.CONFIGURATION}. {msg}'
708
709 check_attr(ConfigFields.framework)
710 check_attr(ConfigFields.task)
711 check_attr(ConfigFields.pipeline)
712
713 if is_training:
714 check_attr(ConfigFields.model)
715 check_attr(ConfigFields.train)
716 check_attr(ConfigFields.preprocessor)
717 check_attr(ConfigFields.evaluation)
718
719
720class JSONIteratorEncoder(json.JSONEncoder):

Callers 2

pipelineFunction · 0.90
test_check_configMethod · 0.90

Calls 2

from_fileMethod · 0.80
check_attrFunction · 0.70

Tested by 1

test_check_configMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…