Update graph.py
Browse files
graph.py
CHANGED
@@ -174,23 +174,23 @@ class EssayWriter:
|
|
174 |
# Generate and save the graph in /tmp/
|
175 |
dot.render(output_path, format="png", cleanup=False)
|
176 |
|
177 |
-
# Check if
|
178 |
graph_path = "/tmp/graph.png"
|
179 |
if os.path.exists(graph_path):
|
180 |
with open(log_file, "w") as f:
|
181 |
f.write("✅ Graphviz successfully generated /tmp/graph.png\n")
|
182 |
print("✅ Graphviz successfully generated /tmp/graph.png")
|
183 |
else:
|
184 |
-
|
185 |
-
f.write("❌ Graphviz failed to generate /tmp/graph.png\n")
|
186 |
-
print("❌ Graphviz failed to generate /tmp/graph.png") # Debugging print
|
187 |
-
raise FileNotFoundError("❌ Graphviz failed to generate the workflow graph.")
|
188 |
|
189 |
except Exception as e:
|
190 |
-
|
|
|
191 |
with open(log_file, "w") as f:
|
192 |
f.write(error_message)
|
193 |
-
print(error_message)
|
|
|
|
|
194 |
|
195 |
|
196 |
|
|
|
174 |
# Generate and save the graph in /tmp/
|
175 |
dot.render(output_path, format="png", cleanup=False)
|
176 |
|
177 |
+
# Check if file exists
|
178 |
graph_path = "/tmp/graph.png"
|
179 |
if os.path.exists(graph_path):
|
180 |
with open(log_file, "w") as f:
|
181 |
f.write("✅ Graphviz successfully generated /tmp/graph.png\n")
|
182 |
print("✅ Graphviz successfully generated /tmp/graph.png")
|
183 |
else:
|
184 |
+
raise FileNotFoundError("❌ Graphviz failed to generate /tmp/graph.png")
|
|
|
|
|
|
|
185 |
|
186 |
except Exception as e:
|
187 |
+
# Capture full traceback
|
188 |
+
error_message = f"❌ Error generating workflow visualization:\n{traceback.format_exc()}\n"
|
189 |
with open(log_file, "w") as f:
|
190 |
f.write(error_message)
|
191 |
+
print(error_message)
|
192 |
+
return error_message
|
193 |
+
|
194 |
|
195 |
|
196 |
|