Skip to content

Commit c654bb3

Browse files
committed
Fix: Handle missing directories in export_compliance_report
- Add automatic directory creation for output path if it doesn't exist - Move os import to top-level for consistency - Remove redundant os import from RingIntel.__init__ - Replace emoji with ASCII in BUY MORE COVER message to fix encoding issues - Examples now run successfully without FileNotFoundError - All 14 unit tests still passing
1 parent 7034307 commit c654bb3

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Python/orionai.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
import json
9+
import os
910
import re
1011
from datetime import datetime
1112
from enum import Enum
@@ -37,8 +38,6 @@ def __init__(self, model_name: Optional[str] = None):
3738
self.model_name = model_name or self.TOXICITY_MODELS[0]
3839

3940
# Check if ML is disabled via environment variable (for testing)
40-
import os
41-
4241
if os.environ.get("ORIONAI_DISABLE_ML") == "1":
4342
print("[!] Ring Intel disabled - ML disabled via environment variable")
4443
return
@@ -476,7 +475,7 @@ def _enter_buy_more_mode(self, reason: str):
476475
self.safe_mode_active = True
477476

478477
print("=" * 50)
479-
print("🛡️ BUY MORE COVER ACTIVATED")
478+
print("[!] BUY MORE COVER ACTIVATED")
480479
print(f"Reason: {reason}")
481480
print("ALL AI SYSTEMS LIMITED")
482481
print("=" * 50)
@@ -547,6 +546,11 @@ def export_compliance_report(
547546
for rule in qr.triggered_rules:
548547
report += f" - {rule}\n"
549548

549+
# Create directory if it doesn't exist
550+
output_dir = os.path.dirname(output_path)
551+
if output_dir and not os.path.exists(output_dir):
552+
os.makedirs(output_dir, exist_ok=True)
553+
550554
with open(output_path, "w") as f:
551555
f.write(report)
552556

0 commit comments

Comments
 (0)