Jeremy Live
commited on
Commit
·
8e70ec1
1
Parent(s):
76dd9b4
vv5
Browse files
app.py
CHANGED
@@ -247,13 +247,45 @@ except Exception as e:
|
|
247 |
execution_output = f"Error during script execution: {str(e)}\n\n"
|
248 |
execution_output += "Please check the generated code for issues or try a different query."
|
249 |
|
250 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
if os.path.exists(plot_file_path):
|
252 |
-
|
253 |
-
|
|
|
254 |
else:
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
except Exception as e:
|
259 |
traceback_str = traceback.format_exc()
|
|
|
247 |
execution_output = f"Error during script execution: {str(e)}\n\n"
|
248 |
execution_output += "Please check the generated code for issues or try a different query."
|
249 |
|
250 |
+
# Enhanced plot file checking with more detailed debugging
|
251 |
+
plot_debug_info = []
|
252 |
+
plot_found = False
|
253 |
+
|
254 |
+
# Check in current directory first
|
255 |
+
current_dir = os.getcwd()
|
256 |
+
plot_abs_path = os.path.abspath(plot_file_path)
|
257 |
+
|
258 |
+
# Log directory contents for debugging
|
259 |
+
plot_debug_info.append(f"Current directory: {current_dir}")
|
260 |
+
plot_debug_info.append("Directory contents:" + "\n- " + "\n- ".join(os.listdir('.')))
|
261 |
+
|
262 |
+
# Check if plot exists in current directory
|
263 |
if os.path.exists(plot_file_path):
|
264 |
+
plot_found = True
|
265 |
+
plot_debug_info.append(f"✅ Plot file found at: {plot_abs_path}")
|
266 |
+
generated_plot_path = plot_file_path
|
267 |
else:
|
268 |
+
# Try to find the plot file in subdirectories
|
269 |
+
for root, _, files in os.walk('.'):
|
270 |
+
if plot_file_path in files:
|
271 |
+
found_path = os.path.join(root, plot_file_path)
|
272 |
+
plot_found = True
|
273 |
+
plot_debug_info.append(f"✅ Plot file found at: {os.path.abspath(found_path)}")
|
274 |
+
generated_plot_path = found_path
|
275 |
+
break
|
276 |
+
|
277 |
+
if not plot_found:
|
278 |
+
plot_debug_info.append(f"❌ Plot file not found at: {plot_abs_path}")
|
279 |
+
plot_debug_info.append("Troubleshooting tips:")
|
280 |
+
plot_debug_info.append("1. Ensure the script calls plt.savefig('plot.png')")
|
281 |
+
plot_debug_info.append("2. Check for any errors in the execution output")
|
282 |
+
plot_debug_info.append("3. Verify the script has write permissions in the current directory")
|
283 |
+
|
284 |
+
# Add debug info to execution output
|
285 |
+
execution_output += "\n\n[PLOT DEBUG] " + "\n[PLOT DEBUG] ".join(plot_debug_info)
|
286 |
+
|
287 |
+
if not plot_found:
|
288 |
+
execution_output += f"\n\n[ERROR] Plot file '{plot_file_path}' was not generated. Check the debug information above for details."
|
289 |
|
290 |
except Exception as e:
|
291 |
traceback_str = traceback.format_exc()
|