CarlyneB's picture
[UX] British spelling: rename optimization → optimisation throughout code (conflict resolve)
7a80c0b
Raw
History Blame Contribute Delete
1.3 kB
"""
Run this script after any change to inputs.csv to update all
generated data files and Excel templates.
Usage:
python data/update.py
"""
import hashlib
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).parent.parent
PYTHON = sys.executable
scripts = [
("Coefficients + method groups + secondary resources", "data/generate_model_data.py"),
("Resource template (resource_template.xlsx)", "data/generate_resource_template.py"),
]
print("=" * 60)
print("CRRA Optimisation Tool — data update")
print("=" * 60)
for label, script in scripts:
print(f"\n▶ {label}")
result = subprocess.run(
[PYTHON, str(ROOT / script)],
cwd=str(ROOT),
capture_output=True,
text=True,
)
for line in result.stdout.splitlines():
print(f" {line}")
if result.returncode != 0:
print(f" ERROR:\n{result.stderr}")
sys.exit(result.returncode)
print("\n" + "=" * 60)
print("All files updated successfully.")
print("=" * 60)
# Update the hash file so the app knows the CSV is in sync
csv_path = ROOT / "data/inputs.csv"
hash_path = ROOT / "data/.csv_hash"
hasher = hashlib.md5()
with open(csv_path, "rb") as f:
hasher.update(f.read())
with open(hash_path, "w") as f:
f.write(hasher.hexdigest())