mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 23:47:46 +00:00
Support special step customization (#123)
* Support special step customization * lint
This commit is contained in:
@@ -2,16 +2,28 @@
|
||||
Factor workflow with session control
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
import fire
|
||||
|
||||
from rdagent.app.qlib_rd_loop.conf import FACTOR_PROP_SETTING
|
||||
from rdagent.components.workflow.rd_loop import RDLoop
|
||||
from rdagent.core.exception import FactorEmptyError
|
||||
from rdagent.log import rdagent_logger as logger
|
||||
|
||||
|
||||
class FactorRDLoop(RDLoop):
|
||||
skip_loop_error = (FactorEmptyError,)
|
||||
|
||||
def exp_gen(self, prev_out: dict[str, Any]):
|
||||
with logger.tag("r"): # research
|
||||
exp = self.hypothesis2experiment.convert(prev_out["propose"], self.trace)
|
||||
if exp is None:
|
||||
logger.error(f"Factor extraction failed.")
|
||||
raise FactorEmptyError("Factor extraction failed.")
|
||||
logger.log_object(exp.sub_tasks, tag="experiment generation")
|
||||
return exp
|
||||
|
||||
|
||||
def main(path=None, step_n=None):
|
||||
"""
|
||||
|
||||
@@ -35,7 +35,10 @@ class LoopMeta(type):
|
||||
steps = LoopMeta._get_steps(bases) # all the base classes of parents
|
||||
for name, attr in attrs.items():
|
||||
if not name.startswith("__") and isinstance(attr, Callable):
|
||||
steps.append(name)
|
||||
if name not in steps:
|
||||
# NOTE: if we override the step in the subclass
|
||||
# Then it is not the new step. So we skip it.
|
||||
steps.append(name)
|
||||
attrs["steps"] = steps
|
||||
return super().__new__(cls, clsname, bases, attrs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user