mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-02 18:07:43 +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
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
import shutil
|
|
import uuid
|
|
from pathlib import Path
|
|
|
|
import pandas as pd
|
|
|
|
from rdagent.components.coder.model_coder.model import ModelExperiment, ModelFBWorkspace
|
|
from rdagent.components.runner import CachedRunner
|
|
from rdagent.components.runner.conf import RUNNER_SETTINGS
|
|
from rdagent.core.developer import Developer
|
|
from rdagent.core.exception import ModelEmptyException
|
|
from rdagent.log import rdagent_logger as logger
|
|
from rdagent.scenarios.qlib.experiment.model_experiment import QlibModelExperiment
|
|
from rdagent.utils.env import QTDockerEnv
|
|
|
|
|
|
class QlibModelRunner(CachedRunner[QlibModelExperiment]):
|
|
"""
|
|
Docker run
|
|
Everything in a folder
|
|
- config.yaml
|
|
- Pytorch `model.py`
|
|
- results in `mlflow`
|
|
|
|
https://github.com/microsoft/qlib/blob/main/qlib/contrib/model/pytorch_nn.py
|
|
- pt_model_uri: hard-code `model.py:Net` in the config
|
|
- let LLM modify model.py
|
|
"""
|
|
|
|
def develop(self, exp: QlibModelExperiment) -> QlibModelExperiment:
|
|
if RUNNER_SETTINGS.cache_result:
|
|
cache_hit, result = self.get_cache_result(exp)
|
|
if cache_hit:
|
|
exp.result = result
|
|
return exp
|
|
|
|
if exp.sub_workspace_list[0].code_dict.get("model.py") is None:
|
|
raise ModelEmptyException("model.py is empty")
|
|
# to replace & inject code
|
|
exp.experiment_workspace.inject_code(**{"model.py": exp.sub_workspace_list[0].code_dict["model.py"]})
|
|
|
|
env_to_use = {"PYTHONPATH": "./"}
|
|
|
|
if exp.sub_tasks[0].model_type == "TimeSeries":
|
|
env_to_use.update({"dataset_cls": "TSDatasetH", "step_len": 20, "num_timesteps": 20})
|
|
elif exp.sub_tasks[0].model_type == "Tabular":
|
|
env_to_use.update({"dataset_cls": "DatasetH"})
|
|
|
|
result = exp.experiment_workspace.execute(qlib_config_name="conf.yaml", run_env=env_to_use)
|
|
|
|
exp.result = result
|
|
if RUNNER_SETTINGS.cache_result:
|
|
self.dump_cache_result(exp, result)
|
|
|
|
return exp
|