Download code/tt_meteor/tests/paths.py from changh95/meteor-p150: direct link, hf CLI and curl.
- Browser
- Download file 3.65 kB
-
https://huggingface.co/changh95/meteor-p150/resolve/main/code/tt_meteor/tests/paths.py
- Command line
-
hf download hf://changh95/meteor-p150/code/tt_meteor/tests/paths.py
-
curl -L -o paths.py https://huggingface.co/changh95/meteor-p150/resolve/main/code/tt_meteor/tests/paths.py
3.65 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| """Where the tests find data that is NOT shipped with the bundle. | |
| - The **shipped sample** is the synthetic eight-camera frame ``samples/synthetic_8cam.json`` (preset | |
| ``calib/synthetic_8cam.json``, stored CPU reference ``samples/synthetic_8cam.reference.json``; made by | |
| ``code/scripts/make_synthetic_sample.py``, Apache-2.0). | |
| - The **PandaSet 019 frame 40 sample** (CC BY 4.0 + PandaSet Dataset Terms), its calibration preset ``pandaset_019`` | |
| and its small goldens (feed sha256, decoded CPU reference, the ``/predict`` reference body) do not ship until the | |
| user approves PandaSet-derived samples (PLAN.md 6.3, research/DATASETS.md N5). They are found in | |
| ``$METEOR_PANDASET_DIR`` (a directory laid out like ``staging_samples_pandaset/``, i.e. like ``code/tt_meteor/``), | |
| else in ``code/tt_meteor/`` once swapped in, else in the git-ignored ``staging_samples_pandaset/`` of the bundle | |
| checkout. Inside the tt-models workspace a test that needs them FAILS when they are missing (a frozen gate must | |
| not vanish silently, :func:`need_pandaset`); elsewhere it skips. | |
| The workspace root is ``$TT_MODELS_ROOT`` (default ``/home/ubuntu/experiments/tt-models``). | |
| """ | |
| from __future__ import annotations | |
| import json | |
| import os | |
| from pathlib import Path | |
| from typing import Any, Dict | |
| PKG_DIR = Path(__file__).resolve().parents[1] | |
| CODE_DIR = PKG_DIR.parent | |
| BUNDLE_DIR = CODE_DIR.parent | |
| WORKSPACE = Path(os.environ.get("TT_MODELS_ROOT", "/home/ubuntu/experiments/tt-models")) | |
| GOLDENS_SMALL = PKG_DIR / "tests" / "goldens" | |
| SAMPLES = PKG_DIR / "samples" | |
| SHIPPED_NAME = "synthetic_8cam" | |
| SHIPPED_SAMPLE = SAMPLES / f"{SHIPPED_NAME}.json" # the shipped sample | |
| SHIPPED_REFERENCE = SAMPLES / f"{SHIPPED_NAME}.reference.json" | |
| SHIPPED_INPUTS = GOLDENS_SMALL / f"{SHIPPED_NAME}_inputs.json" | |
| STAGING_PANDASET = BUNDLE_DIR / "staging_samples_pandaset" # git-ignored, never shipped (PLAN.md 6.3) | |
| PANDASET_NAME = "pandaset_019_f40" | |
| def _pandaset_root() -> Path: | |
| env = os.environ.get("METEOR_PANDASET_DIR") | |
| if env: | |
| return Path(env) | |
| if (SAMPLES / f"{PANDASET_NAME}.json").is_file(): # swapped in after the user's OK | |
| return PKG_DIR | |
| return STAGING_PANDASET | |
| _PS = _pandaset_root() | |
| PANDASET_SAMPLES = _PS / "samples" | |
| PANDASET_CALIB = _PS / "calib" | |
| PANDASET_GOLDENS = _PS / "tests" / "goldens" | |
| PANDASET_SAMPLE = PANDASET_SAMPLES / f"{PANDASET_NAME}.json" # the request manifest (preset beside it) | |
| PANDASET_SCENE = PANDASET_SAMPLES / PANDASET_NAME # METEOR demo-scene layout of the same frame | |
| PANDASET_REFERENCE = PANDASET_SAMPLES / f"{PANDASET_NAME}.reference.json" | |
| def need_pandaset() -> None: | |
| """Skip (outside the workspace) or fail (inside it) when the staged PandaSet sample is missing.""" | |
| import pytest | |
| if PANDASET_SAMPLE.is_file() and (PANDASET_GOLDENS / f"{PANDASET_NAME}_inputs.json").is_file(): | |
| return | |
| msg = (f"the PandaSet 019 frame 40 sample is not at {PANDASET_SAMPLES} (staging_samples_pandaset/ of the bundle " | |
| "checkout or $METEOR_PANDASET_DIR; it does not ship until the user approves PandaSet-derived samples)") | |
| if (WORKSPACE / "research" / "meteor").is_dir(): | |
| pytest.fail(msg) | |
| pytest.skip(msg) | |
| def pandaset_golden(kind: str) -> Dict[str, Any]: | |
| """``tests/goldens/pandaset_019_f40_<kind>.json`` of the staged sample (``inputs`` or ``reference``).""" | |
| need_pandaset() | |
| return json.loads((PANDASET_GOLDENS / f"{PANDASET_NAME}_{kind}.json").read_text()) | |
| def shipped_inputs() -> Dict[str, Any]: | |
| return json.loads(SHIPPED_INPUTS.read_text()) | |