Files
cs249r_book/mlsysim/tests/test_constants_allowlist.py
Vijay Janapa Reddi 9c3dce60dc Delete the core/constants.py compat shim; migrate the whole corpus
No-backward-compat sweep, part 2. The module had been reduced to a
units-only re-export ('retired, do not add values'); per policy it is
now gone and every consumer reads the real home:

- 32 internal modules, the package __init__, and core/__init__ import
  core.units (physics modules keep their own physics/constants)
- 43 book chapters' LEGO cells migrated (star imports, named imports,
  and the appendix attribute style 'constants.VIDEO_*' -> units.*);
  lego_focal_verify confirms identical pass/flag state to pre-sweep
  (8 pre-existing structural flags, A/B-verified unchanged)
- tutorial/tools/test imports migrated (incl. binder test_units.py);
  book tests' legacy-symbol scanner treats a missing constants.py as
  'nothing defined'
- test_constants_allowlist.py rewritten as a deletion pin: the module
  (and any shim for it) must never return; core.units must keep the
  measurement surface (ureg, Q_, GB, BYTES_FP16, PRECISION_MAP, ...)
- test_mlsysim_registry_parity.py deleted: it compared registry values
  against legacy constants 'before deletion' — that migration is
  complete (registry gate list updated)
- Docs prose (DATA_MODEL, architecture, contributing) states the
  deletion instead of describing a retired shim

749 passed; binder registry gate green; star import intact.
2026-06-06 11:34:47 -04:00

37 lines
1.5 KiB
Python

"""CI gate: core/constants.py stays DELETED — units live in core/units.py only.
History: the taxonomy refactor (2026-05) reduced this module to a units-only
re-export; the no-backward-compat sweep (2026-06-06) deleted it outright and
migrated every consumer (package, tests, book LEGO cells, docs, tools) to
``mlsysim.core.units``. This pin prevents the junk drawer — or a compat shim
for it — from quietly coming back: there is exactly one home for measurement
units, and registry/physics values have category homes of their own.
"""
from __future__ import annotations
import importlib
from pathlib import Path
import pytest
CORE_DIR = Path(__file__).resolve().parents[1] / "mlsysim" / "core"
def test_constants_module_stays_deleted():
assert not (CORE_DIR / "constants.py").exists(), (
"core/constants.py was deleted in the 2026-06 no-backward-compat sweep; "
"units belong in core/units.py and domain values in their registries. "
"Do not reintroduce the module."
)
with pytest.raises(ModuleNotFoundError):
importlib.import_module("mlsysim.core.constants")
def test_units_module_carries_the_measurement_surface():
units = importlib.import_module("mlsysim.core.units")
# Spot-pin the names every consumer migrated onto, so a units.py refactor
# cannot silently strand the book's LEGO cells.
for name in ("ureg", "Q_", "GB", "GiB", "BYTES_FP16", "PRECISION_MAP", "resolve_precision"):
assert hasattr(units, name), f"core.units lost {name!r}"