MCPcopy Create free account
hub / github.com/Robbyant/lingbot-map / __init__

Method __init__

benchmark/viewer.py:86–114  ·  view source on GitHub ↗

Initialize cache manager. Args: data_dir: Path to method directory (e.g., workspace/dataset/scene/method) spatial_subsample: Spatial subsampling factor (used as cache key) workspace_root: Path to workspace root directory remove_sky: Whether sk

(self, data_dir: Path, spatial_subsample: int, workspace_root: Path, remove_sky: bool = False)

Source from the content-addressed store, hash-verified

84 """Manages persistent scene data caching (trajectory, point clouds) for faster loading."""
85
86 def __init__(self, data_dir: Path, spatial_subsample: int, workspace_root: Path, remove_sky: bool = False):
87 """Initialize cache manager.
88
89 Args:
90 data_dir: Path to method directory (e.g., workspace/dataset/scene/method)
91 spatial_subsample: Spatial subsampling factor (used as cache key)
92 workspace_root: Path to workspace root directory
93 remove_sky: Whether sky removal is enabled (determines which cache file to use)
94 """
95 self.data_dir = data_dir
96 self.spatial_subsample = spatial_subsample
97
98 # Compute relative path from workspace
99 try:
100 rel_path = data_dir.relative_to(workspace_root)
101 except ValueError:
102 # Fallback if data_dir is not under workspace_root
103 rel_path = Path(data_dir.name)
104
105 # Store cache in workspace/viewer_cache/{dataset}/{scene}/{method}/
106 self.cache_dir = workspace_root / "viewer_cache" / rel_path
107 sky_suffix = "_sky" if remove_sky else ""
108 self.cache_file = self.cache_dir / f"scene_data_{spatial_subsample}{sky_suffix}.npz"
109 self.params_file = self.cache_dir / f"cache_params_{spatial_subsample}{sky_suffix}.json"
110 # RGB thumbnail cache (independent of sky removal and spatial_subsample)
111 self.rgb_cache_file = self.cache_dir / "rgb_thumbnails.npz"
112 self.rgb_params_file = self.cache_dir / "rgb_params.json"
113 # Sky mask cache (independent of spatial_subsample)
114 self.sky_masks_file = self.cache_dir / "sky_masks.npz"
115
116 def is_valid(self, num_frames: int, image_width: int, image_height: int, has_transform: bool) -> bool:
117 """Check if cache exists and parameters match.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected