MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / read_config

Function read_config

deeplabcut/utils/auxiliaryfunctions.py:203–240  ·  view source on GitHub ↗

Reads structured config file defining a project.

(configname)

Source from the content-addressed store, hash-verified

201
202
203def read_config(configname):
204 """Reads structured config file defining a project."""
205 ruamelFile = YAML()
206 path = Path(configname)
207 if os.path.exists(path):
208 try:
209 with open(path) as f:
210 cfg = ruamelFile.load(f)
211 curr_dir = str(Path(configname).parent.resolve())
212
213 if cfg.get("engine") is None:
214 cfg["engine"] = Engine.TF.aliases[0]
215 write_config(configname, cfg)
216
217 if cfg.get("detector_snapshotindex") is None:
218 cfg["detector_snapshotindex"] = -1
219
220 if cfg.get("detector_batch_size") is None:
221 cfg["detector_batch_size"] = 1
222
223 if cfg["project_path"] != curr_dir:
224 cfg["project_path"] = curr_dir
225 write_config(configname, cfg)
226 except Exception as err:
227 if len(err.args) > 2:
228 if err.args[2] == "could not determine a constructor for the tag '!!python/tuple'":
229 with open(path) as ymlfile:
230 cfg = yaml.load(ymlfile, Loader=yaml.SafeLoader)
231 write_config(configname, cfg)
232 else:
233 raise
234
235 else:
236 raise FileNotFoundError(
237 f"Config file at {path} not found. Please make sure that the file exists and/or that you passed the path of"
238 f"the config file correctly!"
239 )
240 return cfg
241
242
243def write_config(configname, cfg):

Callers 6

create_conversion_tableFunction · 0.90
get_conversion_tableFunction · 0.90
extract_save_all_mapsFunction · 0.90
__init__Method · 0.90

Calls 3

loadMethod · 0.80
write_configFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected