From b831172b66daa258af0d9b8907bef61d5aa63988 Mon Sep 17 00:00:00 2001 From: chenzihong <522023320011@smail.nju.edu.cn> Date: Fri, 16 Jan 2026 16:33:59 +0800 Subject: [PATCH 1/5] fix: fix cache error --- webui/app.py | 6 ++++++ webui/utils/cache.py | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/webui/app.py b/webui/app.py index 0c6cd5ef..08f1907a 100644 --- a/webui/app.py +++ b/webui/app.py @@ -1,6 +1,7 @@ import json import os import sys +import gc import tempfile from importlib.resources import files @@ -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) @@ -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 diff --git a/webui/utils/cache.py b/webui/utils/cache.py index 0c9412f2..c86ed5b3 100644 --- a/webui/utils/cache.py +++ b/webui/utils/cache.py @@ -1,6 +1,8 @@ -import os -import shutil +import time import uuid +import shutil +import os +import stat def setup_workspace(folder): @@ -17,6 +19,15 @@ def setup_workspace(folder): return log_file, working_dir -def cleanup_workspace(folder): - if os.path.exists(folder): - shutil.rmtree(folder) +def on_rm_error(func, path, exc_info): + os.chmod(path, stat.S_IWRITE) + + time.sleep(0.5) + try: + func(path) + except Exception: + pass + +def cleanup_workspace(working_dir): + if os.path.exists(working_dir): + shutil.rmtree(working_dir, onerror=on_rm_error) From 72d861e67c23f2519d13ea77165a6c6ba2df4972 Mon Sep 17 00:00:00 2001 From: chenzihong <58508660+ChenZiHong-Gavin@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:43:38 +0800 Subject: [PATCH 2/5] Update webui/app.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- webui/app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webui/app.py b/webui/app.py index 08f1907a..7a039a30 100644 --- a/webui/app.py +++ b/webui/app.py @@ -217,6 +217,13 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()): finally: if engine: + # Explicitly terminate Ray actors to release resources + for actor in engine.llm_actors.values(): + if actor: + ray.kill(actor) + for actor in engine.storage_actors.values(): + if actor: + ray.kill(actor) del engine gc.collect() From 68f50122972042262fb59742d10528a57a5dcfb1 Mon Sep 17 00:00:00 2001 From: chenzihong <58508660+ChenZiHong-Gavin@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:44:10 +0800 Subject: [PATCH 3/5] Update webui/utils/cache.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- webui/utils/cache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webui/utils/cache.py b/webui/utils/cache.py index c86ed5b3..addee692 100644 --- a/webui/utils/cache.py +++ b/webui/utils/cache.py @@ -20,7 +20,8 @@ def setup_workspace(folder): def on_rm_error(func, path, exc_info): - os.chmod(path, stat.S_IWRITE) + st = os.stat(path) + os.chmod(path, st.st_mode | stat.S_IWRITE) time.sleep(0.5) try: From 30f8a3014760b1be2c88326c29b2e647b1fa0a79 Mon Sep 17 00:00:00 2001 From: chenzihong <522023320011@smail.nju.edu.cn> Date: Fri, 16 Jan 2026 17:24:55 +0800 Subject: [PATCH 4/5] fix: fix lint error --- webui/app.py | 7 ------- webui/utils/cache.py | 5 ++++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/webui/app.py b/webui/app.py index 7a039a30..08f1907a 100644 --- a/webui/app.py +++ b/webui/app.py @@ -217,13 +217,6 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()): finally: if engine: - # Explicitly terminate Ray actors to release resources - for actor in engine.llm_actors.values(): - if actor: - ray.kill(actor) - for actor in engine.storage_actors.values(): - if actor: - ray.kill(actor) del engine gc.collect() diff --git a/webui/utils/cache.py b/webui/utils/cache.py index addee692..85a3486e 100644 --- a/webui/utils/cache.py +++ b/webui/utils/cache.py @@ -2,6 +2,7 @@ import uuid import shutil import os +import sys import stat @@ -30,5 +31,7 @@ def on_rm_error(func, path, exc_info): pass def cleanup_workspace(working_dir): - if os.path.exists(working_dir): + if sys.version_info >= (3, 12): + shutil.rmtree(working_dir, onexc=on_rm_error) + else: shutil.rmtree(working_dir, onerror=on_rm_error) From 5789ad2d89dcd8f90d3d930ea6e4aa40f16dd24e Mon Sep 17 00:00:00 2001 From: chenzihong-gavin Date: Mon, 19 Jan 2026 11:33:56 +0800 Subject: [PATCH 5/5] fix: fix lint error --- webui/utils/cache.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/webui/utils/cache.py b/webui/utils/cache.py index 85a3486e..eb537c49 100644 --- a/webui/utils/cache.py +++ b/webui/utils/cache.py @@ -1,9 +1,8 @@ -import time -import uuid -import shutil import os -import sys +import shutil import stat +import time +import uuid def setup_workspace(folder): @@ -20,18 +19,14 @@ def setup_workspace(folder): return log_file, working_dir -def on_rm_error(func, path, exc_info): - st = os.stat(path) - os.chmod(path, st.st_mode | stat.S_IWRITE) +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: - func(path) + shutil.rmtree(working_dir) except Exception: pass - -def cleanup_workspace(working_dir): - if sys.version_info >= (3, 12): - shutil.rmtree(working_dir, onexc=on_rm_error) - else: - shutil.rmtree(working_dir, onerror=on_rm_error)