@@ -155,13 +155,22 @@ def get_best_method(urls, metric_col="test_acc"):
155155
156156 # Find best run based on optimization goal
157157 goal = sweep .config ["metric" ]["goal" ]
158- best_run = max (sweep .runs , key = partial (get_metric , metric_col = metric_col )) if goal == "maximize" else \
159- min (sweep .runs , key = partial (get_metric , metric_col = metric_col )) if goal == "minimize" else \
158+ from dance .pipeline import get_additional_sweep , save_summary_data
159+ sweep_ids = get_additional_sweep (entity = entity , project = project , sweep_id = sweep_id )
160+ sweep_ids .remove (sweep_id )
161+ sweep_data = save_summary_data (entity = entity , project = project , sweep_id = sweep_id ,
162+ additional_sweep_ids = sweep_ids , save = False , summary_file_path = '' , root_path = '' )
163+
164+ if metric_col not in sweep_data .columns :
165+ continue
166+ best_run_id = sweep_data [metric_col ].idxmax () if goal == "maximize" else \
167+ sweep_data [metric_col ].idxmin () if goal == "minimize" else \
160168 None
161169
162- if best_run is None :
170+ if best_run_id is None :
163171 raise RuntimeError ("Optimization goal must be either 'minimize' or 'maximize'" )
164-
172+ api = wandb .Api (timeout = 1000 )
173+ best_run = api .run (f"/{ entity } /{ project } /runs/{ best_run_id } " )
165174 if metric_col not in best_run .summary :
166175 continue
167176 if all_best_run is None :
@@ -285,7 +294,7 @@ def get_new_ans(tissue):
285294 continue
286295
287296 step2_data = pd .read_csv (result_path )
288- if abs (len (step2_data ) - method_num [method_folder ]) > 3 :
297+ if abs (len (step2_data ) - method_num [method_folder ]) > 6 :
289298 print (f"File { result_path } has { len (step2_data )} rows, expected { method_num [method_folder ]} ." )
290299 continue
291300 step2_url = get_sweep_url (step2_data )
0 commit comments