Skip to content

Commit

Permalink
updates pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
BWMac committed Oct 25, 2023
1 parent 62fce82 commit 5740d79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/orca/services/nextflowtower/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def request_paged(self, method: str, path: str, **kwargs) -> dict[str, Any]:
while num_items < total_size:
kwargs["params"]["offset"] = num_items
json = self.request_json(method, path, **kwargs)
total_size = json.pop("totalSize")
total_size = (
json.pop("totalSize") if json.get("totalSize") else json.pop("total")
)
key_name, items = json.popitem()
num_items += len(items)
all_items.extend(items)
Expand All @@ -134,7 +136,7 @@ def get(self, path: str, **kwargs) -> dict[str, Any]:
A dictionary from deserializing the JSON response.
"""
json = self.request_json("GET", path, **kwargs)
if "totalSize" in json:
if "totalSize" in json or "total" in json:
json = self.request_paged("GET", path, **kwargs)
return json

Expand Down
1 change: 0 additions & 1 deletion tests/services/nextflowtower/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def test_that_get_workflow_tasks_works(client, mocker, get_response):
mock.return_value = get_response("get_workflow_tasks")
result = client.get_workflow_tasks(workspace_id=98765, workflow_id="123456789")
mock.assert_called()
print(result)
assert len(result) == 4


Expand Down

0 comments on commit 5740d79

Please sign in to comment.