mtyrrell commited on
Commit
8512247
·
1 Parent(s): 197d3e1
Files changed (1) hide show
  1. auditqa/utils.py +14 -5
auditqa/utils.py CHANGED
@@ -41,17 +41,26 @@ def save_logs(JSON_DATASET_PATH: str, logs: dict, feedback: str = None) -> None:
41
  Also saves user feedback (when provided).
42
  """
43
  try:
44
- # Create directory if it doesn't exist
45
- os.makedirs(os.path.dirname(JSON_DATASET_PATH), exist_ok=True)
 
 
 
 
 
 
 
 
 
46
 
47
  if feedback:
48
  logs["feedback"] = feedback
49
- logger.debug(f"Adding feedback to logs: {feedback}")
50
 
51
- with open(JSON_DATASET_PATH, 'a') as f:
52
  json.dump(logs, f)
53
  f.write("\n")
54
- logger.info(f"Successfully saved logs to {JSON_DATASET_PATH}")
55
  except Exception as e:
56
  logger.error(f"Failed to save logs to {JSON_DATASET_PATH}: {str(e)}")
57
  raise
 
41
  Also saves user feedback (when provided).
42
  """
43
  try:
44
+ # Debug logging to verify path
45
+ logger.debug(f"Attempting to save logs to path: '{JSON_DATASET_PATH}'")
46
+
47
+ # Validate path
48
+ if not JSON_DATASET_PATH:
49
+ raise ValueError("JSON_DATASET_PATH cannot be empty")
50
+
51
+ # Create directory if it doesn't exist (using the current directory if no path specified)
52
+ path = Path(JSON_DATASET_PATH)
53
+ if str(path.parent) != '.':
54
+ path.parent.mkdir(parents=True, exist_ok=True)
55
 
56
  if feedback:
57
  logs["feedback"] = feedback
58
+ logging.debug(f"Adding feedback to logs: {feedback}")
59
 
60
+ with open(path, 'a') as f:
61
  json.dump(logs, f)
62
  f.write("\n")
63
+ logger.info(f"Successfully saved logs to {path}")
64
  except Exception as e:
65
  logger.error(f"Failed to save logs to {JSON_DATASET_PATH}: {str(e)}")
66
  raise