4545 load_cached_survey_result ,
4646 load_cached_prepare_result ,
4747 persist_stage_result ,
48+ resolve_experiment_analysis ,
4849 resolve_prepare_result ,
4950 persist_survey_result ,
5051 get_args ,
@@ -61,6 +62,14 @@ def _persist_stage_output(cache_path: str, stage_name: str, payload: Dict[str, A
6162 json .dump (payload , f , ensure_ascii = False , indent = 4 )
6263 return stage_path
6364
65+
66+ def _update_runtime_progress (runtime : MasterRuntime , run_id : str , task_level : str ) -> None :
67+ runtime .write_runtime_status (
68+ run_id = run_id ,
69+ status = "running" ,
70+ metadata = {"entrypoint" : "run_infer_idea" , "task_level" : task_level },
71+ )
72+
6473class InnoFlow (FlowModule ):
6574 def __init__ (self , cache_path : str , log_path : Union [str , None , MetaChainLogger ] = None , model : str = "gpt-4o-2024-08-06" , code_env : DockerEnv = None , web_env : BrowserEnv = None , file_env : RequestsMarkdownBrowser = None ):
6675 super ().__init__ (cache_path , log_path , model )
@@ -151,6 +160,7 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
151160 artifacts = {"prepare_result" : os .path .join (self .cache_path , "prepare_stage" , "prepare_result.json" )},
152161 )
153162 context_variables ["stage_state" ] = runtime .load_state ()
163+ _update_runtime_progress (runtime , run_id , task_level )
154164 paper_list = prepare_dict ["reference_papers" ]
155165 download_res = self .download_papaer ({"paper_list" : paper_list , "local_root" : local_root , "workplace_name" : workplace_name })
156166
@@ -229,6 +239,7 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
229239 artifacts = {"survey_result" : survey_result_path },
230240 )
231241 context_variables ["stage_state" ] = runtime .load_state ()
242+ _update_runtime_progress (runtime , run_id , task_level )
232243
233244 plan_query = f"""\
234245 I have an innovative ideas related to machine learning:
@@ -283,6 +294,7 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
283294 artifacts = context_variables .get ("plan_artifacts" , {}),
284295 )
285296 context_variables ["stage_state" ] = runtime .load_state ()
297+ _update_runtime_progress (runtime , run_id , task_level )
286298
287299 if not runtime .can_run_stage ("implement" ):
288300 raise RuntimeError ("Implement stage cannot start before required prior stages are completed." )
@@ -427,6 +439,7 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
427439 artifacts = {"project_manifest" : implement_path },
428440 )
429441 context_variables ["stage_state" ] = runtime .load_state ()
442+ _update_runtime_progress (runtime , run_id , task_level )
430443
431444 if not runtime .can_run_stage ("judge" ):
432445 raise RuntimeError ("Judge stage cannot start before implement stage is completed." )
@@ -478,6 +491,7 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
478491 artifacts = {"judge_report" : judge_path },
479492 )
480493 context_variables ["stage_state" ] = runtime .load_state ()
494+ _update_runtime_progress (runtime , run_id , task_level )
481495
482496 MAX_ITER_TIMES = max_iter_times
483497 for i in range (MAX_ITER_TIMES ):
@@ -573,6 +587,7 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
573587 artifacts = {"submit_result" : submit_path },
574588 )
575589 context_variables ["stage_state" ] = runtime .load_state ()
590+ _update_runtime_progress (runtime , run_id , task_level )
576591
577592 EXP_ITER_TIMES = 2
578593 analysis_report = ""
@@ -598,9 +613,10 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
598613 judge_messages .append ({"role" : "user" , "content" : exp_planner_query })
599614 judge_messages , context_variables = await self .exp_analyser (judge_messages , context_variables , iter_times = f"refine_{ i + 1 } " )
600615 analysis_report = judge_messages [- 1 ]["content" ]
601-
602- analysis_report = context_variables ["experiment_report" ][- 1 ]["analysis_report" ]
603- further_plan = context_variables ["experiment_report" ][- 1 ]["further_plan" ]
616+ analysis_report , further_plan = resolve_experiment_analysis (
617+ context_variables ,
618+ analysis_report ,
619+ )
604620 # print(analysis_report)
605621 refine_query = f"""\
606622 You are given an innovative idea:
@@ -636,6 +652,7 @@ async def forward(self, instance_path: str, task_level: str, local_root: str, wo
636652 "analyze" ,
637653 artifacts = {"analysis_report" : analysis_path },
638654 )
655+ _update_runtime_progress (runtime , run_id , task_level )
639656
640657 print (refine_res )
641658 runtime .sync_stage_state ()
@@ -710,13 +727,14 @@ def main(args, references):
710727 with open (args .instance_path , "r" , encoding = "utf-8" ) as f :
711728 eval_instance = json .load (f )
712729 instance_id = eval_instance ["instance_id" ] + "_idea"
713- cache_path = args .cache_path + "_" + instance_id + "_" + COMPLETION_MODEL .replace ("/" , "__" )
730+ model_suffix = args .model .replace ("/" , "__" )
731+ cache_path = args .cache_path + "_" + instance_id + "_" + model_suffix
714732 local_root = os .path .join (
715733 os .getcwd (),
716734 "workplace_paper" ,
717- f"task_{ instance_id } " + "_" + COMPLETION_MODEL . replace ( "/" , "__" ) ,
735+ f"task_{ instance_id } " + "_" + model_suffix ,
718736 )
719- container_name = args .container_name + "_" + instance_id + "_" + COMPLETION_MODEL . replace ( "/" , "__" )
737+ container_name = args .container_name + "_" + instance_id + "_" + model_suffix
720738 os .makedirs (local_root , exist_ok = True )
721739 env_config = DockerConfig (container_name = container_name ,
722740 workplace_name = args .workplace_name ,
0 commit comments