Skip to content

Commit 2c887a0

Browse files
Pigbibicodex
andauthored
fix: make monthly audit script executable from repo root (#109)
Co-authored-by: Codex <noreply@openai.com>
1 parent 4f7b2ab commit 2c887a0

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

scripts/run_monthly_codex_audit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
import urllib.parse
2020
import urllib.request
2121

22-
from service.model_router import route_model
22+
ROOT = Path(__file__).resolve().parents[1]
23+
if str(ROOT) not in sys.path:
24+
sys.path.insert(0, str(ROOT))
25+
26+
from service.model_router import route_model # noqa: E402
2327

2428

2529
API_BASE = "https://api.github.com"
26-
ROOT = Path(__file__).resolve().parents[1]
2730
PROMPT_TEMPLATES = {
2831
"monthly_snapshot_audit": ROOT / "prompts" / "monthly_crypto_snapshot_audit.md",
2932
"long_horizon_signal_shadow": ROOT / "prompts" / "long_horizon_signal_shadow.md",

tests/test_run_monthly_codex_audit.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import subprocess
6+
import sys
67
import tempfile
78
import threading
89
import time
@@ -93,6 +94,25 @@ def _normalized_policy(policy: dict[str, object]) -> dict[str, object]:
9394

9495

9596
class RunMonthlyCodexAuditTests(unittest.TestCase):
97+
def test_script_entrypoint_can_import_service_from_repo_root(self) -> None:
98+
repo_root = Path(__file__).resolve().parents[1]
99+
env = dict(os.environ)
100+
env.pop("PYTHONPATH", None)
101+
env["ISSUE_NUMBER"] = ""
102+
103+
result = subprocess.run(
104+
[sys.executable, "scripts/run_monthly_codex_audit.py"],
105+
cwd=repo_root,
106+
env=env,
107+
capture_output=True,
108+
text=True,
109+
check=False,
110+
)
111+
112+
self.assertEqual(result.returncode, 1)
113+
self.assertIn("ISSUE_NUMBER must be provided as an integer", result.stderr)
114+
self.assertNotIn("ModuleNotFoundError", result.stderr)
115+
96116
def test_parse_bool_accepts_common_true_values(self) -> None:
97117
for value in ("1", "true", "TRUE", "yes", "on", True):
98118
self.assertTrue(parse_bool(value))

0 commit comments

Comments
 (0)