Visitar URL original
Fix failing local Windows tests due to ruamel parsing (#3275) · DeepLabCut/DeepLabCut@45fe7ce · GitHub
Skip to content

Commit 45fe7ce

Browse files
authored
Fix failing local Windows tests due to ruamel parsing (#3275)
Update multianimal project fixture to produce stable YAML: import ruamel.yaml.scalarstring.SingleQuotedScalarString and use it for the video_sets key (posix path), set yaml width to avoid unwanted wrapping, and use project_dir.as_posix() for project_path. Also write config.yaml with explicit UTF-8 encoding and ensure crop is a string. These changes make YAML dumping deterministic and platform-independent for the test.
1 parent ca8124e commit 45fe7ce

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎tests/pose_estimation_pytorch/apis/test_apis_export.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import pytest
1919
import torch
20+
from ruamel.yaml.scalarstring import SingleQuotedScalarString as SQS
2021

2122
import deeplabcut.pose_estimation_pytorch.apis.export as export
2223
import deeplabcut.utils.auxiliaryfunctions as af
@@ -39,16 +40,18 @@ def _mock_multianimal_project(project_dir: Path):
3940
video_dir.mkdir(exist_ok=True)
4041

4142
cfg_file, yaml_file = af.create_config_template(multianimal=True)
43+
yaml_file.width = 10_000
44+
4245
cfg_file["Task"] = "mock"
4346
cfg_file["scorer"] = "mock"
44-
cfg_file["video_sets"] = {str(video_dir / "vid.mp4"): dict(crop="0, 640, 0, 480")}
45-
cfg_file["project_path"] = str(project_dir)
47+
cfg_file["video_sets"] = {SQS((video_dir / "vid.mp4").as_posix()): {"crop": "0, 640, 0, 480"}}
48+
cfg_file["project_path"] = project_dir.as_posix()
4649
cfg_file["individuals"] = ["a", "b"]
4750
cfg_file["uniquebodyparts"] = []
4851
cfg_file["multianimalbodyparts"] = ["k1", "k2", "k3"]
4952
cfg_file["bodyparts"] = "MULTI!"
5053

51-
with open(project_dir / "config.yaml", "w") as f:
54+
with open(project_dir / "config.yaml", "w", encoding="utf-8") as f:
5255
yaml_file.dump(cfg_file, f)
5356

5457

0 commit comments

Comments
 (0)