2025-01-17 22:53:05 +08:00
|
|
|
import typing
|
2024-06-14 12:59:44 +08:00
|
|
|
from abc import ABC, abstractmethod
|
2024-06-28 11:45:23 +08:00
|
|
|
|
2025-01-17 22:53:05 +08:00
|
|
|
if typing.TYPE_CHECKING:
|
|
|
|
|
from rdagent.core.experiment import Task, Workspace
|
2025-02-11 20:50:19 +08:00
|
|
|
from rdagent.core.scenario import Scenario
|
2025-01-17 22:53:05 +08:00
|
|
|
|
2024-07-05 17:42:00 +08:00
|
|
|
|
|
|
|
|
class Feedback:
|
2025-01-17 22:53:05 +08:00
|
|
|
"""
|
|
|
|
|
Design Principle:
|
|
|
|
|
It will be more like a **dataclass**.
|
|
|
|
|
The building process of feedback will should be in evaluator
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __bool__(self) -> bool:
|
|
|
|
|
return True
|
2024-06-28 11:45:23 +08:00
|
|
|
|
2024-06-14 12:59:44 +08:00
|
|
|
|
|
|
|
|
class Evaluator(ABC):
|
2025-01-17 22:53:05 +08:00
|
|
|
"""
|
|
|
|
|
Design Principle:
|
|
|
|
|
|
|
|
|
|
It should cover the building process of feedback from raw information.
|
2025-02-11 20:50:19 +08:00
|
|
|
Typically the building of feedback will be two phases.
|
|
|
|
|
1. raw information including stdout & workspace (feedback itself will handle this)
|
|
|
|
|
2. advanced/summarized feedback information. (evaluate will handle this)
|
2025-01-17 22:53:05 +08:00
|
|
|
"""
|
|
|
|
|
|
2024-07-05 17:42:00 +08:00
|
|
|
def __init__(
|
|
|
|
|
self,
|
2025-02-11 20:50:19 +08:00
|
|
|
scen: "Scenario",
|
2024-07-05 17:42:00 +08:00
|
|
|
) -> None:
|
|
|
|
|
self.scen = scen
|
|
|
|
|
|
2024-06-14 12:59:44 +08:00
|
|
|
@abstractmethod
|
|
|
|
|
def evaluate(
|
|
|
|
|
self,
|
2025-01-17 22:53:05 +08:00
|
|
|
target_task: "Task",
|
|
|
|
|
implementation: "Workspace",
|
|
|
|
|
gt_implementation: "Workspace",
|
2024-07-18 22:36:04 +08:00
|
|
|
**kwargs: object,
|
2025-01-17 22:53:05 +08:00
|
|
|
) -> Feedback:
|
2024-06-14 12:59:44 +08:00
|
|
|
raise NotImplementedError
|