1+ import hashlib
12import math
23import re
34from collections import defaultdict
@@ -157,8 +158,14 @@ def task_win(data):
157158 )
158159
159160
160- def workspace_win (data ):
161- show_files = {k : v for k , v in data .file_dict .items () if not "test" in k }
161+ def workspace_win (data , instance_id = None ):
162+ show_files = {k : v for k , v in data .file_dict .items () if "test" not in k }
163+
164+ base_key = str (data .workspace_path )
165+ if instance_id is not None :
166+ base_key += f"_{ instance_id } "
167+ unique_key = hashlib .md5 (base_key .encode ()).hexdigest ()
168+
162169 if len (show_files ) > 0 :
163170 with st .expander (f"Files in :blue[{ replace_ep_path (data .workspace_path )} ]" ):
164171 code_tabs = st .tabs (show_files .keys ())
@@ -170,6 +177,21 @@ def workspace_win(data):
170177 wrap_lines = True ,
171178 line_numbers = True ,
172179 )
180+
181+ st .markdown ("### Save All Files to Folder" )
182+ target_folder = st .text_input ("Enter target folder path:" , key = f"save_folder_path_input_{ unique_key } " )
183+
184+ if st .button ("Save Files" , key = f"save_files_button_{ unique_key } " ):
185+ if target_folder .strip () == "" :
186+ st .warning ("Please enter a valid folder path." )
187+ else :
188+ target_folder_path = Path (target_folder )
189+ target_folder_path .mkdir (parents = True , exist_ok = True )
190+ for filename , content in data .file_dict .items ():
191+ save_path = target_folder_path / filename
192+ save_path .parent .mkdir (parents = True , exist_ok = True )
193+ save_path .write_text (content , encoding = "utf-8" )
194+ st .success (f"All files saved to: { target_folder } " )
173195 else :
174196 st .markdown (f"No files in :blue[{ replace_ep_path (data .workspace_path )} ]" )
175197
@@ -187,7 +209,7 @@ def exp_gen_win(data):
187209 for tasks in data ["no_tag" ].pending_tasks_list :
188210 task_win (tasks [0 ])
189211 st .subheader ("Exp Workspace" )
190- workspace_win (data ["no_tag" ].experiment_workspace )
212+ workspace_win (data ["no_tag" ].experiment_workspace , instance_id = "exp_gen" )
191213
192214
193215def evolving_win (data , key ):
@@ -203,7 +225,7 @@ def evolving_win(data, key):
203225 if evo_id in data :
204226 if data [evo_id ]["evolving code" ][0 ] is not None :
205227 st .subheader ("codes" )
206- workspace_win (data [evo_id ]["evolving code" ][0 ])
228+ workspace_win (data [evo_id ]["evolving code" ][0 ], instance_id = key )
207229 fb = data [evo_id ]["evolving feedback" ][0 ]
208230 st .subheader ("evolving feedback" + ("✅" if bool (fb ) else "❌" ))
209231 f1 , f2 , f3 = st .tabs (["execution" , "return_checking" , "code" ])
@@ -236,15 +258,15 @@ def coding_win(data):
236258 evolving_win (evolving_data , key = "coding" )
237259 if "no_tag" in data :
238260 st .subheader ("Exp Workspace (coding final)" )
239- workspace_win (data ["no_tag" ].experiment_workspace )
261+ workspace_win (data ["no_tag" ].experiment_workspace , instance_id = "coding" )
240262
241263
242264def running_win (data , mle_score ):
243265 st .header ("Running" , divider = "blue" , anchor = "running" )
244266 evolving_win ({k : v for k , v in data .items () if isinstance (k , int )}, key = "running" )
245267 if "no_tag" in data :
246268 st .subheader ("Exp Workspace (running final)" )
247- workspace_win (data ["no_tag" ].experiment_workspace )
269+ workspace_win (data ["no_tag" ].experiment_workspace , instance_id = "running_dump" )
248270 st .subheader ("Result" )
249271 st .write (data ["no_tag" ].result )
250272 st .subheader ("MLE Submission Score" + ("✅" if (isinstance (mle_score , dict ) and mle_score ["score" ]) else "❌" ))
@@ -268,7 +290,7 @@ def sota_win(data):
268290 st .markdown (f"**SOTA Exp Hypothesis**" )
269291 hypothesis_win (data .hypothesis )
270292 st .markdown ("**Exp Workspace**" )
271- workspace_win (data .experiment_workspace )
293+ workspace_win (data .experiment_workspace , instance_id = "sota" )
272294 else :
273295 st .markdown ("No SOTA experiment." )
274296
0 commit comments