Skip to content

Commit

Permalink
fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
WinstonLiyt committed Dec 25, 2024
1 parent de2825f commit 9a4ba5f
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 19 deletions.
4 changes: 2 additions & 2 deletions rdagent/app/data_science/loop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path
from typing import Any

from pathlib import Path
import fire

from rdagent.app.data_science.conf import DS_RD_SETTING
Expand Down Expand Up @@ -100,7 +100,7 @@ def feedback(self, prev_out: dict[str, Any]):
self.trace.hist.append((prev_out["direct_exp_gen"].hypothesis, prev_out["running"], feedback))


def main(path=None, step_n=None, competition=None):
def main(path=None, step_n=None, competition="bms-molecular-translation"):
"""
Auto R&D Evolving loop for models in a kaggle{} scenario.
You can continue running session by
Expand Down
5 changes: 3 additions & 2 deletions rdagent/components/coder/CoSTEER/evolving_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rdagent.core.evolving_framework import EvolvableSubjects
from rdagent.core.exception import CoderError


class FilterFailedRAGEvoAgent(RAGEvoAgent):
def filter_evolvable_subjects_by_feedback(
self, evo: EvolvableSubjects, feedback: CoSTEERSingleFeedbackDeprecated
Expand All @@ -15,8 +16,8 @@ def filter_evolvable_subjects_by_feedback(
for index in range(len(evo.sub_workspace_list)):
if evo.sub_workspace_list[index] is not None and feedback[index] and not feedback[index].final_decision:
evo.sub_workspace_list[index].clear()

if all(not f.final_decision for f in feedback if f):
raise CoderError("All feedbacks of sub tasks are negative.")

return evo
1 change: 0 additions & 1 deletion rdagent/components/coder/data_science/ensemble/exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
from rdagent.components.coder.CoSTEER.task import CoSTEERTask
from rdagent.core.utils import cache_with_pickle


EnsembleTask = CoSTEERTask
3 changes: 2 additions & 1 deletion rdagent/components/coder/data_science/feature/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def evaluate(
test_code = f.read()
implementation.inject_files(**{fname: test_code})
stdout = implementation.execute(env=de, entry=f"python {fname}")

if stdout is None:
stdout = "The execution exceeded the time limit, and no stdout information has been generated yet."
system_prompt = T(".prompts:feature_eval.system").r(
test_code=test_code, code=implementation.file_dict["feat01.py"]
)
Expand Down
1 change: 0 additions & 1 deletion rdagent/components/coder/data_science/feature/exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
from rdagent.components.coder.CoSTEER.task import CoSTEERTask
from rdagent.core.utils import cache_with_pickle


FeatureTask = CoSTEERTask
2 changes: 2 additions & 0 deletions rdagent/components/coder/data_science/model/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def evaluate(
test_code = f.read()
implementation.inject_files(**{fname: test_code})
stdout = implementation.execute(env=de, entry=f"python {fname}")
if stdout is None:
stdout = "The execution exceeded the time limit, and no stdout information has been generated yet."
system_prompt = T(".prompts:model_eval.system").r(
test_code=test_code, scenario="No scenario information yet.", spec=implementation.file_dict["spec/model.md"]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def evaluate(
test_code = f.read()
implementation.inject_files(**{fname: test_code})
stdout = implementation.execute(env=de, entry=f"python {fname}")

if stdout is None:
stdout = "The execution exceeded the time limit, and no stdout information has been generated yet."
system_prompt = T(".prompts:data_loader_eval.system").r(
test_code=test_code, code=implementation.file_dict["load_data.py"]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
from rdagent.utils.agent.tpl import T
from rdagent.utils.env import DockerEnv, DSDockerConf


DataLoaderTask = CoSTEERTask
2 changes: 2 additions & 0 deletions rdagent/components/coder/data_science/workflow/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def evaluate(
de = DockerEnv(conf=ds_docker_conf)
fname = "main.py"
stdout = implementation.execute(env=de, entry=f"python {fname}")
if stdout is None:
stdout = "The execution exceeded the time limit, and no stdout information has been generated yet."
system_prompt = T(".prompts:workflow_eval.system").r(
scenario="No scenario information yet.", spec=implementation.file_dict["spec/workflow.md"]
)
Expand Down
3 changes: 1 addition & 2 deletions rdagent/components/coder/data_science/workflow/exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
from rdagent.components.coder.CoSTEER.task import CoSTEERTask
from rdagent.core.utils import cache_with_pickle


WorkflowTask = CoSTEERTask
WorkflowTask = CoSTEERTask
1 change: 1 addition & 0 deletions rdagent/core/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_task_information(self) -> str:
def __repr__(self) -> str:
return f"<{self.__class__.__name__} {self.name}>"


ASpecificTask = TypeVar("ASpecificTask", bound=Task)


Expand Down
2 changes: 1 addition & 1 deletion rdagent/log/logger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import os
import sys
import pickle
import sys
from contextlib import contextmanager
from datetime import datetime, timezone
from functools import partial
Expand Down
2 changes: 1 addition & 1 deletion rdagent/scenarios/data_science/scen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .scen import DataScienceScen
from .kaggle import KaggleScen
from .scen import DataScienceScen

__all__ = ["DataScienceScen", "KaggleScen"]
2 changes: 1 addition & 1 deletion rdagent/scenarios/data_science/scen/kaggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class KaggleScen(DataScienceScen):
But we found that too much scenario unrelated code in kaggle scenario and hard to reuse.
So we start from a simple one....
"""

