github-actions[bot] commited on
Commit
bcf65d3
·
1 Parent(s): caa2d9c

Auto-sync from demo at Mon Jan 19 05:28:47 UTC 2026

Browse files
Files changed (3) hide show
  1. app.py +6 -0
  2. webui/app.py +6 -0
  3. webui/utils/cache.py +13 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import json
2
  import os
3
  import sys
 
4
  import tempfile
5
  from importlib.resources import files
6
 
@@ -178,6 +179,7 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
178
  "nodes": nodes,
179
  }
180
 
 
181
  try:
182
  # 4. Initialize and Run Engine
183
  engine = Engine(config, operators)
@@ -214,6 +216,10 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
214
  raise gr.Error(f"Error occurred: {str(e)}")
215
 
216
  finally:
 
 
 
 
217
  # Clean up workspace
218
  cleanup_workspace(working_dir) # Optional: keep for debugging or enable
219
 
 
1
  import json
2
  import os
3
  import sys
4
+ import gc
5
  import tempfile
6
  from importlib.resources import files
7
 
 
179
  "nodes": nodes,
180
  }
181
 
182
+ engine = None
183
  try:
184
  # 4. Initialize and Run Engine
185
  engine = Engine(config, operators)
 
216
  raise gr.Error(f"Error occurred: {str(e)}")
217
 
218
  finally:
219
+ if engine:
220
+ del engine
221
+ gc.collect()
222
+
223
  # Clean up workspace
224
  cleanup_workspace(working_dir) # Optional: keep for debugging or enable
225
 
webui/app.py CHANGED
@@ -1,6 +1,7 @@
1
  import json
2
  import os
3
  import sys
 
4
  import tempfile
5
  from importlib.resources import files
6
 
@@ -178,6 +179,7 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
178
  "nodes": nodes,
179
  }
180
 
 
181
  try:
182
  # 4. Initialize and Run Engine
183
  engine = Engine(config, operators)
@@ -214,6 +216,10 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
214
  raise gr.Error(f"Error occurred: {str(e)}")
215
 
216
  finally:
 
 
 
 
217
  # Clean up workspace
218
  cleanup_workspace(working_dir) # Optional: keep for debugging or enable
219
 
 
1
  import json
2
  import os
3
  import sys
4
+ import gc
5
  import tempfile
6
  from importlib.resources import files
7
 
 
179
  "nodes": nodes,
180
  }
181
 
182
+ engine = None
183
  try:
184
  # 4. Initialize and Run Engine
185
  engine = Engine(config, operators)
 
216
  raise gr.Error(f"Error occurred: {str(e)}")
217
 
218
  finally:
219
+ if engine:
220
+ del engine
221
+ gc.collect()
222
+
223
  # Clean up workspace
224
  cleanup_workspace(working_dir) # Optional: keep for debugging or enable
225
 
webui/utils/cache.py CHANGED
@@ -1,5 +1,7 @@
1
  import os
2
  import shutil
 
 
3
  import uuid
4
 
5
 
@@ -17,6 +19,14 @@ def setup_workspace(folder):
17
  return log_file, working_dir
18
 
19
 
20
- def cleanup_workspace(folder):
21
- if os.path.exists(folder):
22
- shutil.rmtree(folder)
 
 
 
 
 
 
 
 
 
1
  import os
2
  import shutil
3
+ import stat
4
+ import time
5
  import uuid
6
 
7
 
 
19
  return log_file, working_dir
20
 
21
 
22
+ def cleanup_workspace(working_dir):
23
+ if not os.path.exists(working_dir):
24
+ return
25
+ st = os.stat(working_dir)
26
+ os.chmod(working_dir, st.st_mode | stat.S_IWRITE)
27
+
28
+ time.sleep(0.5)
29
+ try:
30
+ shutil.rmtree(working_dir)
31
+ except Exception:
32
+ pass