Skip to content

Commit 8a94d6f

Browse files
author
Vojta Valter
committed
feat: Add support for filters in export helper methods
1 parent 358212d commit 8a94d6f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

rossum_api/elis_api_client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,27 @@ async def retrieve_upload(self, upload_id: int) -> Upload:
204204
upload = await self._http_client.fetch_one(Resource.Upload, upload_id)
205205
return self._deserializer(Resource.Upload, upload)
206206

207-
async def export_annotations_to_json(self, queue_id: int) -> AsyncIterator[Annotation]:
207+
async def export_annotations_to_json(
208+
self, queue_id: int, **filters: Any
209+
) -> AsyncIterator[Annotation]:
208210
"""https://elis.rossum.ai/api/docs/#export-annotations.
209211
210212
JSON export is paginated and returns the result in a way similar to other list_all methods.
211213
"""
212-
async for chunk in self._http_client.export(Resource.Queue, queue_id, "json"):
214+
async for chunk in self._http_client.export(Resource.Queue, queue_id, "json", **filters):
213215
# JSON export can be translated directly to Annotation object
214216
yield self._deserializer(Resource.Annotation, typing.cast(typing.Dict, chunk))
215217

216218
async def export_annotations_to_file(
217-
self, queue_id: int, export_format: ExportFileFormats
219+
self, queue_id: int, export_format: ExportFileFormats, **filters: Any
218220
) -> AsyncIterator[bytes]:
219221
"""https://elis.rossum.ai/api/docs/#export-annotations.
220222
221223
XLSX/CSV/XML exports can be huge, therefore byte streaming is used to keep memory consumption low.
222224
"""
223-
async for chunk in self._http_client.export(Resource.Queue, queue_id, str(export_format)):
225+
async for chunk in self._http_client.export(
226+
Resource.Queue, queue_id, str(export_format), **filters
227+
):
224228
yield typing.cast(bytes, chunk)
225229

226230
# ##### ORGANIZATIONS #####

rossum_api/elis_api_client_sync.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,24 @@ def retrieve_upload(self, upload_id: int) -> Upload:
207207

208208
return self._run_coroutine(self.elis_api_client.retrieve_upload(upload_id))
209209

210-
def export_annotations_to_json(self, queue_id: int) -> Iterator[Annotation]:
210+
def export_annotations_to_json(self, queue_id: int, **filters: Any) -> Iterator[Annotation]:
211211
"""https://elis.rossum.ai/api/docs/#export-annotations.
212212
213213
JSON export is paginated and returns the result in a way similar to other list_all methods.
214214
"""
215-
return self._iter_over_async(self.elis_api_client.export_annotations_to_json(queue_id))
215+
return self._iter_over_async(
216+
self.elis_api_client.export_annotations_to_json(queue_id, **filters)
217+
)
216218

217219
def export_annotations_to_file(
218-
self, queue_id: int, export_format: ExportFileFormats
220+
self, queue_id: int, export_format: ExportFileFormats, **filters: Any
219221
) -> Iterator[bytes]:
220222
"""https://elis.rossum.ai/api/docs/#export-annotations.
221223
222224
XLSX/CSV/XML exports can be huge, therefore byte streaming is used to keep memory consumption low.
223225
"""
224226
return self._iter_over_async(
225-
self.elis_api_client.export_annotations_to_file(queue_id, export_format)
227+
self.elis_api_client.export_annotations_to_file(queue_id, export_format, **filters)
226228
)
227229

228230
# ##### ORGANIZATIONS #####

0 commit comments

Comments
 (0)