fix: resend request when experiment does not exist #985
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
post
method inswanlab/api/http.py
to accept both dictionaries and lists as valid types for thedata
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:
upload_columns
function inswanlab/api/upload/__init__.py
to handleApiError
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:
decode_response
andApiError
inswanlab/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.