Skip to content

Conversation

SAKURA-CAT
Copy link
Member

This pull request introduces improvements to the HTTP handling and error management in the swanlab API, including enhanced type annotations, better error handling for specific cases, and the addition of a new utility function. The most important changes are grouped below:

HTTP Handling Enhancements:

  • Updated the post method in swanlab/api/http.py to accept both dictionaries and lists as valid types for the data parameter, improving flexibility in HTTP requests. ([swanlab/api/http.pyL179-R179](https://github.com/SwanHubX/SwanLab/pull/985/files#diff-59d6f0332f63c34567b4c6ad36216611d1ec51e7a6f6fc991c360a2736b3f4ecL179-R179))

Error Handling Improvements:

  • Enhanced the upload_columns function in swanlab/api/upload/__init__.py to handle ApiError exceptions. Specifically, it now logs a warning and skips uploading columns if the resource is disabled (HTTP 404 with a specific error code). ([swanlab/api/upload/__init__.pyR113-R122](https://github.com/SwanHubX/SwanLab/pull/985/files#diff-7eef39be6eb534f3b784e5d8b8a0ea5882cc017cdc756d4c3ccfb01dde50ec9fR113-R122))

Codebase Organization:

  • Added imports for decode_response and ApiError in swanlab/api/upload/__init__.py to support the new error handling logic. ([swanlab/api/upload/__init__.pyL14-R15](https://github.com/SwanHubX/SwanLab/pull/985/files#diff-7eef39be6eb534f3b784e5d8b8a0ea5882cc017cdc756d4c3ccfb01dde50ec9fL14-R15))

We found that deleting an experiment while it is running causes duplicate error requests from the SDK, hence submitting this PR to fix the issue.

@SAKURA-CAT SAKURA-CAT requested review from Zeyi-Lin and Copilot May 16, 2025 07:59
@SAKURA-CAT SAKURA-CAT self-assigned this May 16, 2025
@SAKURA-CAT SAKURA-CAT added the 🐛 bug Something isn't working label May 16, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request improves error management and HTTP handling in the swanlab API by enhancing type annotations, refining error handling for missing experiments, and adding necessary imports.

  • Updated the post method in swanlab/api/http.py to accept both dictionaries and lists.
  • Wrapped the HTTP request in upload_columns with a try-except block to log and skip uploading columns when the experiment is deleted (HTTP 404 with a specific error code).
  • Added new imports for decode_response and ApiError to support the updated error handling.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
swanlab/api/upload/init.py Enhanced error handling to log a warning and skip column upload on experiment deletion.
swanlab/api/http.py Modified the post method to allow dict or list for the data parameter.

@SAKURA-CAT SAKURA-CAT merged commit dfd039e into main May 18, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the fix/upload-column-404 branch May 18, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants