Visitar URL original
Fix ruamel.yaml dumping issue causing YAML corruption for long video … · deruyter92/DeepLabCut@3ec4180 · GitHub
Skip to content

Commit 3ec4180

Browse files
deruyter92Copilot
andcommitted
Fix ruamel.yaml dumping issue causing YAML corruption for long video paths
ruamel.yaml was inserting unintended newlines when dumping paths, leading to corrupted YAML files for long video paths containing spaces. Fixes DeepLabCut#3119 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d6c0bb4 commit 3ec4180

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎deeplabcut/utils/auxiliaryfunctions.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ def write_config(configname, cfg):
256256
if not "skeleton" in cfg.keys():
257257
cfg_file["skeleton"] = []
258258
cfg_file["skeleton_color"] = "black"
259+
# Use a very large width so long strings (e.g., file paths or keys with spaces)
260+
# are kept on a single line instead of being wrapped, which can otherwise cause
261+
# them to be emitted as complex keys. See also:
262+
# https://stackoverflow.com/questions/31197268/pyyaml-yaml-dump-produces-complex-key-for-string-key-122-chars/31199123#31199123
263+
ruamelFile.width = 1_000_000
259264
ruamelFile.dump(cfg_file, cf)
260265

261266

0 commit comments

Comments
 (0)