twanghcmut's picture
download
raw
2.83 kB
"""Tests for scripts/run_datagen.py -- now a thin CLI over
:class:`fpgm.datagen.pipeline.EpisodePipeline`.
The heavy stage logic this module used to test directly (S6's Defect 1-4 fixes: the
observed-surface point cloud, the prismatic precondition, poses.npz/events.json
writers) moved to :mod:`fpgm.datagen.geometry_ops` along with the code itself -- see
``tests/test_datagen_geometry_ops.py``. ``gripper_width_m``'s own tests live in
``tests/test_datagen_object_poses.py::TestGripperWidthM`` (moved there in an earlier
pass, before this one). What remains here is the CLI's own, now much smaller,
responsibility: argument parsing and stage-name validation.
``scripts/run_datagen.py`` is not an importable package (no ``scripts/__init__.py``,
by design -- it is a CLI entry point, not a library), so it is loaded here via
``importlib.util.spec_from_file_location``. Importing it executes its module-level
code (the ``.nvshim`` LD_LIBRARY_PATH shim, a handful of lightweight ``fpgm.*``
imports) but touches no GPU/CUDA/model-weight path -- safe in a no-GPU CI
environment, exactly like every other test in this suite.
"""
from __future__ import annotations
import importlib.util
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "src"))
def _load_run_datagen():
spec = importlib.util.spec_from_file_location(
"run_datagen_under_test", REPO_ROOT / "scripts" / "run_datagen.py"
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
run_datagen = _load_run_datagen()
class TestParseArgs:
def test_default_stages_match_the_pipeline(self, monkeypatch) -> None:
from fpgm.datagen.pipeline import EpisodePipeline
monkeypatch.setattr(
sys, "argv", ["run_datagen.py", "--uuid", "u", "--camera", "ext1"]
)
args = run_datagen.parse_args()
assert args.stages == ",".join(EpisodePipeline.STAGES)
assert args.config == run_datagen._DEFAULT_CONFIG
assert args.out_root is None
assert args.force is False
def test_explicit_stages_and_out_root_round_trip(self, monkeypatch) -> None:
monkeypatch.setattr(
sys, "argv",
[
"run_datagen.py", "--uuid", "u", "--camera", "22008760",
"--stages", "s2,s3", "--out-root", "/tmp/scratch", "--force",
],
)
args = run_datagen.parse_args()
assert args.stages == "s2,s3"
assert args.out_root == Path("/tmp/scratch")
assert args.force is True
class TestDefaultConfigPath:
def test_points_at_the_real_profile_yaml(self) -> None:
assert run_datagen._DEFAULT_CONFIG.name == "datagen_droid.yaml"
assert run_datagen._DEFAULT_CONFIG.exists()

Xet Storage Details

Size:
2.83 kB
·
Xet hash:
5bfbabb04b4cc84adc9a319ac2598083a29c515c22924f71a049e1a67c062908

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.