2024-07-05 17:42:00 +08:00
|
|
|
from rdagent.components.coder.factor_coder.factor import (
|
2024-07-02 17:58:37 +08:00
|
|
|
FactorExperiment,
|
2024-07-17 15:00:13 +08:00
|
|
|
FactorFBWorkspace,
|
2024-07-02 17:58:37 +08:00
|
|
|
FactorTask,
|
|
|
|
|
)
|
|
|
|
|
from rdagent.core.evolving_framework import EvolvableSubjects
|
2024-07-16 20:35:42 +08:00
|
|
|
from rdagent.log import rdagent_logger as logger
|
2024-07-02 17:58:37 +08:00
|
|
|
|
|
|
|
|
|
2024-07-04 15:56:14 +08:00
|
|
|
class FactorEvolvingItem(FactorExperiment, EvolvableSubjects):
|
2024-07-02 17:58:37 +08:00
|
|
|
"""
|
|
|
|
|
Intermediate item of factor implementation.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
sub_tasks: list[FactorTask],
|
2024-07-17 15:00:13 +08:00
|
|
|
sub_gt_implementations: list[FactorFBWorkspace] = None,
|
2024-07-02 17:58:37 +08:00
|
|
|
):
|
|
|
|
|
FactorExperiment.__init__(self, sub_tasks=sub_tasks)
|
|
|
|
|
self.corresponding_selection: list = None
|
|
|
|
|
if sub_gt_implementations is not None and len(
|
|
|
|
|
sub_gt_implementations,
|
|
|
|
|
) != len(self.sub_tasks):
|
|
|
|
|
self.sub_gt_implementations = None
|
2024-07-16 20:35:42 +08:00
|
|
|
logger.warning(
|
2024-07-02 17:58:37 +08:00
|
|
|
"The length of sub_gt_implementations is not equal to the length of sub_tasks, set sub_gt_implementations to None",
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
self.sub_gt_implementations = sub_gt_implementations
|
2024-09-26 17:54:45 +08:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def from_experiment(cls, exp: FactorExperiment) -> "FactorExperiment":
|
|
|
|
|
ei = cls(sub_tasks=exp.sub_tasks)
|
|
|
|
|
ei.based_experiments = exp.based_experiments
|
|
|
|
|
ei.experiment_workspace = exp.experiment_workspace
|
|
|
|
|
return ei
|