Files
cs249r_book/scripts/exec_analysis.py
Vijay Janapa Reddi fccee3c735 Refactor: complete the Great Constant Migration across mlsysim and Quarto chapters
- Migrated all legacy constants from constants.py to hardware and model registries
- Updated dozens of LEGO blocks in Volume 1 and Volume 2 to use Engine.solve and formulas
- Resolved all resulting NameError, TypeError, and AttributeError exceptions in the inline Python blocks
- Master Quarto HTML build now passes with zero execution failures
2026-05-23 16:45:00 -04:00

34 lines
832 B
Python

import glob
import traceback
import sys
qmd_files = sorted(glob.glob('book/quarto/contents/**/*.qmd', recursive=True))
failed = False
for qmd in qmd_files:
with open(qmd, 'r') as f:
content = f.read()
import re
blocks = re.findall(r'```\{python\}(.*?)```', content, re.DOTALL)
if not blocks:
continue
combined_code = "\n".join(blocks)
# We execute it in a clean dictionary to act as the global namespace
namespace = {}
try:
exec(combined_code, namespace)
except Exception as e:
failed = True
print(f"❌ Error in {qmd}:")
traceback.print_exc(limit=0, file=sys.stdout)
print("-" * 40)
if not failed:
print("✅ All Python blocks executed successfully across the entire book!")
sys.exit(0)
else:
sys.exit(1)