diff --git a/main.py b/main.py index 36667d2..3cd9bc3 100755 --- a/main.py +++ b/main.py @@ -120,10 +120,10 @@ def upsert_clip_annotation(folder: str, clip_path: str, label: str) -> None: entries = json.load(f) except (json.JSONDecodeError, ValueError): entries = [] - rel_path = os.path.relpath(clip_path, folder) - entry: dict = {"path": rel_path, "label": label} + abs_path = os.path.abspath(clip_path) + entry: dict = {"path": abs_path, "label": label} for i, e in enumerate(entries): - if e.get("path") == rel_path: + if e.get("path") == abs_path: entries[i] = entry break else: diff --git a/tests/test_utils.py b/tests/test_utils.py index 263b422..2565151 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -245,7 +245,7 @@ def test_upsert_creates_file(): entries = json.load(f) assert len(entries) == 1 assert entries[0]["label"] == "dog barking" - assert entries[0]["path"] == "clip_001.mp4" + assert entries[0]["path"] == clip def test_upsert_appends_new_clips(): with tempfile.TemporaryDirectory() as d: diff --git a/tools/migrate_dataset_json.py b/tools/migrate_dataset_json.py index 7e0b23e..07f6c4f 100644 --- a/tools/migrate_dataset_json.py +++ b/tools/migrate_dataset_json.py @@ -30,7 +30,7 @@ def load_db_records(db_path: Path) -> list[dict]: def build_entries_for_folder(folder: str, records: list[dict]) -> list[dict]: return [ - {"path": os.path.relpath(rec["output_path"], folder), "label": rec["label"]} + {"path": os.path.abspath(rec["output_path"]), "label": rec["label"]} for rec in records ]