def _get_description(self):
return crawl_descriptions(self.competition, DS_RD_SETTING.local_data_path)

Expand All @@ -32,4 +33,3 @@ def rich_style_description(self) -> str:
name="Kaggle",
competition=f"[{self.competition}](https://www.kaggle.com/competitions/{self.competition})",
)

9 changes: 5 additions & 4 deletions rdagent/scenarios/data_science/scen/scen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

from rdagent.app.data_science.conf import DS_RD_SETTING
from rdagent.core.scenario import Scenario
from rdagent.log import rdagent_logger as logger
from rdagent.oai.llm_utils import APIBackend
from rdagent.utils.agent.tpl import T
from rdagent.log import rdagent_logger as logger


class DataScienceScen(Scenario):
"""Data Science Scenario
"""
"""Data Science Scenario"""

def __init__(self, competition: str) -> None:
self.competition = competition
Expand All @@ -24,7 +23,9 @@ def _get_description(self):
with fp.open("r") as f:
return json.load(f)
else:
logger.error(f"Cannot find {self.competition}.json in {DS_RD_SETTING.local_data_path}, please check the file.")
logger.error(
f"Cannot find {self.competition}.json in {DS_RD_SETTING.local_data_path}, please check the file."
)

def _get_direction(self):
return self.raw_description.get("metric_direction", "minimize")
Expand Down
8 changes: 7 additions & 1 deletion test/utils/coder/test_CoSTEER.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest


class CoSTEERTest(unittest.TestCase):

def setUp(self):
Expand All @@ -23,26 +24,31 @@ def test_feature(self):
from rdagent.components.coder.data_science.feature.test import (
develop_one_competition,
)

exp = develop_one_competition(self.test_competition)

def test_model(self):
from rdagent.components.coder.data_science.model.test import (
develop_one_competition,
)

exp = develop_one_competition(self.test_competition)

def test_ensemble(self):
from rdagent.components.coder.data_science.ensemble.test import (
develop_one_competition,
)

exp = develop_one_competition(self.test_competition)

def test_workflow(self):
from rdagent.components.coder.data_science.workflow.test import (
develop_one_competition,
)

exp = develop_one_competition(self.test_competition)


if __name__ == "__main__":
unittest.main()
# pytest test/utils/coder/test_CoSTEER.py

0 comments on commit 9a4ba5f

Please sign in to comment.