Skip to content

Commit ead5283

Browse files
committed
Internal Submodule Purge Fix
1 parent 6756f07 commit ead5283

7 files changed

Lines changed: 37 additions & 55 deletions

File tree

‎test_support/compass.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,20 @@
55
import os
66
import pathlib
77

8-
from test_support.runtime import (
9-
SHARED_DRIVE_ROOT,
10-
get_root,
11-
hf_hub_download_cmd,
12-
run_subprocess_step,
13-
)
8+
from test_support.runtime import TEST_CACHE_PATH, get_root, hf_hub_download_cmd, run_subprocess_step
149

1510

1611
_REPO_ROOT = get_root()
1712

1813
# COMPASS repo — cloned directly into shared storage (not a git submodule).
1914
_COMPASS_GIT_URL = "https://github.com/NVlabs/COMPASS.git"
20-
SHARED_COMPASS_REPO = SHARED_DRIVE_ROOT / "repos/COMPASS"
15+
SHARED_COMPASS_REPO = TEST_CACHE_PATH / "repos/COMPASS"
2116

2217
# IsaacLab repo + installation — cloned and installed into shared storage.
2318
_ISAACLAB_GIT_URL = "https://github.com/isaac-sim/IsaacLab.git"
2419
_ISAACLAB_PIP_INDEX = "https://pypi.nvidia.com"
2520
_ISAACLAB_TORCH_INDEX = "https://download.pytorch.org/whl/cu128"
26-
SHARED_ISAACLAB_REPO = SHARED_DRIVE_ROOT / "repos/IsaacLab"
21+
SHARED_ISAACLAB_REPO = TEST_CACHE_PATH / "repos/IsaacLab"
2722

2823
# Dedicated venv for the IsaacLab/Isaac Sim Python environment.
2924
# Must live on local disk (/tmp) rather than the shared NFS drive because the
@@ -35,7 +30,7 @@
3530
_X_MOBILITY_WHL = "x_mobility/x_mobility-0.1.0-py3-none-any.whl"
3631
_X_MOBILITY_HF_REPO = "nvidia/X-Mobility"
3732
_X_MOBILITY_HF_FILE = "x_mobility-nav2-semantic_action_path.ckpt"
38-
SHARED_X_MOBILITY_CKPT = SHARED_DRIVE_ROOT / f"models/x_mobility/{_X_MOBILITY_HF_FILE}"
33+
SHARED_X_MOBILITY_CKPT = TEST_CACHE_PATH / f"models/x_mobility/{_X_MOBILITY_HF_FILE}"
3934

4035

4136
def isaaclab_env(env: dict[str, str], extra: dict[str, str] | None = None) -> dict[str, str]:

‎test_support/runtime.py‎

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,17 @@
1313
DEFAULT_SERVER_STARTUP_SECONDS = 600.0
1414

1515

16-
def _default_shared_drive_root() -> pathlib.Path:
17-
"""Return the shared drive root, falling back to a local cache dir.
18-
19-
In CI, CI_SHARED_DRIVE_PATH points to a shared PVC mounted across all
20-
runners, so assets/models/submodules downloaded on one run are reused on
21-
the next without re-downloading.
22-
23-
On dev machines (CI_SHARED_DRIVE_PATH unset), the fallback is
24-
~/.cache/g00t — a local directory that plays the same caching role so
25-
tests work identically without any extra setup.
26-
"""
27-
if "CI_SHARED_DRIVE_PATH" in os.environ:
28-
return pathlib.Path(os.environ["CI_SHARED_DRIVE_PATH"])
16+
def _default_cache_path() -> pathlib.Path:
17+
"""Return the cache root directory."""
18+
if "TEST_CACHE_PATH" in os.environ:
19+
return pathlib.Path(os.environ["TEST_CACHE_PATH"])
2920

3021
local_fallback = pathlib.Path.home() / ".cache" / "g00t"
3122
local_fallback.mkdir(parents=True, exist_ok=True)
3223
return local_fallback
3324

3425

35-
# In CI: shared PVC path from CI_SHARED_DRIVE_PATH.
36-
# On dev machines: ~/.cache/g00t (created automatically).
37-
SHARED_DRIVE_ROOT = _default_shared_drive_root()
26+
TEST_CACHE_PATH = _default_cache_path()
3827

