Skip to content

Commit f120341

Browse files
authored
fix: qlib and other scenario bugs (microsoft#636)
* fix qlib and other scenario bugs * bug fix
1 parent 54cd73e commit f120341

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

rdagent/components/coder/factor_coder/factor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def execute(self, data_type: str = "Debug") -> Tuple[str, pd.DataFrame]:
117117
- The cached information will include a tuple with the following: (execution_feedback, executed_factor_value_dataframe, Optional[Exception])
118118
119119
"""
120-
super().execute()
120+
self.before_execute()
121121
if self.file_dict is None or "factor.py" not in self.file_dict:
122122
if self.raise_exception:
123123
raise CodeFormatError(self.FB_CODE_NOT_SET)

rdagent/components/coder/model_coder/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def execute(
9797
input_value: float = 1.0,
9898
param_init_value: float = 1.0,
9999
):
100-
super().execute()
100+
self.before_execute()
101101
try:
102102
qtde = QTDockerEnv() if self.target_task.version == 1 else KGDockerEnv()
103103
qtde.prepare()

rdagent/core/exception.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,9 @@ class RunnerError(Exception):
4848
# NOTE: it corresponds to the error of whole **project**
4949

5050

51-
class FactorEmptyError(Exception):
52-
"""
53-
Exceptions raised when no factor is generated correctly
54-
"""
55-
51+
FactorEmptyError = CoderError # Exceptions raised when no factor is generated correctly
5652

57-
class ModelEmptyError(Exception):
58-
"""
59-
Exceptions raised when no model is generated correctly
60-
"""
53+
ModelEmptyError = CoderError # Exceptions raised when no model is generated correctly
6154

6255

6356
class KaggleError(Exception):

rdagent/core/experiment.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ def clear(self) -> None:
232232
shutil.rmtree(self.workspace_path, ignore_errors=True)
233233
self.file_dict = {}
234234

235+
def before_execute(self) -> None:
236+
"""
237+
Before executing the code, we need to prepare the workspace and inject code into the workspace.
238+
"""
239+
self.prepare()
240+
self.inject_files(**self.file_dict)
241+
235242
def execute(self, env: Env, entry: str) -> str:
236243
"""
237244
Before each execution, make sure to prepare and inject code.

rdagent/scenarios/qlib/prompts.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
hypothesis_and_feedback: |-
22
{% for experiment, feedback in trace.hist[-10:] %}
33
Hypothesis {{ loop.index }}: {{ experiment.hypothesis }}
4-
Corresponding Code (that leads to the difference in performance): {{experiment.sub_workspace_list[0].file_dict.get("model.py")}}
4+
5+
Corresponding Code (that leads to the difference in performance):
6+
{% for workspace in experiment.sub_workspace_list %}
7+
{% if workspace is not none %}
8+
Workspace {{loop.index}}:
9+
{{workspace.all_codes}}{% endif %}{% endfor %}
10+
511
Observation on the result with the hypothesis: {{ feedback.observations }}
612
Feedback on the original hypothesis: {{ feedback.hypothesis_evaluation }}
713
New Feedback for Context (For you to agree or improve upon): {{ feedback.new_hypothesis }}

0 commit comments

Comments
 (0)