Jeremy Live
commited on
Commit
·
1740ecf
1
Parent(s):
158f99d
Revert "vv5"
Browse filesThis reverts commit 8e70ec15fc58a92150e416917bbf2e069293057b.
app.py
CHANGED
@@ -247,45 +247,13 @@ 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 |
-
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 |
-
|
265 |
-
|
266 |
-
generated_plot_path = plot_file_path
|
267 |
else:
|
268 |
-
|
269 |
-
|
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()
|
|
|
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 |
+
# Check for the generated plot file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
if os.path.exists(plot_file_path):
|
252 |
+
print(f"Plot file found at: {os.path.abspath(plot_file_path)}") # Log file path
|
253 |
+
generated_plot_path = plot_file_path # Set the path to be returned
|
|
|
254 |
else:
|
255 |
+
print(f"Plot file not found at expected path: {os.path.abspath(plot_file_path)}") # Log missing file path
|
256 |
+
execution_output += f"\nPlot file '{plot_file_path}' not found after execution."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
except Exception as e:
|
259 |
traceback_str = traceback.format_exc()
|