Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/competitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ kaggle competitions submit <COMPETITION> -f <FILE_NAME> -m <MESSAGE> [options]
* `-k, --kernel <KERNEL>`: Name of the kernel (notebook) to submit (for code competitions).
* `-v, --version <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:**

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions src/kaggle/api/kaggle_api_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand Down Expand Up @@ -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)
)
Expand All @@ -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.

Expand All @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/kaggle/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 = (
Expand Down
Loading