Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions webui/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import sys
import gc
import tempfile
from importlib.resources import files

Expand Down Expand Up @@ -178,6 +179,7 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
"nodes": nodes,
}

engine = None
try:
# 4. Initialize and Run Engine
engine = Engine(config, operators)
Expand Down Expand Up @@ -214,6 +216,10 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
raise gr.Error(f"Error occurred: {str(e)}")

finally:
if engine:
del engine
gc.collect()

# Clean up workspace
cleanup_workspace(working_dir) # Optional: keep for debugging or enable

Expand Down
16 changes: 13 additions & 3 deletions webui/utils/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import shutil
import stat
import time
import uuid


Expand All @@ -17,6 +19,14 @@ def setup_workspace(folder):
return log_file, working_dir


def cleanup_workspace(folder):
if os.path.exists(folder):
shutil.rmtree(folder)
def cleanup_workspace(working_dir):
if not os.path.exists(working_dir):
return
st = os.stat(working_dir)
os.chmod(working_dir, st.st_mode | stat.S_IWRITE)

time.sleep(0.5)
try:
shutil.rmtree(working_dir)
except Exception:
pass
Comment on lines +31 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Silently swallowing exceptions with except Exception: pass can hide underlying issues and make debugging difficult. If the cleanup consistently fails for some reason, you would have no way of knowing, and temporary files could accumulate. Consider logging the exception here, even if you don't re-raise it, so that persistent problems can be identified.