mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-28 07:57:44 +00:00
e0a24fb46f
* ignore result csv file * fix app scripts * rename taskgenerator to developer and generate to develop * fix a config bug in coder * fix a small bug in factor coder evaluators * remove a single logger in factor coder evaluators * fix a small bug in model coder main.py * rename Implementation to Workspace * move the prepare the inject_code into FBWorkspace to align all the behavior * fix a small bug in model feedback * remove debug lines for multi processing and simplify evaluators multi proc * add a copy function to workspace to freeze the workspace && add config prefix to speed up debugging * make hypothesisgen a abc class * use Qlib***Experiment * fix a small bug * rename Imp to Ws * rename sub_implementations to sub_workspace_list * fix a bug in feedback not presented as content in prompts * move proposal pys to proposal folder * reformat the folder * align factor and model qlib workspace and use template to handle the workspace * add a filter to evoagent to filter out false evo * align multi_proc_n into RDAGENT seeting * handle when runner gets empty experiment * fix logger merge remaining problems * fix black and isort automatically
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
import pickle
|
|
from pathlib import Path
|
|
from typing import Tuple
|
|
|
|
from rdagent.components.runner.conf import RUNNER_SETTINGS
|
|
from rdagent.core.developer import Developer
|
|
from rdagent.core.experiment import ASpecificExp, Experiment
|
|
from rdagent.oai.llm_utils import md5_hash
|
|
|
|
|
|
class CachedRunner(Developer[ASpecificExp]):
|
|
def get_cache_key(self, exp: Experiment) -> str:
|
|
all_tasks = []
|
|
for based_exp in exp.based_experiments:
|
|
all_tasks.extend(based_exp.sub_tasks)
|
|
all_tasks.extend(exp.sub_tasks)
|
|
task_info_list = [task.get_task_information() for task in all_tasks]
|
|
task_info_str = "\n".join(task_info_list)
|
|
return md5_hash(task_info_str)
|
|
|
|
def get_cache_result(self, exp: Experiment) -> Tuple[bool, object]:
|
|
task_info_key = self.get_cache_key(exp)
|
|
Path(RUNNER_SETTINGS.cache_path).mkdir(parents=True, exist_ok=True)
|
|
cache_path = Path(RUNNER_SETTINGS.cache_path) / f"{task_info_key}.pkl"
|
|
if cache_path.exists():
|
|
return True, pickle.load(open(cache_path, "rb"))
|
|
else:
|
|
return False, None
|
|
|
|
def dump_cache_result(self, exp: Experiment, result: object):
|
|
task_info_key = self.get_cache_key(exp)
|
|
cache_path = Path(RUNNER_SETTINGS.cache_path) / f"{task_info_key}.pkl"
|
|
pickle.dump(result, open(cache_path, "wb"))
|