feat: add last_exp_fb to DSTrace and update feedback retrieval usage (#910)

* feat: add last_exp_fb to DSTrace and update feedback retrieval usage

* fix: use trace.last_exp_fb for previous trial feedback description
This commit is contained in:
you-n-g
2025-05-29 20:32:06 +08:00
committed by GitHub
parent a7c6fca8b4
commit 4974277f1c
2 changed files with 13 additions and 5 deletions
@@ -31,11 +31,9 @@ class DSExperiment2Feedback(Experiment2Feedback):
exp=sota_exp, heading="SOTA of previous exploration of the scenario"
)
last_exp = trace.last_exp()
# Get feedback description using shared template
feedback_desc = T("scenarios.data_science.share:describe.feedback").r(
exp_and_feedback=trace.hist[-1] if trace.hist else None, heading="Previous Trial Feedback"
exp_and_feedback=trace.last_exp_fb(), heading="Previous Trial Feedback"
)
# TODO:
@@ -304,10 +304,20 @@ class DSTrace(Trace[DataScienceScen, KnowledgeBase]):
"""
Access the last experiment
"""
search_list = self.retrieve_search_list(search_type)
if (last_exp_fb := self.last_exp_fb(search_type=search_type)) is not None:
return last_exp_fb[0]
return None
def last_exp_fb(
self,
search_type: Literal["all", "ancestors"] = "ancestors",
) -> tuple[DSExperiment, ExperimentFeedback] | None:
"""
Access the last experiment and feedback
"""
search_list = self.retrieve_search_list(search_type)
for exp, ef in search_list[::-1]:
return exp
return exp, ef
return None
def last_runnable_exp_fb(