File size: 2,027 Bytes
e8055cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Tests for inference package path helpers."""

from pathlib import Path

import pytest

import inference


def test_video_path_finds_exact_dataset_match(tmp_path, monkeypatch):
    root = tmp_path / "VSI-Bench"
    video = root / "scannet" / "scene1.mp4"
    video.parent.mkdir(parents=True)
    video.write_bytes(b"fake video")
    monkeypatch.setattr(inference, "VSI_ROOT", root)

    assert inference.video_path("scene1") == str(video)
    assert inference.video_path("scene1", "scannet") == str(video)


def test_video_path_reports_missing_unknown_and_ambiguous_datasets(
    tmp_path, monkeypatch
):
    root = tmp_path / "VSI-Bench"
    for dataset in ("scannet", "arkitscenes"):
        path = root / dataset / "scene1.mp4"
        path.parent.mkdir(parents=True, exist_ok=True)
        path.write_bytes(b"fake video")
    monkeypatch.setattr(inference, "VSI_ROOT", root)

    with pytest.raises(ValueError, match="unknown VSI dataset"):
        inference.video_path("scene1", "badset")
    with pytest.raises(RuntimeError, match="multiple datasets"):
        inference.video_path("scene1")
    with pytest.raises(FileNotFoundError, match="searched"):
        inference.video_path("missing", "scannet")


def test_cache_dir_helpers_validate_axes_and_include_dimensions(tmp_path, monkeypatch):
    monkeypatch.setattr(inference, "CACHE_ROOT", tmp_path)

    assert inference.model_cache_dir(
        "depth-anything-3", "uniform", 16, "metric"
    ) == str(tmp_path / "depth-anything-3" / "metric" / "frames" / "uniform" / "16")
    assert inference.sam3_cache_dir("no tracking", "selective", 8) == str(
        tmp_path / "sam3" / "no tracking" / "frames" / "selective" / "8"
    )
    assert inference.parse_sam3_frame_mode("uniform-tracking") == (
        "uniform",
        "tracking",
    )
    with pytest.raises(ValueError, match="frame count"):
        inference.model_cache_dir("x", "uniform", 0)
    with pytest.raises(ValueError, match="unknown tracking"):
        inference.sam3_cache_dir("bad", "uniform")