fix: qlib and other scenario bugs (#636)

* fix qlib and other scenario bugs

* bug fix
This commit is contained in:
Xu Yang
2025-02-25 12:06:07 +08:00
committed by GitHub
parent 54cd73eb85
commit f120341c9c
5 changed files with 18 additions and 12 deletions
@@ -117,7 +117,7 @@ class FactorFBWorkspace(FBWorkspace):
- The cached information will include a tuple with the following: (execution_feedback, executed_factor_value_dataframe, Optional[Exception])
"""
super().execute()
self.before_execute()
if self.file_dict is None or "factor.py" not in self.file_dict:
if self.raise_exception:
raise CodeFormatError(self.FB_CODE_NOT_SET)
@@ -97,7 +97,7 @@ class ModelFBWorkspace(FBWorkspace):
input_value: float = 1.0,
param_init_value: float = 1.0,
):
super().execute()
self.before_execute()
try:
qtde = QTDockerEnv() if self.target_task.version == 1 else KGDockerEnv()
qtde.prepare()
+2 -9
View File
@@ -48,16 +48,9 @@ class RunnerError(Exception):
# NOTE: it corresponds to the error of whole **project**
class FactorEmptyError(Exception):
"""
Exceptions raised when no factor is generated correctly
"""
FactorEmptyError = CoderError # Exceptions raised when no factor is generated correctly
class ModelEmptyError(Exception):
"""
Exceptions raised when no model is generated correctly
"""
ModelEmptyError = CoderError # Exceptions raised when no model is generated correctly
class KaggleError(Exception):
+7
View File
@@ -232,6 +232,13 @@ class FBWorkspace(Workspace):
shutil.rmtree(self.workspace_path, ignore_errors=True)
self.file_dict = {}
def before_execute(self) -> None:
"""
Before executing the code, we need to prepare the workspace and inject code into the workspace.
"""
self.prepare()
self.inject_files(**self.file_dict)
def execute(self, env: Env, entry: str) -> str:
"""
Before each execution, make sure to prepare and inject code.
+7 -1
View File
@@ -1,7 +1,13 @@
hypothesis_and_feedback: |-
{% for experiment, feedback in trace.hist[-10:] %}
Hypothesis {{ loop.index }}: {{ experiment.hypothesis }}
Corresponding Code (that leads to the difference in performance): {{experiment.sub_workspace_list[0].file_dict.get("model.py")}}
Corresponding Code (that leads to the difference in performance):
{% for workspace in experiment.sub_workspace_list %}
{% if workspace is not none %}
Workspace {{loop.index}}:
{{workspace.all_codes}}{% endif %}{% endfor %}
Observation on the result with the hypothesis: {{ feedback.observations }}
Feedback on the original hypothesis: {{ feedback.hypothesis_evaluation }}
New Feedback for Context (For you to agree or improve upon): {{ feedback.new_hypothesis }}