Fix ruff error1 (#81)

* fix_ruff_error1

* fix_ruff_error

* fix ruff error

* fix ruff error

* pass model.py

* rename exception class

* rename exception class

* rename func name generate_feedback

* remove prepare args

* optimize code

* optimize code

* fix code error
This commit is contained in:
Linlang
2024-07-18 22:36:04 +08:00
committed by GitHub
parent 74bc047615
commit ae2aa6e9b4
20 changed files with 121 additions and 94 deletions
@@ -11,9 +11,9 @@ from filelock import FileLock
from rdagent.components.coder.factor_coder.config import FACTOR_IMPLEMENT_SETTINGS
from rdagent.core.exception import (
CodeFormatException,
NoOutputException,
RuntimeErrorException,
CodeFormatError,
NoOutputError,
CustomRuntimeError,
)
from rdagent.core.experiment import Experiment, FBWorkspace, Task
from rdagent.log import rdagent_logger as logger
@@ -106,7 +106,7 @@ class FactorFBWorkspace(FBWorkspace):
super().execute()
if self.code_dict is None or "factor.py" not in self.code_dict:
if self.raise_exception:
raise CodeFormatException(self.FB_CODE_NOT_SET)
raise CodeFormatError(self.FB_CODE_NOT_SET)
else:
return self.FB_CODE_NOT_SET, None
with FileLock(self.workspace_path / "execution.lock"):
@@ -163,11 +163,11 @@ class FactorFBWorkspace(FBWorkspace):
execution_feedback[:1000] + "....hidden long error message...." + execution_feedback[-1000:]
)
if self.raise_exception:
raise RuntimeErrorException(execution_feedback)
raise CustomRuntimeError(execution_feedback)
except subprocess.TimeoutExpired:
execution_feedback += f"Execution timeout error and the timeout is set to {FACTOR_IMPLEMENT_SETTINGS.file_based_execution_timeout} seconds."
if self.raise_exception:
raise RuntimeErrorException(execution_feedback)
raise CustomRuntimeError(execution_feedback)
workspace_output_file_path = self.workspace_path / "result.h5"
if workspace_output_file_path.exists() and execution_success: