File size: 1,331 Bytes
10979b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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()