9fe9d27865
Consolidate next-stage docs, archive superseded narratives, and preserve frozen document inputs. Retain invalid P2 pairs, partial RootXY training, failed attempts and nonselectable checkpoints as explicit limitations. Include supervised evaluation/training, desktop GPU admission, bounded evidence and atomic-publication monitor repairs with CPU regressions. Ignore local dotenv configuration. Validation: 1403 passed, 6 skipped for contact-cycle and related contracts/CLI tests. Full-suite legacy ABI and registration tests require Python 3.12/Torch 2.10/pxr; no runtime checks relaxed. No new physical run or accepted skill.
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
"""Trainer CLI forwards visualization to workers without importing Kit."""
|
|
|
|
import importlib.util
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
@pytest.fixture
|
|
def trainer(monkeypatch):
|
|
monkeypatch.syspath_prepend(str(ROOT / "scripts"))
|
|
spec = importlib.util.spec_from_file_location("train_leg_skill", ROOT / "scripts/train_leg_skill.py")
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
@pytest.mark.parametrize("viz_args", [[], ["--viz", "kit"], ["--viz", "none"], ["--visualizer", "kit"]])
|
|
def test_worker_visualization_forwarding(trainer, tmp_path, viz_args):
|
|
bundles = [tmp_path / "go2_fl", tmp_path / "go1_fl"]
|
|
args = trainer.parse_args(
|
|
[
|
|
"--bundles",
|
|
*map(str, bundles),
|
|
"--num_envs",
|
|
"1",
|
|
"--horizon",
|
|
"32",
|
|
"--updates",
|
|
"1",
|
|
*viz_args,
|
|
]
|
|
)
|
|
for index, bundle in enumerate(args.bundles):
|
|
directory = tmp_path / "update_0000" / bundle.name
|
|
command = trainer.worker_command(args, bundle, tmp_path / "sampling_policy.pt", directory, args.seed + index)
|
|
assert command[0] == sys.executable
|
|
assert Path(command[1]).name == "leg_worker.py"
|
|
assert command[command.index("--bundle") + 1] == str(bundle.resolve())
|
|
assert command[command.index("--output") + 1] == str(directory.resolve())
|
|
assert command[command.index("--seed") + 1] == str(args.seed + index)
|
|
assert command[command.index("--device") + 1] == args.device
|
|
assert command[command.index("--mode") + 1] == "rollout"
|
|
if viz_args:
|
|
assert command[-2:] == ["--viz", viz_args[-1]]
|
|
else:
|
|
assert "--viz" not in command
|
|
|
|
|
|
def test_invalid_visualization_rejected(trainer):
|
|
with pytest.raises(SystemExit) as error:
|
|
trainer.parse_args(["--bundles", "asset", "--viz", "invalid"])
|
|
assert error.value.code == 2
|