From 43e24cc99684e82292ec5d86e526f4cc34b885e5 Mon Sep 17 00:00:00 2001 From: XianBW <36835909+XianBW@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:41:14 +0800 Subject: [PATCH] feat: auto submit result after one kaggle RDLoop (#345) * auto submit when a loop end * fix CI --- rdagent/app/kaggle/conf.py | 2 ++ rdagent/app/kaggle/loop.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) 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)