From 110e46781aa0542ca371ee1f96206820482973ba Mon Sep 17 00:00:00 2001 From: Arash Date: Wed, 2 Oct 2024 14:48:59 +0200 Subject: [PATCH] Using `DecodedDatabaseIdField` instead of `Union[DecodedDatabaseIdField, LibraryFolderDatabaseIdField]` for library_id and fix `_create_dataset_in_folder_in_library` function that is leading to failed tests --- lib/galaxy/schema/library_contents.py | 2 -- lib/galaxy/webapps/galaxy/api/library_contents.py | 13 ++++++------- .../webapps/galaxy/services/library_contents.py | 5 ++--- lib/galaxy_test/api/test_libraries.py | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/galaxy/schema/library_contents.py b/lib/galaxy/schema/library_contents.py index 21febf223f13..b46fabf233ab 100644 --- a/lib/galaxy/schema/library_contents.py +++ b/lib/galaxy/schema/library_contents.py @@ -310,8 +310,6 @@ class LibraryContentsPurgedResponse(LibraryContentsDeleteResponse): purged: bool -AnyLibraryId = Union[DecodedDatabaseIdField, LibraryFolderDatabaseIdField] - AnyLibraryContentsShowResponse = Union[ LibraryContentsShowFolderResponse, LibraryContentsShowDatasetResponse, diff --git a/lib/galaxy/webapps/galaxy/api/library_contents.py b/lib/galaxy/webapps/galaxy/api/library_contents.py index 9a0e539d12b0..a0403b78adeb 100644 --- a/lib/galaxy/webapps/galaxy/api/library_contents.py +++ b/lib/galaxy/webapps/galaxy/api/library_contents.py @@ -27,7 +27,6 @@ AnyLibraryContentsCreatePayload, AnyLibraryContentsCreateResponse, AnyLibraryContentsShowResponse, - AnyLibraryId, LibraryContentsDeletePayload, LibraryContentsDeleteResponse, LibraryContentsFileCreatePayload, @@ -74,7 +73,7 @@ class FastAPILibraryContents: ) def index( self, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, trans: ProvidesUserContext = DependsOnTrans, ) -> LibraryContentsIndexListResponse: """This endpoint is deprecated. Please use GET /api/folders/{folder_id}/contents instead.""" @@ -88,7 +87,7 @@ def index( ) def show( self, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, id: MaybeLibraryFolderOrDatasetID, trans: ProvidesUserContext = DependsOnTrans, ) -> AnyLibraryContentsShowResponse: @@ -103,7 +102,7 @@ def show( ) def create_json( self, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, payload: AnyLibraryContentsCreatePayload, trans: ProvidesHistoryContext = DependsOnTrans, ) -> AnyLibraryContentsCreateResponse: @@ -119,7 +118,7 @@ def create_json( async def create_form( self, request: Request, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, payload: LibraryContentsFileCreatePayload = Depends(LibraryContentsCreateForm.as_form), files: Optional[List[UploadFile]] = None, trans: ProvidesHistoryContext = DependsOnTrans, @@ -148,7 +147,7 @@ async def create_form( ) def update( self, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, id: DecodedDatabaseIdField, payload, trans: ProvidesUserContext = DependsOnTrans, @@ -163,7 +162,7 @@ def update( ) def delete( self, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, id: DecodedDatabaseIdField, payload: Optional[LibraryContentsDeletePayload] = Body(None), trans: ProvidesHistoryContext = DependsOnTrans, diff --git a/lib/galaxy/webapps/galaxy/services/library_contents.py b/lib/galaxy/webapps/galaxy/services/library_contents.py index 3ec5686dc132..55db4038fcc1 100644 --- a/lib/galaxy/webapps/galaxy/services/library_contents.py +++ b/lib/galaxy/webapps/galaxy/services/library_contents.py @@ -26,7 +26,6 @@ AnyLibraryContentsCreatePayload, AnyLibraryContentsCreateResponse, AnyLibraryContentsShowResponse, - AnyLibraryId, LibraryContentsCreateDatasetCollectionResponse, LibraryContentsCreateDatasetResponse, LibraryContentsCreateFileListResponse, @@ -78,7 +77,7 @@ def __init__( def index( self, trans: ProvidesUserContext, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, ) -> LibraryContentsIndexListResponse: """Return a list of library files and folders.""" rval: List[Union[LibraryContentsIndexFolderResponse, LibraryContentsIndexDatasetResponse]] = [] @@ -124,7 +123,7 @@ def show( def create( self, trans: ProvidesHistoryContext, - library_id: AnyLibraryId, + library_id: DecodedDatabaseIdField, payload: AnyLibraryContentsCreatePayload, ) -> AnyLibraryContentsCreateResponse: """Create a new library file or folder.""" diff --git a/lib/galaxy_test/api/test_libraries.py b/lib/galaxy_test/api/test_libraries.py index a7f5dfd71d0c..ba0bd7850870 100644 --- a/lib/galaxy_test/api/test_libraries.py +++ b/lib/galaxy_test/api/test_libraries.py @@ -605,6 +605,6 @@ def _create_dataset_in_folder_in_library(self, library_name, content="1 2 3", wa history_id = self.dataset_populator.new_history() hda_id = self.dataset_populator.new_dataset(history_id, content=content, wait=wait)["id"] payload = {"from_hda_id": hda_id, "create_type": "file", "folder_id": folder_id} - ld = self._post(f"libraries/{folder_id}/contents", payload, json=True) + ld = self._post(f"libraries/{library['id']}/contents", payload, json=True) ld.raise_for_status() return ld