from pathlib import Path

import yaml


def update_data_yml_path():
    root_dir = Path(__file__).parent.absolute()
    images_dir = root_dir / "data" / "images"
    data_yml_path = root_dir / "data.yaml"
    with open(data_yml_path, "r", encoding="utf-8") as f:
        yaml_data = yaml.safe_load(f)
    if yaml_data is None:
        yaml_data = {}
    yaml_data["path"] = str(images_dir.absolute())
    with open(data_yml_path, "w", encoding="utf-8") as f:
        yaml.safe_dump(
            yaml_data,
            f,
            allow_unicode=True,
            default_flow_style=False
        )