fix: store absolute paths in dataset.json

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-07 14:10:06 +02:00
parent 8148971aae
commit 8bc42cabd9
3 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -120,10 +120,10 @@ def upsert_clip_annotation(folder: str, clip_path: str, label: str) -> None:
entries = json.load(f) entries = json.load(f)
except (json.JSONDecodeError, ValueError): except (json.JSONDecodeError, ValueError):
entries = [] entries = []
rel_path = os.path.relpath(clip_path, folder) abs_path = os.path.abspath(clip_path)
entry: dict = {"path": rel_path, "label": label} entry: dict = {"path": abs_path, "label": label}
for i, e in enumerate(entries): for i, e in enumerate(entries):
if e.get("path") == rel_path: if e.get("path") == abs_path:
entries[i] = entry entries[i] = entry
break break
else: else:
+1 -1
View File
@@ -245,7 +245,7 @@ def test_upsert_creates_file():
entries = json.load(f) entries = json.load(f)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0]["label"] == "dog barking" assert entries[0]["label"] == "dog barking"
assert entries[0]["path"] == "clip_001.mp4" assert entries[0]["path"] == clip
def test_upsert_appends_new_clips(): def test_upsert_appends_new_clips():
with tempfile.TemporaryDirectory() as d: with tempfile.TemporaryDirectory() as d:
+1 -1
View File
@@ -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]: def build_entries_for_folder(folder: str, records: list[dict]) -> list[dict]:
return [ 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 for rec in records
] ]