MCPcopy
hub / github.com/microsoft/qlib / parse_config

Function parse_config

qlib/utils/__init__.py:242–255  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

240
241#################### Parse ####################
242def parse_config(config):
243 # Check whether need parse, all object except str do not need to be parsed
244 if not isinstance(config, str):
245 return config
246 # Check whether config is file
247 yaml = YAML(typ="safe", pure=True)
248 if os.path.exists(config):
249 with open(config, "r") as f:
250 return yaml.load(f)
251 # Check whether the str can be parsed
252 try:
253 return yaml.load(config)
254 except BaseException as base_exp:
255 raise ValueError("cannot parse config!") from base_exp
256
257
258#################### Other ####################

Callers

nothing calls this directly

Calls 2

existsMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected