Backup / gmnet /code /journal_exp /scripts /run_e1_spectral.py
YFanwang's picture
Add files using upload-large-folder tool
10979b5 verified
Raw History Blame Contribute Delete
1.33 kB
#!/usr/bin/env python3
"""Run the local E1 spectral audit and write only under /tmp."""
from __future__ import annotations
import argparse
import sys
from datetime import UTC, datetime
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from gmnet.spectral.experiment import run_experiment
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument(
"--config",
type=Path,
default=Path("configs/e1_spectral/gate_block_audit.yaml"),
)
parser.add_argument("--output-dir", type=Path)
return parser.parse_args()
def main() -> None:
args = parse_args()
output_dir = args.output_dir or Path(
"/tmp/gmnet_runs/"
f"e1_spectral_{datetime.now(UTC).strftime('%Y%m%dT%H%M%SZ')}"
)
resolved = output_dir.resolve()
allowed_root = Path("/tmp/gmnet_runs").resolve()
if resolved.parent != allowed_root or not resolved.name.startswith("e1_spectral_"):
raise ValueError(
"E1 local results must be a direct /tmp/gmnet_runs/e1_spectral_* directory"
)
result = run_experiment(args.config, resolved)
print(f"E1 complete: {result['output_dir']}")
if __name__ == "__main__":
main()