mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-28 16:07:46 +00:00
09be71d586
* refactor: split workflow into pkg, add WorkflowTracker & wait_retry * feat: add async LoopBase with parallel workers and step semaphores * fix: replace pickle with dill and run blocking tasks via joblib wrapper * feat: add log format settings, dynamic parallelism & pickle-based snapshot * fix: default step semaphore to 1 and avoid subprocess when single worker * merge bowen's changes * merge tim's changes * refactor: extract component task mapping, add conditional logger setup * lint * refactor: add type hints and safer remain_time metric logging in workflow * lint * fix: allow BadRequestError to be pickled via custom copyreg reducer * fix: stop loop when LoopTerminationError is raised in LoopBase * lint * refactor: make log tag context-local using ContextVar for thread safety * feat: add subproc_step flag and helper to decide subprocess execution * fix: use ./cache path and normalize relative volume bind paths * fix: reset loop_idx to 0 on loop restart/resume to ensure correct flow * fix: avoid chmod on cache and input dirs in Env timeout wrapper * fix: skip chmod on 'cache' and 'input' dirs using find -prune * fix: restrict chmod to immediate mount dirs excluding cache/input * fix: chmod cache and input dirs alongside their contents after entry run * fix: guard chmod with directory checks for cache and input * fix: prefix mount_path in chmod command for cache/input dirs * fix: drop quotes from find exclude patterns to ensure chmod executes * fix: skip chmod on cache/input directories to avoid warning spam * feat: support string volume mappings and poll subprocess stdout/stderr * support remove symbolic link * test: use dynamic home path and code volume in LocalEnv local_simple * fix: skip trace and progress update when loop step is withdrawn * refactor: add clean_workspace util and non-destructive workspace backup * fix: preserve symlinks when backing up workspace with copytree * fix: prevent AttributeError when _pbar not yet initialized in LoopBase * perf: replace shutil.copytree with rsync for faster workspace backup * fix: cast log directory Path to str in tar command of data science loop * fix: use portable 'cp -r -P' instead of rsync for workspace backup * fix: add retry and logging to workspace backup for robustness * refactor: extract backup_folder helper and reuse in DataScienceRDLoop * fix: propagate backup errors & default _pbar getattr to avoid error * fix the division by zero bug * refactor: execute RD loops via asyncio.run and add necessary imports * lint * lint * lint --------- Co-authored-by: Xu <v-xuminrui@microsoft.com>
75 lines
3.0 KiB
Python
75 lines
3.0 KiB
Python
import asyncio
|
|
from pathlib import Path
|
|
|
|
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
|
|
from rdagent.scenarios.data_science.loop import DataScienceRDLoop
|
|
|
|
|
|
def main(
|
|
path: str | None = None,
|
|
checkout: bool | str | Path = True,
|
|
step_n: int | None = None,
|
|
loop_n: int | None = None,
|
|
competition="bms-molecular-translation",
|
|
timeout=None,
|
|
replace_timer=True,
|
|
exp_gen_cls: str | None = None,
|
|
):
|
|
"""
|
|
|
|
Parameters
|
|
----------
|
|
path :
|
|
A path like `$LOG_PATH/__session__/1/0_propose`. This indicates that we restore the state after finishing step 0 in loop 1.
|
|
checkout :
|
|
Used only when a path is provided.
|
|
Can be True, False, or a path.
|
|
Default is True.
|
|
- If True, the new loop will use the existing folder and clear logs for sessions after the one corresponding to the given path.
|
|
- If False, the new loop will use the existing folder but keep the logs for sessions after the one corresponding to the given path.
|
|
- If a path (or a str like Path) is provided, the new loop will be saved to that path, leaving the original path unchanged.
|
|
step_n :
|
|
Number of steps to run; if None, the process will run indefinitely until an error or KeyboardInterrupt occurs.
|
|
loop_n :
|
|
Number of loops to run; if None, the process will run indefinitely until an error or KeyboardInterrupt occurs.
|
|
- If the 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.
|
|
competition :
|
|
Competition name.
|
|
replace_timer :
|
|
If a session is loaded, determines whether to replace the timer with session.timer.
|
|
exp_gen_cls :
|
|
When there are different stages, the exp_gen can be replaced with the new proposal.
|
|
|
|
|
|
Auto R&D Evolving loop for models in a Kaggle scenario.
|
|
You can continue running a session by using the command:
|
|
.. 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 an optional parameter
|
|
rdagent kaggle --competition playground-series-s4e8 # This command is recommended.
|
|
"""
|
|
if competition is not None:
|
|
DS_RD_SETTING.competition = competition
|
|
|
|
if not DS_RD_SETTING.competition:
|
|
logger.error("Please specify competition name.")
|
|
|
|
if path is None:
|
|
kaggle_loop = DataScienceRDLoop(DS_RD_SETTING)
|
|
else:
|
|
kaggle_loop: DataScienceRDLoop = DataScienceRDLoop.load(path, checkout=checkout, replace_timer=replace_timer)
|
|
|
|
# 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)
|
|
|
|
asyncio.run(kaggle_loop.run(step_n=step_n, loop_n=loop_n, all_duration=timeout))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
fire.Fire(main)
|