Skip to content

Commit 308e40d

Browse files
authored
Merge pull request galaxyproject#18732 from mvdbeek/drop_response_body_delete_datasets
Don't serialize view of item in delete/purge request
2 parents 8ebc13e + a1ecabd commit 308e40d

12 files changed

Lines changed: 58 additions & 124 deletions

File tree

client/src/api/schema/schema.ts

Lines changed: 27 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9924,30 +9924,6 @@ export interface components {
99249924
*/
99259925
stop_job: boolean;
99269926
};
9927-
/**
9928-
* DeleteHistoryContentResult
9929-
* @description Contains minimum information about the deletion state of a history item.
9930-
*
9931-
* Can also contain any other properties of the item.
9932-
*/
9933-
DeleteHistoryContentResult: {
9934-
/**
9935-
* Deleted
9936-
* @description True if the item was successfully deleted.
9937-
*/
9938-
deleted: boolean;
9939-
/**
9940-
* ID
9941-
* @description The encoded ID of the history item.
9942-
* @example 0123456789ABCDEF
9943-
*/
9944-
id: string;
9945-
/**
9946-
* Purged
9947-
* @description True if the item was successfully removed from disk.
9948-
*/
9949-
purged?: boolean | null;
9950-
};
99519927
/** DeleteHistoryPayload */
99529928
DeleteHistoryPayload: {
99539929
/**
@@ -24261,10 +24237,6 @@ export interface operations {
2426124237
* @description Whether to stop the creating job if all outputs of the job have been deleted.
2426224238
*/
2426324239
stop_job?: boolean | null;
24264-
/** @description View to be passed to the serializer */
24265-
view?: string | null;
24266-
/** @description Comma-separated list of keys to be passed to the serializer */
24267-
keys?: string | null;
2426824240
};
2426924241
header?: {
2427024242
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
@@ -24282,23 +24254,28 @@ export interface operations {
2428224254
};
2428324255
};
2428424256
responses: {
24285-
/** @description Request has been executed. */
24257+
/** @description Successful Response */
2428624258
200: {
2428724259
headers: {
2428824260
[name: string]: unknown;
2428924261
};
2429024262
content: {
24291-
"application/json": components["schemas"]["DeleteHistoryContentResult"];
24263+
"application/json": unknown;
2429224264
};
2429324265
};
2429424266
/** @description Request accepted, processing will finish later. */
2429524267
202: {
2429624268
headers: {
2429724269
[name: string]: unknown;
2429824270
};
24299-
content: {
24300-
"application/json": components["schemas"]["DeleteHistoryContentResult"];
24271+
content?: never;
24272+
};
24273+
/** @description Request has been executed. */
24274+
204: {
24275+
headers: {
24276+
[name: string]: unknown;
2430124277
};
24278+
content?: never;
2430224279
};
2430324280
/** @description Request Error */
2430424281
"4XX": {
@@ -30217,10 +30194,6 @@ export interface operations {
3021730194
* @description Whether to stop the creating job if all outputs of the job have been deleted.
3021830195
*/
3021930196
stop_job?: boolean | null;
30220-
/** @description View to be passed to the serializer */
30221-
view?: string | null;
30222-
/** @description Comma-separated list of keys to be passed to the serializer */
30223-
keys?: string | null;
3022430197
};
3022530198
header?: {
3022630199
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
@@ -30240,23 +30213,28 @@ export interface operations {
3024030213
};
3024130214
};
3024230215
responses: {
30243-
/** @description Request has been executed. */
30216+
/** @description Successful Response */
3024430217
200: {
3024530218
headers: {
3024630219
[name: string]: unknown;
3024730220
};
3024830221
content: {
30249-
"application/json": components["schemas"]["DeleteHistoryContentResult"];
30222+
"application/json": unknown;
3025030223
};
3025130224
};
3025230225
/** @description Request accepted, processing will finish later. */
3025330226
202: {
3025430227
headers: {
3025530228
[name: string]: unknown;
3025630229
};
30257-
content: {
30258-
"application/json": components["schemas"]["DeleteHistoryContentResult"];
30230+
content?: never;
30231+
};
30232+
/** @description Request has been executed. */
30233+
204: {
30234+
headers: {
30235+
[name: string]: unknown;
3025930236
};
30237+
content?: never;
3026030238
};
3026130239
/** @description Request Error */
3026230240
"4XX": {
@@ -30634,10 +30612,6 @@ export interface operations {
3063430612
* @description Whether to stop the creating job if all outputs of the job have been deleted.
3063530613
*/
3063630614
stop_job?: boolean | null;
30637-
/** @description View to be passed to the serializer */
30638-
view?: string | null;
30639-
/** @description Comma-separated list of keys to be passed to the serializer */
30640-
keys?: string | null;
3064130615
};
3064230616
header?: {
3064330617
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
@@ -30659,23 +30633,28 @@ export interface operations {
3065930633
};
3066030634
};
3066130635
responses: {
30662-
/** @description Request has been executed. */
30636+
/** @description Successful Response */
3066330637
200: {
3066430638
headers: {
3066530639
[name: string]: unknown;
3066630640
};
3066730641
content: {
30668-
"application/json": components["schemas"]["DeleteHistoryContentResult"];
30642+
"application/json": unknown;
3066930643
};
3067030644
};
3067130645
/** @description Request accepted, processing will finish later. */
3067230646
202: {
3067330647
headers: {
3067430648
[name: string]: unknown;
3067530649
};
30676-
content: {
30677-
"application/json": components["schemas"]["DeleteHistoryContentResult"];
30650+
content?: never;
30651+
};
30652+
/** @description Request has been executed. */
30653+
204: {
30654+
headers: {
30655+
[name: string]: unknown;
3067830656
};
30657+
content?: never;
3067930658
};
3068030659
/** @description Request Error */
3068130660
"4XX": {

lib/galaxy/schema/schema.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,28 +3592,6 @@ class DeleteHistoryContentPayload(Model):
35923592
)
35933593

35943594

3595-
class DeleteHistoryContentResult(Model):
3596-
"""Contains minimum information about the deletion state of a history item.
3597-
3598-
Can also contain any other properties of the item."""
3599-
3600-
id: DecodedDatabaseIdField = Field(
3601-
...,
3602-
title="ID",
3603-
description="The encoded ID of the history item.",
3604-
)
3605-
deleted: bool = Field(
3606-
...,
3607-
title="Deleted",
3608-
description="True if the item was successfully deleted.",
3609-
)
3610-
purged: Optional[bool] = Field(
3611-
default=None,
3612-
title="Purged",
3613-
description="True if the item was successfully removed from disk.",
3614-
)
3615-
3616-
36173595
class HistoryContentsArchiveDryRunResult(RootModel):
36183596
"""
36193597
Contains a collection of filepath/filename entries that represent

lib/galaxy/webapps/galaxy/api/history_contents.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
DatasetAssociationRoles,
4545
DatasetSourceType,
4646
DeleteHistoryContentPayload,
47-
DeleteHistoryContentResult,
4847
HistoryContentBulkOperationPayload,
4948
HistoryContentBulkOperationResult,
5049
HistoryContentsArchiveDryRunResult,
@@ -146,13 +145,11 @@ def ContentTypeQueryParam(default: Optional[HistoryContentType]):
146145

147146

148147
CONTENT_DELETE_RESPONSES = {
149-
200: {
150-
"description": "Request has been executed.",
151-
"model": DeleteHistoryContentResult,
152-
},
153148
202: {
154149
"description": "Request accepted, processing will finish later.",
155-
"model": DeleteHistoryContentResult,
150+
},
151+
204: {
152+
"description": "Request has been executed.",
156153
},
157154
}
158155

@@ -894,7 +891,6 @@ def delete_typed(
894891
id: HistoryItemIDPathParam,
895892
trans: ProvidesHistoryContext = DependsOnTrans,
896893
type: HistoryContentType = ContentTypePathParam,
897-
serialization_params: SerializationParams = Depends(query_serialization_params),
898894
purge: Optional[bool] = PurgeQueryParam,
899895
recursive: Optional[bool] = RecursiveQueryParam,
900896
stop_job: Optional[bool] = StopJobQueryParam,
@@ -910,7 +906,6 @@ def delete_typed(
910906
trans,
911907
id,
912908
type,
913-
serialization_params,
914909
purge,
915910
recursive,
916911
stop_job,
@@ -930,7 +925,6 @@ def delete_legacy(
930925
id: HistoryItemIDPathParam,
931926
trans: ProvidesHistoryContext = DependsOnTrans,
932927
type: HistoryContentType = ContentTypeQueryParam(default=HistoryContentType.dataset),
933-
serialization_params: SerializationParams = Depends(query_serialization_params),
934928
purge: Optional[bool] = PurgeQueryParam,
935929
recursive: Optional[bool] = RecursiveQueryParam,
936930
stop_job: Optional[bool] = StopJobQueryParam,
@@ -946,7 +940,6 @@ def delete_legacy(
946940
trans,
947941
id,
948942
type,
949-
serialization_params,
950943
purge,
951944
recursive,
952945
stop_job,
@@ -964,7 +957,6 @@ def delete_dataset(
964957
response: Response,
965958
dataset_id: HistoryItemIDPathParam,
966959
trans: ProvidesHistoryContext = DependsOnTrans,
967-
serialization_params: SerializationParams = Depends(query_serialization_params),
968960
purge: Optional[bool] = PurgeQueryParam,
969961
recursive: Optional[bool] = RecursiveQueryParam,
970962
stop_job: Optional[bool] = StopJobQueryParam,
@@ -980,7 +972,6 @@ def delete_dataset(
980972
trans,
981973
dataset_id,
982974
HistoryContentType.dataset,
983-
serialization_params,
984975
purge,
985976
recursive,
986977
stop_job,
@@ -993,7 +984,6 @@ def _delete(
993984
trans: ProvidesHistoryContext,
994985
id: DecodedDatabaseIdField,
995986
type: HistoryContentType,
996-
serialization_params: SerializationParams,
997987
purge: Optional[bool],
998988
recursive: Optional[bool],
999989
stop_job: Optional[bool],
@@ -1005,17 +995,14 @@ def _delete(
1005995
payload.purge = payload.purge or purge is True
1006996
payload.recursive = payload.recursive or recursive is True
1007997
payload.stop_job = payload.stop_job or stop_job is True
1008-
rval = self.service.delete(
998+
if self.service.delete(
1009999
trans,
10101000
id=id,
1011-
serialization_params=serialization_params,
10121001
contents_type=type,
10131002
payload=payload,
1014-
)
1015-
async_result = rval.pop("async_result", None)
1016-
if async_result:
1017-
response.status_code = status.HTTP_202_ACCEPTED
1018-
return rval
1003+
):
1004+
return Response(status_code=status.HTTP_202_ACCEPTED)
1005+
return Response(status_code=status.HTTP_204_NO_CONTENT)
10191006

10201007
@router.get(
10211008
"/api/histories/{history_id}/contents/archive/{filename}.{format}",

lib/galaxy/webapps/galaxy/services/history_contents.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -739,20 +739,18 @@ def delete(
739739
self,
740740
trans,
741741
id: DecodedDatabaseIdField,
742-
serialization_params: SerializationParams,
743742
contents_type: HistoryContentType,
744743
payload: DeleteHistoryContentPayload,
745744
):
746745
"""
747746
Delete the history content with the given ``id`` and specified type (defaults to dataset)
748747
"""
749748
if contents_type == HistoryContentType.dataset:
750-
return self.__delete_dataset(trans, id, payload.purge, payload.stop_job, serialization_params)
749+
return self.__delete_dataset(trans, id, payload.purge, payload.stop_job)
751750
elif contents_type == HistoryContentType.dataset_collection:
752-
async_result = self.dataset_collection_manager.delete(
751+
return self.dataset_collection_manager.delete(
753752
trans, "history", id, recursive=payload.recursive, purge=payload.purge
754753
)
755-
return {"id": self.encode_id(id), "deleted": True, "async_result": async_result is not None}
756754
else:
757755
raise exceptions.UnknownContentsType(f"Unknown contents type: {contents_type}")
758756

@@ -866,24 +864,16 @@ def build_archive_files_and_paths(content, *parents):
866864
archive.write(file_path, archive_path)
867865
return archive
868866

869-
def __delete_dataset(
870-
self, trans, id: DecodedDatabaseIdField, purge: bool, stop_job: bool, serialization_params: SerializationParams
871-
):
867+
def __delete_dataset(self, trans, id: DecodedDatabaseIdField, purge: bool, stop_job: bool):
872868
hda = self.hda_manager.get_owned(id, trans.user, current_history=trans.history)
873869
self.history_manager.error_unless_mutable(hda.history)
874870
self.hda_manager.error_if_uploading(hda)
875871

876-
async_result = None
877872
if purge:
878-
async_result = self.hda_manager.purge(hda, user=trans.user)
873+
return self.hda_manager.purge(hda, user=trans.user)
879874
else:
880875
self.hda_manager.delete(hda, stop_job=stop_job)
881-
serialization_params.default_view = "detailed"
882-
rval = self.hda_serializer.serialize_to_view(
883-
hda, user=trans.user, trans=trans, encode_id=False, **serialization_params.model_dump()
884-
)
885-
rval["async_result"] = async_result is not None
886-
return rval
876+
return None
887877

888878
def __update_dataset_collection(self, trans, id: DecodedDatabaseIdField, payload: dict[str, Any]):
889879
return self.dataset_collection_manager.update(trans, "history", id, payload)

lib/galaxy_test/api/test_datasets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def _run_cancel_job(self, history_id: str, use_query_params: bool = False):
672672
history_id, output_hda_id, stop_job=True, use_query_params=use_query_params
673673
)
674674
self._assert_status_code_is_ok(delete_response)
675-
deleted_hda = delete_response.json()
675+
deleted_hda = self.dataset_populator.get_history_dataset_details(history_id, content_id=output_hda_id)
676676
assert deleted_hda["deleted"], deleted_hda
677677

678678
# The job should be cancelled

lib/galaxy_test/api/test_history_contents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def _check_pair_creation(self, history_id: str, endpoint, payload):
692692
assert not dataset_collection["deleted"]
693693

694694
delete_response = self._delete(collection_url)
695-
self._assert_status_code_is(delete_response, 200)
695+
self._assert_status_code_is_ok(delete_response)
696696

697697
show_response = self._get(collection_url)
698698
dataset_collection = show_response.json()

0 commit comments

Comments
 (0)