Skip to content

Commit

Permalink
update yaml safe loading
Browse files Browse the repository at this point in the history
  • Loading branch information
sidhulyalkar committed Dec 6, 2023
1 parent 556556b commit 7c8ccdd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions element_deeplabcut/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import cv2
import csv
import yaml
from ruamel.yaml import YAML
import inspect
import importlib
import numpy as np
Expand Down Expand Up @@ -239,8 +239,9 @@ def extract_new_body_parts(cls, dlc_config: dict, verbose: bool = True):
".yaml",
), f"dlc_config is neither dict nor filepath\n Check: {dlc_config_fp}"
if dlc_config_fp.suffix in (".yml", ".yaml"):
yaml = YAML(typ="safe", pure=True)
with open(dlc_config_fp, "rb") as f:
dlc_config = yaml.safe_load(f)
dlc_config = yaml.load(f)
# -- Check and insert new BodyPart --
assert "bodyparts" in dlc_config, f"Found no bodyparts section in {dlc_config}"
tracked_body_parts = cls.fetch("body_part")
Expand Down Expand Up @@ -381,8 +382,9 @@ def insert_new_model(
"dlc_config is not a filepath" + f"\n Check: {dlc_config_fp}"
)
if dlc_config_fp.suffix in (".yml", ".yaml"):
yaml = YAML(typ="safe", pure=True)
with open(dlc_config_fp, "rb") as f:
dlc_config = yaml.safe_load(f)
dlc_config = yaml.load(f)
if isinstance(params, dict):
dlc_config.update(params)

Expand Down

0 comments on commit 7c8ccdd

Please sign in to comment.