Skip to content

Commit

Permalink
Using DecodedDatabaseIdField instead of `Union[DecodedDatabaseIdFie…
Browse files Browse the repository at this point in the history
…ld, LibraryFolderDatabaseIdField]` for library_id and fix `_create_dataset_in_folder_in_library` function that is leading to failed tests
  • Loading branch information
arash77 committed Oct 2, 2024
1 parent b03ce07 commit 110e467
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 0 additions & 2 deletions lib/galaxy/schema/library_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ class LibraryContentsPurgedResponse(LibraryContentsDeleteResponse):
purged: bool


AnyLibraryId = Union[DecodedDatabaseIdField, LibraryFolderDatabaseIdField]

AnyLibraryContentsShowResponse = Union[
LibraryContentsShowFolderResponse,
LibraryContentsShowDatasetResponse,
Expand Down
13 changes: 6 additions & 7 deletions lib/galaxy/webapps/galaxy/api/library_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
AnyLibraryContentsCreatePayload,
AnyLibraryContentsCreateResponse,
AnyLibraryContentsShowResponse,
AnyLibraryId,
LibraryContentsDeletePayload,
LibraryContentsDeleteResponse,
LibraryContentsFileCreatePayload,
Expand Down Expand Up @@ -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."""
Expand All @@ -88,7 +87,7 @@ def index(
)
def show(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
id: MaybeLibraryFolderOrDatasetID,
trans: ProvidesUserContext = DependsOnTrans,
) -> AnyLibraryContentsShowResponse:
Expand All @@ -103,7 +102,7 @@ def show(
)
def create_json(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
payload: AnyLibraryContentsCreatePayload,
trans: ProvidesHistoryContext = DependsOnTrans,
) -> AnyLibraryContentsCreateResponse:
Expand All @@ -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,
Expand Down Expand Up @@ -148,7 +147,7 @@ async def create_form(
)
def update(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
id: DecodedDatabaseIdField,
payload,
trans: ProvidesUserContext = DependsOnTrans,
Expand All @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions lib/galaxy/webapps/galaxy/services/library_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
AnyLibraryContentsCreatePayload,
AnyLibraryContentsCreateResponse,
AnyLibraryContentsShowResponse,
AnyLibraryId,
LibraryContentsCreateDatasetCollectionResponse,
LibraryContentsCreateDatasetResponse,
LibraryContentsCreateFileListResponse,
Expand Down Expand Up @@ -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]] = []
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy_test/api/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 110e467

Please sign in to comment.