From 513328d9b85a74beca998a90badc900ec163ec15 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Fri, 27 Feb 2026 19:40:21 +0000 Subject: [PATCH] Add `--sandbox` flag to competition submit command http://b/488368674 --- CHANGELOG.md | 4 ++++ docs/competitions.md | 1 + pyproject.toml | 2 +- src/kaggle/api/kaggle_api_extended.py | 9 +++++++-- src/kaggle/cli.py | 4 ++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c8f3d1..f8f53765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ==== +### Next + +* Add `--sandbox` flag to `kaggle competitions submit` for sandbox submissions (competition hosts/admins only) + ### 2.0.0 * General Availability release diff --git a/docs/competitions.md b/docs/competitions.md index ad516cfe..d346f53e 100644 --- a/docs/competitions.md +++ b/docs/competitions.md @@ -131,6 +131,7 @@ kaggle competitions submit -f -m [options] * `-k, --kernel `: Name of the kernel (notebook) to submit (for code competitions). * `-v, --version `: Version of the kernel to submit (e.g. `2`). * `-q, --quiet`: Suppress verbose output. +* `--sandbox`: Mark submission as a sandbox submission (competition hosts/admins only). **Example: Standard (not code) competition:** diff --git a/pyproject.toml b/pyproject.toml index 50c56f99..2ffc61db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ keywords = ["Kaggle", "API"] requires-python = ">= 3.11" dependencies = [ "bleach", - "kagglesdk >= 0.1.15, < 1.0", # sync with kagglehub + "kagglesdk >= 0.1.16, < 1.0", # sync with kagglehub "python-slugify", "requests", "python-dateutil", diff --git a/src/kaggle/api/kaggle_api_extended.py b/src/kaggle/api/kaggle_api_extended.py index be9cd174..26b19024 100644 --- a/src/kaggle/api/kaggle_api_extended.py +++ b/src/kaggle/api/kaggle_api_extended.py @@ -1306,7 +1306,7 @@ def competition_submit_code( return submit_response def competition_submit( - self, file_name: str, message: str, competition: str, quiet: bool = False + self, file_name: str, message: str, competition: str, quiet: bool = False, sandbox: bool = False ) -> ApiCreateSubmissionResponse: """Submits to a competition. @@ -1315,6 +1315,7 @@ def competition_submit( message (str): The submission description. competition (str): The competition name. quiet (bool): Suppress verbose output (default is False). + sandbox (bool): Mark as a sandbox submission (default is False). Returns: ApiCreateSubmissionResponse: @@ -1355,6 +1356,8 @@ def competition_submit( submit_request.blob_file_tokens = response.token if message: submit_request.submission_description = message + if sandbox: + submit_request.sandbox = True submit_response: ApiCreateSubmissionResponse = ( kaggle.competitions.competition_api_client.create_submission(submit_request) ) @@ -1369,6 +1372,7 @@ def competition_submit_cli( version: Optional[str] = None, competition_opt: Optional[str] = None, quiet: bool = False, + sandbox: bool = False, ) -> str: """Submits a competition using the client. @@ -1380,6 +1384,7 @@ def competition_submit_cli( version (Optional[str]): The version of the kernel to submit to a code competition, e.g. '1'. competition_opt (Optional[str]): An alternative competition option provided by cli. quiet (bool): Suppress verbose output (default is False). + sandbox (bool): Mark as a sandbox submission (default is False). Returns: str: @@ -1394,7 +1399,7 @@ def competition_submit_cli( ) else: submit_result = self.competition_submit( - cast(str, file_name), cast(str, message), cast(str, competition), quiet + cast(str, file_name), cast(str, message), cast(str, competition), quiet, sandbox ) except RequestException as e: if e.response and e.response.status_code == 404: diff --git a/src/kaggle/cli.py b/src/kaggle/cli.py index 9e3d349f..87558529 100644 --- a/src/kaggle/cli.py +++ b/src/kaggle/cli.py @@ -210,6 +210,9 @@ def parse_competitions(subparsers) -> None: parser_competitions_submit_optional.add_argument( "-q", "--quiet", dest="quiet", action="store_true", help=Help.param_quiet ) + parser_competitions_submit_optional.add_argument( + "--sandbox", dest="sandbox", action="store_true", help=Help.param_sandbox + ) parser_competitions_submit._action_groups.append(parser_competitions_submit_optional) parser_competitions_submit.set_defaults(func=api.competition_submit_cli) @@ -1167,6 +1170,7 @@ class Help(object): param_wp = "Download files to current working path" param_proxy = "Proxy for HTTP requests" param_quiet = "Suppress printing information about the upload/download progress" + param_sandbox = "Mark submission as a sandbox submission (competition hosts/admins only)" param_public = "Create publicly (default is private)" param_keep_tabular = "Do not convert tabular files to CSV (default is to convert)" param_dir_mode = (