DavisEdward commited on
Commit
e43f4cc
·
1 Parent(s): d04effc

Improve file existence checks and error reporting

Browse files

Enhanced file validation in AgentExecutor by logging file paths and existence, and providing detailed error messages listing missing files instead of a generic error. This aids debugging and improves user feedback when required files are missing.

Files changed (1) hide show
  1. openhands_poc/executor.py +30 -12
openhands_poc/executor.py CHANGED
@@ -155,13 +155,22 @@ class AgentExecutor:
155
  drawing_path = self._get_file_path(drawing_file)
156
  spec_path = self._get_file_path(spec_file)
157
 
 
 
 
 
 
158
  # Validate files exist
159
- if not all([
160
- Path(schedule_path).exists(),
161
- Path(drawing_path).exists(),
162
- Path(spec_path).exists(),
163
- ]):
164
- return "unsupported", {"error": "One or more files do not exist"}
 
 
 
 
165
 
166
  # Run classification
167
  return await self.receptionist_agent.classify_documents_async(
@@ -228,13 +237,22 @@ class AgentExecutor:
228
  drawing_path = self._get_file_path(drawing_file)
229
  spec_path = self._get_file_path(spec_file)
230
 
 
 
 
 
 
231
  # Validate files exist
232
- if not all([
233
- Path(schedule_path).exists(),
234
- Path(drawing_path).exists(),
235
- Path(spec_path).exists(),
236
- ]):
237
- return "", {"error": "One or more files do not exist"}
 
 
 
 
238
 
239
  try:
240
  # Step 1: Classify documents with ReceptionistAgentSDK
 
155
  drawing_path = self._get_file_path(drawing_file)
156
  spec_path = self._get_file_path(spec_file)
157
 
158
+ # Debug: Log paths and existence
159
+ print(f"[Executor.classify] Schedule path: {schedule_path}, exists: {Path(schedule_path).exists()}")
160
+ print(f"[Executor.classify] Drawing path: {drawing_path}, exists: {Path(drawing_path).exists()}")
161
+ print(f"[Executor.classify] Spec path: {spec_path}, exists: {Path(spec_path).exists()}")
162
+
163
  # Validate files exist
164
+ missing_files = []
165
+ if not Path(schedule_path).exists():
166
+ missing_files.append(f"Schedule: {schedule_path}")
167
+ if not Path(drawing_path).exists():
168
+ missing_files.append(f"Drawing: {drawing_path}")
169
+ if not Path(spec_path).exists():
170
+ missing_files.append(f"Spec: {spec_path}")
171
+
172
+ if missing_files:
173
+ return "unsupported", {"error": f"Files not found: {', '.join(missing_files)}"}
174
 
175
  # Run classification
176
  return await self.receptionist_agent.classify_documents_async(
 
237
  drawing_path = self._get_file_path(drawing_file)
238
  spec_path = self._get_file_path(spec_file)
239
 
240
+ # Debug: Log paths and existence
241
+ print(f"[Executor] Schedule path: {schedule_path}, exists: {Path(schedule_path).exists()}")
242
+ print(f"[Executor] Drawing path: {drawing_path}, exists: {Path(drawing_path).exists()}")
243
+ print(f"[Executor] Spec path: {spec_path}, exists: {Path(spec_path).exists()}")
244
+
245
  # Validate files exist
246
+ missing_files = []
247
+ if not Path(schedule_path).exists():
248
+ missing_files.append(f"Schedule: {schedule_path}")
249
+ if not Path(drawing_path).exists():
250
+ missing_files.append(f"Drawing: {drawing_path}")
251
+ if not Path(spec_path).exists():
252
+ missing_files.append(f"Spec: {spec_path}")
253
+
254
+ if missing_files:
255
+ return "", {"error": f"Files not found: {', '.join(missing_files)}"}
256
 
257
  try:
258
  # Step 1: Classify documents with ReceptionistAgentSDK