Skip to content

Commit

Permalink
paginate mapping endpoints (#1506)
Browse files Browse the repository at this point in the history
closes lig-4613
- paginate mapping endpoint to allow >400k samples without overloading the API
  • Loading branch information
japrescott authored Feb 19, 2024
1 parent f779e58 commit 51db826
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lightly/api/api_workflow_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,13 @@ def get_filenames(self) -> List[str]:
:meta private: # Skip docstring generation
"""
filenames_on_server = self._mappings_api.get_sample_mappings_by_dataset_id(
dataset_id=self.dataset_id, field="fileName"
filenames_on_server = list(
utils.paginate_endpoint(
self._mappings_api.get_sample_mappings_by_dataset_id,
page_size=25000,
dataset_id=self.dataset_id,
field="fileName",
)
)
return filenames_on_server

Expand Down
9 changes: 7 additions & 2 deletions lightly/api/api_workflow_download_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,13 @@ def download_dataset(
)

# get sample ids
sample_ids = self._mappings_api.get_sample_mappings_by_dataset_id(
self.dataset_id, field="_id"
sample_ids = list(
utils.paginate_endpoint(
self._mappings_api.get_sample_mappings_by_dataset_id,
page_size=25000,
dataset_id=self.dataset_id,
field="_id",
)
)

indices = BitMask.from_hex(tag.bit_mask_data).to_indices()
Expand Down

0 comments on commit 51db826

Please sign in to comment.