diff --git a/rdagent/app/kaggle/conf.py b/rdagent/app/kaggle/conf.py index 5af7325c..0a6059b8 100644 --- a/rdagent/app/kaggle/conf.py +++ b/rdagent/app/kaggle/conf.py @@ -57,5 +57,7 @@ class KaggleBasePropSetting(BasePropSetting): if_using_feature_selection: bool = False + auto_submit: bool = True + KAGGLE_IMPLEMENT_SETTING = KaggleBasePropSetting() diff --git a/rdagent/app/kaggle/loop.py b/rdagent/app/kaggle/loop.py index 11c75772..cfb72927 100644 --- a/rdagent/app/kaggle/loop.py +++ b/rdagent/app/kaggle/loop.py @@ -1,3 +1,4 @@ +import subprocess from collections import defaultdict from typing import Any @@ -79,6 +80,26 @@ class KaggleRDLoop(RDLoop): else: exp = self.model_runner.develop(prev_out["coding"]) logger.log_object(exp, tag="runner result") + + if KAGGLE_IMPLEMENT_SETTING.auto_submit: + csv_path = exp.experiment_workspace.workspace_path / "submission.csv" + try: + subprocess.run( + [ + "kaggle", + "competitions", + "submit", + "-f", + str(csv_path.absolute()), + "-m", + str(csv_path.parent.absolute()), + KAGGLE_IMPLEMENT_SETTING.competition, + ], + check=True, + ) + except subprocess.CalledProcessError as e: + logger.error(f"Auto submission failed: \n{e}") + return exp skip_loop_error = (ModelEmptyError, FactorEmptyError)