From 918e1084d4b2108bfa61ae553772dae16b82b79d Mon Sep 17 00:00:00 2001 From: Kostis-S-Z Date: Tue, 20 Oct 2026 10:11:59 +0300 Subject: [PATCH 1/2] Add logs to delete_submission --- docs/upload.md | 2 +- src/datacollective/submissions.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/upload.md b/docs/upload.md index 3e70947..092364e 100644 --- a/docs/upload.md +++ b/docs/upload.md @@ -398,7 +398,7 @@ A submission that has not been published can be deleted, together with every fil ```python from datacollective import delete_submission -delete_submission(submission_id="your-submission-id") +delete_submission(submission_id="your-submission-id", enable_logging=True) ``` Deleting a published submission, or one that belongs to another organization, raises `PermissionError`. diff --git a/src/datacollective/submissions.py b/src/datacollective/submissions.py index e049060..c1623c5 100644 --- a/src/datacollective/submissions.py +++ b/src/datacollective/submissions.py @@ -206,13 +206,14 @@ def create_submission_with_upload( return response -def delete_submission(submission_id: str) -> None: +def delete_submission(submission_id: str, enable_logging: bool = False) -> None: """ Delete a dataset submission that has not been published, and every file uploaded for it. WARNING: The deletion cannot be undone! Args: submission_id: Dataset submission ID. + enable_logging: Whether to enable SDK logging to console and a local log file. Raises: ValueError: If submission_id is empty. @@ -226,6 +227,14 @@ def delete_submission(submission_id: str) -> None: if not submission_id or not submission_id.strip(): raise ValueError("`submission_id` must be a non-empty string") + _enable_logging(enable_logging) + url = f"{_get_api_url()}/submissions/{submission_id}" - # 204 No Content: there is no body to return. - _send_api_request("DELETE", url) + logger.info(f"Deleting submission {submission_id}...") + try: + # 204 No Content: there is no body to return. + _send_api_request("DELETE", url) + except Exception as exc: + logger.error(f"Failed to delete submission {submission_id}: {exc}") + raise + logger.info(f"Submission {submission_id} deleted.") From 39ae43e14b1e6ee21e66399e6a21ba99c4aebb60 Mon Sep 17 00:00:00 2001 From: Kostis-S-Z Date: Tue, 20 Oct 2026 10:12:58 +0300 Subject: [PATCH 2/2] Update demo --- docs/demo_upload.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/demo_upload.py b/docs/demo_upload.py index 5b2c5cb..bb938ca 100644 --- a/docs/demo_upload.py +++ b/docs/demo_upload.py @@ -4,6 +4,7 @@ Task, Visibility, create_submission_with_upload, + delete_submission, ) submission = DatasetSubmission( @@ -53,3 +54,6 @@ ) print(response) + +# Completely remove the submission +delete_submission(response["submission"]["id"], enable_logging=True)