From cd0aab3c315cfdfc5dfce0a02172d17e5c2e76a8 Mon Sep 17 00:00:00 2001 From: xuangu-fang Date: Fri, 27 Jun 2025 17:01:29 +0800 Subject: [PATCH] fix: handle the bug of wrong dag_parant index (#996) * fix the dag_parant_index bug caused by the wrong calling order of * auto-lint --- rdagent/scenarios/data_science/loop.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rdagent/scenarios/data_science/loop.py b/rdagent/scenarios/data_science/loop.py index 306b4e0d..ea52b501 100644 --- a/rdagent/scenarios/data_science/loop.py +++ b/rdagent/scenarios/data_science/loop.py @@ -222,7 +222,6 @@ class DataScienceRDLoop(RDLoop): e = prev_out.get(self.EXCEPTION_KEY, None) if e is None: exp = prev_out["running"] - self.trace.hist.append((exp, prev_out["feedback"])) # NOTE: we put below operations on selections here, instead of out of the if-else block, # to fit the corner case that the trace will be reset @@ -232,8 +231,16 @@ class DataScienceRDLoop(RDLoop): self.trace.set_current_selection(exp.local_selection) self.trace.sync_dag_parent_and_hist() + self.trace.hist.append((exp, prev_out["feedback"])) + else: exp: DSExperiment = prev_out["direct_exp_gen"] if isinstance(e, CoderError) else prev_out["coding"] + + # set the local selection to the trace as global selection, then set the DAG parent for the trace + if exp.local_selection is not None: + self.trace.set_current_selection(exp.local_selection) + self.trace.sync_dag_parent_and_hist() + self.trace.hist.append( ( exp, @@ -241,11 +248,6 @@ class DataScienceRDLoop(RDLoop): ) ) - # set the local selection to the trace as global selection, then set the DAG parent for the trace - if exp.local_selection is not None: - self.trace.set_current_selection(exp.local_selection) - self.trace.sync_dag_parent_and_hist() - if self.trace.sota_experiment() is None: if DS_RD_SETTING.coder_on_whole_pipeline: # check if feedback is not generated