feat: auto submit result after one kaggle RDLoop (#345)

* auto submit when a loop end

* fix CI
This commit is contained in:
XianBW
2024-09-26 09:41:14 +08:00
committed by GitHub
parent 4b639452af
commit 43e24cc996
2 changed files with 23 additions and 0 deletions
+2
View File
@@ -57,5 +57,7 @@ class KaggleBasePropSetting(BasePropSetting):
if_using_feature_selection: bool = False
auto_submit: bool = True
KAGGLE_IMPLEMENT_SETTING = KaggleBasePropSetting()
+21
View File
@@ -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)