From e2995712bbdbea6754c6002ae10b1d8ff6c63412 Mon Sep 17 00:00:00 2001 From: porink0424 Date: Wed, 5 Jun 2024 15:26:40 +0900 Subject: [PATCH] Change remove_associated_artifact format: query param -> body param --- optuna_dashboard/_app.py | 6 +++--- optuna_dashboard/ts/axiosClient.ts | 8 +++++--- python_tests/test_api.py | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/optuna_dashboard/_app.py b/optuna_dashboard/_app.py index a60a5d81..bdbfb168 100644 --- a/optuna_dashboard/_app.py +++ b/optuna_dashboard/_app.py @@ -180,9 +180,9 @@ def create_app( @app.delete("/api/studies/") @json_api_view def delete_study(study_id: int) -> dict[str, Any]: - remove_associated_artifacts = ( - True if request.params.get("remove_associated_artifacts") == "true" else False - ) + data = request.json or {} + remove_associated_artifacts = data.get("remove_associated_artifacts", True) + if artifact_store is not None and remove_associated_artifacts: delete_all_artifacts(artifact_store, storage, study_id) diff --git a/optuna_dashboard/ts/axiosClient.ts b/optuna_dashboard/ts/axiosClient.ts index 7588ad80..bb2b811a 100644 --- a/optuna_dashboard/ts/axiosClient.ts +++ b/optuna_dashboard/ts/axiosClient.ts @@ -121,9 +121,11 @@ export class AxiosClient extends APIClient { removeAssociatedArtifacts: boolean ): Promise => this.axiosInstance - .delete( - `/api/studies/${studyId}?remove_associated_artifacts=${removeAssociatedArtifacts}` - ) + .delete(`/api/studies/${studyId}`, { + data: { + remove_associated_artifacts: removeAssociatedArtifacts, + }, + }) .then(() => { return }) diff --git a/python_tests/test_api.py b/python_tests/test_api.py index 6d6b960a..818e4465 100644 --- a/python_tests/test_api.py +++ b/python_tests/test_api.py @@ -550,7 +550,7 @@ class APITestCase(TestCase): app, f"/api/studies/{study._study_id}", "DELETE", - queries={"remove_associated_artifacts": "true"}, + body=json.dumps({"remove_associated_artifacts": True}), content_type="application/json", ) self.assertEqual(status, 204) @@ -586,7 +586,7 @@ class APITestCase(TestCase): app, f"/api/studies/{study._study_id}", "DELETE", - queries={"remove_associated_artifacts": "false"}, + body=json.dumps({"remove_associated_artifacts": False}), content_type="application/json", ) self.assertEqual(status, 204)