Download gmnet/code/journal_exp/scripts/run_e1_spectral.py from YFanwang/Backup: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/YFanwang/Backup/resolve/main/gmnet/code/journal_exp/scripts/run_e1_spectral.py
- Command line
-
hf download hf://datasets/YFanwang/Backup/gmnet/code/journal_exp/scripts/run_e1_spectral.py
-
curl -L -o run_e1_spectral.py https://huggingface.co/datasets/YFanwang/Backup/resolve/main/gmnet/code/journal_exp/scripts/run_e1_spectral.py
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() | |