mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-07 12:07:43 +00:00
Several update on the repo (see desc) (#76)
* ignore result csv file * fix app scripts * rename taskgenerator to developer and generate to develop * fix a config bug in coder * fix a small bug in factor coder evaluators * remove a single logger in factor coder evaluators * fix a small bug in model coder main.py * rename Implementation to Workspace * move the prepare the inject_code into FBWorkspace to align all the behavior * fix a small bug in model feedback * remove debug lines for multi processing and simplify evaluators multi proc * add a copy function to workspace to freeze the workspace && add config prefix to speed up debugging * make hypothesisgen a abc class * use Qlib***Experiment * fix a small bug * rename Imp to Ws * rename sub_implementations to sub_workspace_list * fix a bug in feedback not presented as content in prompts * move proposal pys to proposal folder * reformat the folder * align factor and model qlib workspace and use template to handle the workspace * add a filter to evoagent to filter out false evo * align multi_proc_n into RDAGENT seeting * handle when runner gets empty experiment * fix logger merge remaining problems * fix black and isort automatically
This commit is contained in:
@@ -15,10 +15,11 @@ from rdagent.components.coder.factor_coder.CoSTEER.evaluators import (
|
||||
FactorRowCountEvaluator,
|
||||
FactorSingleColumnEvaluator,
|
||||
)
|
||||
from rdagent.components.coder.factor_coder.factor import FileBasedFactorImplementation
|
||||
from rdagent.core.exception import ImplementRunException
|
||||
from rdagent.core.experiment import Implementation, Task
|
||||
from rdagent.core.task_generator import TaskGenerator
|
||||
from rdagent.components.coder.factor_coder.factor import FactorFBWorkspace
|
||||
from rdagent.core.conf import RD_AGENT_SETTINGS
|
||||
from rdagent.core.developer import Developer
|
||||
from rdagent.core.exception import CoderException
|
||||
from rdagent.core.experiment import Task, Workspace
|
||||
from rdagent.core.utils import multiprocessing_wrapper
|
||||
|
||||
|
||||
@@ -26,7 +27,7 @@ class TestCase:
|
||||
def __init__(
|
||||
self,
|
||||
target_task: list[Task] = [],
|
||||
ground_truth: list[Implementation] = [],
|
||||
ground_truth: list[Workspace] = [],
|
||||
):
|
||||
self.ground_truth = ground_truth
|
||||
self.target_task = target_task
|
||||
@@ -41,7 +42,7 @@ class BaseEval:
|
||||
self,
|
||||
evaluator_l: List[FactorEvaluator],
|
||||
test_cases: List[TestCase],
|
||||
generate_method: TaskGenerator,
|
||||
generate_method: Developer,
|
||||
catch_eval_except: bool = True,
|
||||
):
|
||||
"""Parameters
|
||||
@@ -62,12 +63,12 @@ class BaseEval:
|
||||
self,
|
||||
path: Union[Path, str],
|
||||
**kwargs,
|
||||
) -> List[Implementation]:
|
||||
) -> List[Workspace]:
|
||||
path = Path(path)
|
||||
fi_l = []
|
||||
for tc in self.test_cases:
|
||||
try:
|
||||
fi = FileBasedFactorImplementation.from_folder(tc.task, path, **kwargs)
|
||||
fi = FactorFBWorkspace.from_folder(tc.task, path, **kwargs)
|
||||
fi_l.append(fi)
|
||||
except FileNotFoundError:
|
||||
print("Fail to load test case for factor: ", tc.task.factor_name)
|
||||
@@ -75,8 +76,8 @@ class BaseEval:
|
||||
|
||||
def eval_case(
|
||||
self,
|
||||
case_gt: Implementation,
|
||||
case_gen: Implementation,
|
||||
case_gt: Workspace,
|
||||
case_gen: Workspace,
|
||||
) -> List[Union[Tuple[FactorEvaluator, object], Exception]]:
|
||||
"""Parameters
|
||||
----------
|
||||
@@ -96,7 +97,7 @@ class BaseEval:
|
||||
try:
|
||||
eval_res.append((ev, ev.evaluate(implementation=case_gen, gt_implementation=case_gt)))
|
||||
# if the corr ev is successfully evaluated and achieve the best performance, then break
|
||||
except ImplementRunException as e:
|
||||
except CoderException as e:
|
||||
return e
|
||||
except Exception as e:
|
||||
# exception when evaluation
|
||||
@@ -111,7 +112,7 @@ class FactorImplementEval(BaseEval):
|
||||
def __init__(
|
||||
self,
|
||||
test_cases: TestCase,
|
||||
method: TaskGenerator,
|
||||
method: Developer,
|
||||
*args,
|
||||
test_round: int = 10,
|
||||
**kwargs,
|
||||
@@ -137,17 +138,17 @@ class FactorImplementEval(BaseEval):
|
||||
print(f"Eval {_}-th times...")
|
||||
print("========================================================\n")
|
||||
try:
|
||||
gen_factor_l = self.generate_method.generate(self.test_cases.target_task)
|
||||
gen_factor_l = self.generate_method.develop(self.test_cases.target_task)
|
||||
except KeyboardInterrupt:
|
||||
# TODO: Why still need to save result after KeyboardInterrupt?
|
||||
print("Manually interrupted the evaluation. Saving existing results")
|
||||
break
|
||||
|
||||
if len(gen_factor_l.sub_implementations) != len(self.test_cases.ground_truth):
|
||||
if len(gen_factor_l.sub_workspace_list) != len(self.test_cases.ground_truth):
|
||||
raise ValueError(
|
||||
"The number of cases to eval should be equal to the number of test cases.",
|
||||
)
|
||||
gen_factor_l_all_rounds.extend(gen_factor_l.sub_implementations)
|
||||
gen_factor_l_all_rounds.extend(gen_factor_l.sub_workspace_list)
|
||||
test_cases_all_rounds.extend(self.test_cases.ground_truth)
|
||||
|
||||
eval_res_list = multiprocessing_wrapper(
|
||||
@@ -155,7 +156,7 @@ class FactorImplementEval(BaseEval):
|
||||
(self.eval_case, (gt_case, gen_factor))
|
||||
for gt_case, gen_factor in zip(test_cases_all_rounds, gen_factor_l_all_rounds)
|
||||
],
|
||||
n=FACTOR_IMPLEMENT_SETTINGS.evo_multi_proc_n,
|
||||
n=RD_AGENT_SETTINGS.multi_proc_n,
|
||||
)
|
||||
|
||||
for gt_case, eval_res, gen_factor in tqdm(zip(test_cases_all_rounds, eval_res_list, gen_factor_l_all_rounds)):
|
||||
|
||||
Reference in New Issue
Block a user