Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add limit, offset and include_deleted to show_folder #494

Merged
merged 25 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5b889cf
add limit and offset to show_folder
bernt-matthias Jan 29, 2025
c49b94a
add include_deleted
bernt-matthias Jan 30, 2025
f5a26d6
Simply test subfolder creation
bernt-matthias Jan 30, 2025
107d985
Just use the upstream default values
bernt-matthias Jan 30, 2025
82dc9cb
Revert to loop and drop subfolders variable
bernt-matthias Jan 30, 2025
5f22c37
add test for include_deleted
bernt-matthias Jan 30, 2025
b1d43f7
Merge branch 'folder-update' of https://github.com/bernt-matthias/bio…
bernt-matthias Jan 30, 2025
7a36f0a
Simplify test
bernt-matthias Jan 30, 2025
40a7810
Simplify test
bernt-matthias Jan 30, 2025
e64a4ca
test content counts
bernt-matthias Jan 30, 2025
a7c2ff6
fix test and add docs
bernt-matthias Jan 30, 2025
11e8793
total_rows became available only after
bernt-matthias Jan 31, 2025
30c4c91
add contents generator
bernt-matthias Jan 31, 2025
4a46da3
Rename content to content_iter
bernt-matthias Feb 1, 2025
687d281
Use sys.maxsize for iteration
bernt-matthias Feb 4, 2025
2f93514
overload show_folder
bernt-matthias Feb 4, 2025
a90a19d
Apply suggestions from code review
bernt-matthias Feb 4, 2025
9317cb1
Update bioblend/_tests/TestGalaxyFolders.py
bernt-matthias Feb 4, 2025
b442c17
revert accidental change
bernt-matthias Feb 4, 2025
080f24a
rewording
bernt-matthias Feb 4, 2025
136fc5e
return is Iterator
bernt-matthias Feb 4, 2025
7a6ee4a
rename limit
bernt-matthias Feb 4, 2025
42b8c06
Merge branch 'folder-update' of https://github.com/bernt-matthias/bio…
bernt-matthias Feb 4, 2025
9ce5013
finish parameter renaming
bernt-matthias Feb 4, 2025
a0b9337
more missing renaming
bernt-matthias Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion bioblend/_tests/TestGalaxyFolders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
List,
)

from . import GalaxyTestBase
from . import (
GalaxyTestBase,
test_util,
)

FOO_DATA = "foo\nbar\n"

Expand Down Expand Up @@ -36,6 +39,22 @@ def test_show_folder_contents(self):
assert "metadata" in f2
assert self.name == f2["metadata"]["folder_name"]

@test_util.skip_unless_galaxy("release_21.05")
def test_show_folder_contents_limit(self):
subfolders = []
for i in range(12):
subfolders.append(self.gi.folders.create_folder(self.folder["id"], f"{self.name} {i}"))

# check defaults for limit and offset
f2 = self.gi.folders.show_folder(self.folder["id"], contents=True)
assert len(f2["folder_contents"]) == 10
assert f2["folder_contents"][0]["name"] == f"{self.name} 0"

# check non defaults
f2 = self.gi.folders.show_folder(self.folder["id"], contents=True, limit=1, offset=1)
assert len(f2["folder_contents"]) == 1
assert f2["folder_contents"][0]["name"] == f"{self.name} 1"

def test_delete_folder(self):
self.sub_folder = self.gi.folders.create_folder(self.folder["id"], self.name)
self.gi.folders.delete_folder(self.sub_folder["id"])
Expand Down
3 changes: 1 addition & 2 deletions bioblend/_tests/TestGalaxyHistories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
import shutil
Expand Down
3 changes: 1 addition & 2 deletions bioblend/_tests/TestGalaxyTools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
from typing import (
Expand Down
3 changes: 1 addition & 2 deletions bioblend/_tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" General support infrastructure not tied to any particular test.
"""
"""General support infrastructure not tied to any particular test."""

import os
import random
Expand Down
26 changes: 23 additions & 3 deletions bioblend/galaxy/folders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def create_folder(self, parent_folder_id: str, name: str, description: Optional[
payload["description"] = description
return self._post(payload=payload, id=parent_folder_id)

def show_folder(self, folder_id: str, contents: bool = False) -> Dict[str, Any]:
def show_folder(
self,
folder_id: str,
contents: bool = False,
limit: Optional[int] = 10,
offset: Optional[int] = 0,
include_deleted: bool = False,
) -> Dict[str, Any]:
"""
Display information about a folder.

Expand All @@ -56,11 +63,24 @@ def show_folder(self, folder_id: str, contents: bool = False) -> Dict[str, Any]:
:param contents: True to get the contents of the folder, rather
than just the folder details.

:type limit: int
:param limit: Maximum number of contents to return (default: 10).

:type offset: int
:param contents: Return contents from this specified position (default: 0).

:type include_deleted: bool
:param include_deleted: Returns also deleted contents.

:rtype: dict
:return: dictionary including details of the folder
"""

return self._get(id=folder_id, contents=contents)
params: Dict[str, Any] = {"include_deleted": include_deleted}
if limit:
params["limit"] = limit
if offset:
params["offset"] = offset
return self._get(id=folder_id, contents=contents, params=params)

def delete_folder(self, folder_id: str, undelete: bool = False) -> Dict[str, Any]:
"""
Expand Down