2025-01-17 22:53:05 +08:00
|
|
|
import fire
|
|
|
|
|
|
|
|
|
|
from rdagent.app.data_science.conf import DS_RD_SETTING
|
|
|
|
|
from rdagent.core.utils import import_class
|
|
|
|
|
from rdagent.log import rdagent_logger as logger
|
2025-05-28 11:14:37 +08:00
|
|
|
from rdagent.scenarios.data_science.loop import DataScienceRDLoop
|
2025-01-17 22:53:05 +08:00
|
|
|
|
|
|
|
|
|
2025-03-04 15:18:36 +08:00
|
|
|
def main(
|
2025-04-18 14:01:03 +08:00
|
|
|
path=None,
|
|
|
|
|
output_path=None,
|
|
|
|
|
step_n=None,
|
|
|
|
|
loop_n=None,
|
|
|
|
|
competition="bms-molecular-translation",
|
|
|
|
|
do_truncate=True,
|
|
|
|
|
timeout=None,
|
2025-04-24 18:22:51 +08:00
|
|
|
replace_timer=True,
|
2025-04-29 09:30:45 +08:00
|
|
|
exp_gen_cls: str | None = None,
|
2025-03-04 15:18:36 +08:00
|
|
|
):
|
2025-01-17 22:53:05 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
path :
|
2025-03-04 15:18:36 +08:00
|
|
|
path like `$LOG_PATH/__session__/1/0_propose`. It indicates that we restore the state that after finish the step 0 in loop 1
|
2025-02-21 16:46:58 +08:00
|
|
|
output_path :
|
|
|
|
|
path like `$LOG_PATH`. It indicates that where we want to save our session and log information.
|
2025-01-17 22:53:05 +08:00
|
|
|
step_n :
|
|
|
|
|
How many steps to run; if None, it will run forever until error or KeyboardInterrupt
|
2025-02-18 19:22:52 +08:00
|
|
|
loop_n :
|
|
|
|
|
How many loops to run; if None, it will run forever until error or KeyboardInterrupt
|
|
|
|
|
- if current loop is incomplete, it will be counted as the first loop for completion.
|
|
|
|
|
- if both step_n and loop_n are provided, the process will stop as soon as either condition is met.
|
2025-01-17 22:53:05 +08:00
|
|
|
competition :
|
2025-03-04 15:18:36 +08:00
|
|
|
do_truncate :
|
|
|
|
|
If set to True, the logger will truncate the future log messages by calling `logger.storage.truncate`.
|
2025-04-29 09:30:45 +08:00
|
|
|
replace_timer :
|
|
|
|
|
If session is loaded, should we replace the timer with session.timer
|
|
|
|
|
exp_gen_cls :
|
|
|
|
|
When we have different stages, we can replace the exp_gen with the new proposal
|
2025-01-17 22:53:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Auto R&D Evolving loop for models in a Kaggle scenario.
|
|
|
|
|
You can continue running session by
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
dotenv run -- python rdagent/app/data_science/loop.py [--competition titanic] $LOG_PATH/__session__/1/0_propose --step_n 1 # `step_n` is a optional parameter
|
|
|
|
|
rdagent kaggle --competition playground-series-s4e8 # You are encouraged to use this one.
|
|
|
|
|
"""
|
|
|
|
|
if competition is not None:
|
|
|
|
|
DS_RD_SETTING.competition = competition
|
|
|
|
|
|
2025-05-06 16:00:13 +08:00
|
|
|
if not DS_RD_SETTING.competition:
|
2025-01-17 22:53:05 +08:00
|
|
|
logger.error("Please specify competition name.")
|
2025-05-06 16:00:13 +08:00
|
|
|
|
2025-01-17 22:53:05 +08:00
|
|
|
if path is None:
|
|
|
|
|
kaggle_loop = DataScienceRDLoop(DS_RD_SETTING)
|
|
|
|
|
else:
|
2025-04-24 18:22:51 +08:00
|
|
|
kaggle_loop = DataScienceRDLoop.load(path, output_path, do_truncate, replace_timer)
|
2025-04-29 09:30:45 +08:00
|
|
|
|
|
|
|
|
# replace exp_gen if we have new class
|
|
|
|
|
if exp_gen_cls is not None:
|
|
|
|
|
kaggle_loop.exp_gen = import_class(exp_gen_cls)(kaggle_loop.exp_gen.scen)
|
|
|
|
|
|
2025-04-18 14:01:03 +08:00
|
|
|
kaggle_loop.run(step_n=step_n, loop_n=loop_n, all_duration=timeout)
|
2025-01-17 22:53:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
fire.Fire(main)
|