mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-28 16:07:46 +00:00
20778a9b87
* use conda to run kaggle and mlebench code * refactor: Simplify environment configuration and execution logic * add setting to use local env in ds * refine dockerfile * fix: Move MLEBDockerEnv initialization inside conditionals & fix condaenv * refactor: reformat code for better readability and consistency * feat: add conda env to all envs. * fix: fix bugs when run loop * refactor: Simplify DockerEnv configuration in mle_summary.py * fix image bug * style: reformat code for better readability and consistency * change commit * feat: Add entrypoint script for sing_docker scenario in rdagent * refactor: add Any type hints and comments for clarity in env.py * feat: Create log directory if it doesn't exist in entrypoint script * feat: Add debug mode and list root directory in entrypoint script * fix: Remove specific branch checkout in Dockerfile for RD-Agent * fix: Add competition argument to loop.py script execution * fix: Correct directory navigation and dependency installation in entrypoint.sh * fix: Correct user ownership assignment in entrypoint script * refactor: Comment out redundant log copying to RD_OUTPUT_DIR * fix: Unset LOG_TRACE_PATH to prevent log contamination in entrypoint.sh --------- Co-authored-by: Xu Yang <peteryang@vip.qq.com>
76 lines
3.0 KiB
Python
76 lines
3.0 KiB
Python
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
from rdagent.app.data_science.conf import DS_RD_SETTING
|
|
from rdagent.components.coder.CoSTEER.evaluators import (
|
|
CoSTEEREvaluator,
|
|
CoSTEERSingleFeedback,
|
|
)
|
|
from rdagent.components.coder.data_science.conf import get_ds_env
|
|
from rdagent.core.evolving_framework import QueriedKnowledge
|
|
from rdagent.core.experiment import FBWorkspace, Task
|
|
from rdagent.utils.agent.tpl import T
|
|
from rdagent.utils.agent.workflow import build_cls_from_json_with_retry
|
|
from rdagent.utils.fmt import shrink_text
|
|
|
|
DIRNAME = Path(__file__).absolute().resolve().parent
|
|
|
|
FeatureEvalFeedback = CoSTEERSingleFeedback
|
|
|
|
|
|
class FeatureCoSTEEREvaluator(CoSTEEREvaluator):
|
|
|
|
def evaluate(
|
|
self,
|
|
target_task: Task,
|
|
implementation: FBWorkspace,
|
|
gt_implementation: FBWorkspace,
|
|
queried_knowledge: QueriedKnowledge = None,
|
|
**kwargs,
|
|
) -> FeatureEvalFeedback:
|
|
|
|
target_task_information = target_task.get_task_information()
|
|
if (
|
|
queried_knowledge is not None
|
|
and target_task_information in queried_knowledge.success_task_to_knowledge_dict
|
|
):
|
|
return queried_knowledge.success_task_to_knowledge_dict[target_task_information].feedback
|
|
elif queried_knowledge is not None and target_task_information in queried_knowledge.failed_task_info_set:
|
|
return FeatureEvalFeedback(
|
|
execution="This task has failed too many times, skip implementation.",
|
|
return_checking="This task has failed too many times, skip implementation.",
|
|
code="This task has failed too many times, skip implementation.",
|
|
final_decision=False,
|
|
)
|
|
|
|
env = get_ds_env()
|
|
env.conf.extra_volumes = {f"{DS_RD_SETTING.local_data_path}/sample/{self.scen.competition}": "/kaggle/input"}
|
|
|
|
# TODO: do we need to clean the generated temporary content?
|
|
fname = "test/feature_test.py"
|
|
test_code = (DIRNAME / "eval_tests" / "feature_test.txt").read_text()
|
|
implementation.inject_files(**{fname: test_code})
|
|
|
|
stdout = implementation.execute(env=env, entry=f"python {fname}")
|
|
|
|
if "main.py" in implementation.file_dict:
|
|
workflow_stdout = implementation.execute(env=env, entry="python main.py")
|
|
workflow_stdout = re.sub(r"=== Start of EDA part ===(.*)=== End of EDA part ===", "", workflow_stdout)
|
|
else:
|
|
workflow_stdout = None
|
|
|
|
system_prompt = T(".prompts:feature_eval.system").r(
|
|
task_desc=target_task.get_task_information(),
|
|
test_code=test_code,
|
|
code=implementation.file_dict["feature.py"],
|
|
workflow_stdout=workflow_stdout,
|
|
workflow_code=implementation.all_codes,
|
|
)
|
|
user_prompt = T(".prompts:feature_eval.user").r(
|
|
stdout=shrink_text(stdout),
|
|
workflow_stdout=workflow_stdout,
|
|
)
|
|
|
|
return build_cls_from_json_with_retry(FeatureEvalFeedback, system_prompt=system_prompt, user_prompt=user_prompt)
|