3928

4029
def get_root() -> pathlib.Path:
@@ -120,29 +109,29 @@ def find_nvidia_egl_vendor_file() -> pathlib.Path:
120109

121110

122111
def resolve_shared_uv_cache_dir() -> pathlib.Path | None:
123-
"""Return a writable shared uv cache path common to all tests, or None.
112+
"""Return a writable uv cache path, or None.
124113
125-
Only redirects the uv cache when CI_SHARED_DRIVE_PATH is set — on dev
114+
Only redirects the uv cache when TEST_CACHE_PATH is set — on dev
126115
machines uv's default cache (~/.cache/uv) is already local and fast, so
127116
there is no benefit to overriding it.
128117
"""
129-
if "CI_SHARED_DRIVE_PATH" not in os.environ:
118+
if "TEST_CACHE_PATH" not in os.environ:
130119
return None
131-
cache_dir = SHARED_DRIVE_ROOT / "uv-cache"
120+
cache_dir = TEST_CACHE_PATH / "uv-cache"
132121
try:
133122
cache_dir.mkdir(parents=True, exist_ok=True)
134123
return cache_dir
135124
except OSError:
136125
print(
137-
f"[cache] warning: shared uv cache unavailable at {cache_dir}; "
126+
f"[cache] warning: uv cache unavailable at {cache_dir}; "
138127
"falling back to uv default cache dir"
139128
)
140129
return None
141130

142131

143132
def build_shared_hf_cache_env(cache_key: str) -> dict[str, str]:
144-
"""Build HF cache environment variables under shared storage for a cache key."""
145-
hf_cache_dir = SHARED_DRIVE_ROOT / f"hf-cache/{cache_key}"
133+
"""Build HF cache environment variables for a cache key."""
134+
hf_cache_dir = TEST_CACHE_PATH / f"hf-cache/{cache_key}"
146135
try:
147136
hub_cache_dir = hf_cache_dir / "hub"
148137
transformers_cache_dir = hf_cache_dir / "transformers"
@@ -152,7 +141,7 @@ def build_shared_hf_cache_env(cache_key: str) -> dict[str, str]:
152141
datasets_cache_dir.mkdir(parents=True, exist_ok=True)
153142
except OSError:
154143
print(
155-
f"[cache] warning: shared Hugging Face cache unavailable at {hf_cache_dir}; "
144+
f"[cache] warning: Hugging Face cache unavailable at {hf_cache_dir}; "
156145
"falling back to defaults"
157146
)
158147
return {}
@@ -171,7 +160,7 @@ def build_uv_runtime_env(
171160
uv_cache_dir: pathlib.Path | None = None,
172161
extra_env: dict[str, str] | None = None,
173162
) -> dict[str, str]:
174-
"""Build a runtime env with shared uv cache and venv selection.
163+
"""Build a runtime env with uv cache and venv selection.
175164
176165
UV_PROJECT_ENVIRONMENT tells uv which venv to use when running subprocesses
177166
(e.g. ``uv run python ...``). We forward the currently active venv so that
@@ -197,16 +186,14 @@ def build_shared_runtime_env(
197186
*,
198187
extra_env: dict[str, str] | None = None,
199188
) -> dict[str, str]:
200-
"""Build runtime env with shared uv cache and per-test HF cache."""
189+
"""Build runtime env with uv cache and per-test HF cache."""
201190
uv_cache_dir = resolve_shared_uv_cache_dir()
202191
merged_extra_env = {**build_shared_hf_cache_env(cache_key)}
203192
if extra_env:
204193
merged_extra_env.update(extra_env)
205194
env = build_uv_runtime_env(uv_cache_dir=uv_cache_dir, extra_env=merged_extra_env)
206195

207-
shared_drive_source = (
208-
"CI_SHARED_DRIVE_PATH" if "CI_SHARED_DRIVE_PATH" in os.environ else "local fallback"
209-
)
196+
cache_source = "TEST_CACHE_PATH" if "TEST_CACHE_PATH" in os.environ else "local fallback"
210197
uv_cache_str = str(uv_cache_dir) if uv_cache_dir is not None else "uv default"
211198
uv_venv = env.get("UV_PROJECT_ENVIRONMENT", "uv default")
212199
uv_venv_source = (
@@ -218,7 +205,7 @@ def build_shared_runtime_env(
218205
)
219206
hf_home = env.get("HF_HOME", "hf default")
220207
print(
221-
f"[cache] shared_drive_root={SHARED_DRIVE_ROOT} ({shared_drive_source})"
208+
f"[cache] cache_path={TEST_CACHE_PATH} ({cache_source})"
222209
f" uv_cache={uv_cache_str}"
223210
f" uv_venv={uv_venv} ({uv_venv_source})"
224211
f" hf_home={hf_home} (key={cache_key})",

‎tests/examples/test_dataset_video_backend.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from gr00t.utils import video_utils
2121
import huggingface_hub
2222
import pytest
23-
from test_support.runtime import SHARED_DRIVE_ROOT, get_root
23+
from test_support.runtime import TEST_CACHE_PATH, get_root
2424

2525

2626
REPO_ROOT = get_root()
@@ -99,7 +99,7 @@ def get_local_directory(self) -> Path:
9999
)
100100

101101

102-
SHARED_DATASETS_ROOT = SHARED_DRIVE_ROOT / "datasets"
102+
SHARED_DATASETS_ROOT = TEST_CACHE_PATH / "datasets"
103103

104104

105105
DATASET_CATALOG: tuple[DatasetCatalogEntry, ...] = (

‎tests/examples/test_libero.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from test_support.readme import extract_code_blocks, find_block, replace_once, run_bash_blocks
1010
from test_support.runtime import (
1111
DEFAULT_SERVER_STARTUP_SECONDS,
12-
SHARED_DRIVE_ROOT,
12+
TEST_CACHE_PATH,
1313
assert_port_available,
1414
build_shared_runtime_env,
1515
find_nvidia_egl_vendor_file,
@@ -27,13 +27,13 @@
2727

2828
DATASET_REL_PATH = pathlib.Path("examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot")
2929
DATASET_ROOT = REPO_ROOT / DATASET_REL_PATH
30-
SHARED_DATASETS_ROOT = SHARED_DRIVE_ROOT / "datasets"
30+
SHARED_DATASETS_ROOT = TEST_CACHE_PATH / "datasets"
3131

3232
SHARED_DATASET_ROOT = SHARED_DATASETS_ROOT / DATASET_REL_PATH
3333
MODEL_CHECKPOINT = pathlib.Path(f"/tmp/libero_spatial/checkpoint-{TRAINING_STEPS}")
3434

3535
LIBERO_REPO_PATH = REPO_ROOT / "external_dependencies/LIBERO"
36-
SHARED_LIBERO_REPO = SHARED_DRIVE_ROOT / "repos/LIBERO"
36+
SHARED_LIBERO_REPO = TEST_CACHE_PATH / "repos/LIBERO"
3737

3838

3939
def _libero_submodule_initialized() -> bool:
@@ -84,7 +84,7 @@ def _prepare_libero_repo(env: dict[str, str]) -> None:
8484
env=env,
8585
log_prefix="libero",
8686
)
87-
if SHARED_DRIVE_ROOT.exists():
87+
if TEST_CACHE_PATH.exists():
8888
modules_path = _git_modules_path(LIBERO_REPO_PATH)
8989
print(f"[libero] caching submodule to {wt_cache}", flush=True)
9090
wt_cache.mkdir(parents=True, exist_ok=True)
@@ -129,7 +129,7 @@ def _prepare_libero_dataset(blocks: list, env: dict[str, str]) -> None:
129129
download_code = find_block(
130130
blocks, "libero_spatial_no_noops_1.0.0_lerobot", language="bash"
131131
).code
132-
if SHARED_DRIVE_ROOT.exists():
132+
if TEST_CACHE_PATH.exists():
133133
download_code = download_code.replace(
134134
"examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/",
135135
f"{SHARED_DATASET_ROOT}/",

‎tests/examples/test_pointnav.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from test_support.readme import extract_code_blocks, find_block, replace_once, run_bash_blocks
1919
from test_support.runtime import (
2020
DEFAULT_SERVER_STARTUP_SECONDS,
21-
SHARED_DRIVE_ROOT,
21+
TEST_CACHE_PATH,
2222
assert_port_available,
2323
build_shared_runtime_env,
2424
get_root,
@@ -40,12 +40,12 @@
4040
_HF_FILENAME = "gr00t_post_training_g1.zip"
4141
_DATASET_NAME = "lerobot_heading"
4242

43-
SHARED_POINTNAV_DIR = SHARED_DRIVE_ROOT / "datasets/pointnav"
43+
SHARED_POINTNAV_DIR = TEST_CACHE_PATH / "datasets/pointnav"
4444
SHARED_POINTNAV_DATASET = SHARED_POINTNAV_DIR / _DATASET_NAME
4545

4646
# GR00T base model — downloaded once to shared storage and reused by the finetune step.
4747
_GROOT_MODEL_REPO_ID = "nvidia/GR00T-N1.6-3B"
48-
SHARED_GROOT_MODEL = SHARED_DRIVE_ROOT / "models/GR00T-N1.6-3B"
48+
SHARED_GROOT_MODEL = TEST_CACHE_PATH / "models/GR00T-N1.6-3B"
4949

5050

5151
def _dataset_ready(path: pathlib.Path) -> bool:

‎tests/examples/test_robocasa.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from test_support.readme import extract_code_blocks, find_block, replace_once, run_bash_blocks
1111
from test_support.runtime import (
1212
DEFAULT_SERVER_STARTUP_SECONDS,
13-
SHARED_DRIVE_ROOT,
13+
TEST_CACHE_PATH,
1414
assert_port_available,
1515
build_shared_runtime_env,
1616
get_root,
@@ -26,10 +26,10 @@
2626
README = REPO_ROOT / "examples/robocasa/README.md"
2727

2828
ROBOCASA_SUBMODULE_PATH = REPO_ROOT / "external_dependencies/robocasa"
29-
SHARED_ROBOCASA_REPO = SHARED_DRIVE_ROOT / "repos/robocasa"
29+
SHARED_ROBOCASA_REPO = TEST_CACHE_PATH / "repos/robocasa"
3030

3131
ROBOCASA_ASSETS_REPO_DIR = REPO_ROOT / "external_dependencies/robocasa/robocasa/models/assets"
32-
ROBOCASA_ASSETS_SHARED_DIR = SHARED_DRIVE_ROOT / "robocasa-assets"
32+
ROBOCASA_ASSETS_SHARED_DIR = TEST_CACHE_PATH / "robocasa-assets"
3333
# Version file written alongside cached assets to detect robocasa submodule updates.
3434
_ASSETS_VERSION_FILE = ROBOCASA_ASSETS_SHARED_DIR / ".robocasa_commit"
3535

@@ -183,7 +183,7 @@ def _prepare_robocasa_repo(env: dict[str, str]) -> None:
183183
env=env,
184184
log_prefix="robocasa",
185185
)
186-
if SHARED_DRIVE_ROOT.exists():
186+
if TEST_CACHE_PATH.exists():
187187
modules_path = _git_modules_path(ROBOCASA_SUBMODULE_PATH)
188188
print(f"[robocasa] caching submodule to {wt_cache}", flush=True)
189189
wt_cache.mkdir(parents=True, exist_ok=True)

‎tests/examples/test_robocasa_gr1_tabletop.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from test_support.readme import extract_code_blocks, find_block, replace_once, run_bash_blocks
99
from test_support.runtime import (
1010
DEFAULT_SERVER_STARTUP_SECONDS,
11-
SHARED_DRIVE_ROOT,
11+
TEST_CACHE_PATH,
1212
assert_port_available,
1313
build_shared_runtime_env,
1414
get_root,
@@ -28,7 +28,7 @@
2828
REPO_ROOT / "external_dependencies/robocasa-gr1-tabletop-tasks/robocasa/models/assets"
2929
)
3030

31-
ROBOCASA_ASSETS_SHARED_DIR = SHARED_DRIVE_ROOT / "robocasa-gr1-tabletop-tasks/assets"
31+
ROBOCASA_ASSETS_SHARED_DIR = TEST_CACHE_PATH / "robocasa-gr1-tabletop-tasks/assets"
3232

3333
REQUIRED_ASSET_DIRS = (
3434
"textures",

0 commit comments

Comments
 (0)