|
4 | 4 | """ |
5 | 5 |
|
6 | 6 | import json |
7 | | -from typing import TYPE_CHECKING, List, Optional |
| 7 | +from typing import TYPE_CHECKING, Any, AsyncGenerator, Dict, List, Optional |
| 8 | + |
| 9 | +from synapseclient.api.api_client import rest_get_paginated_async |
8 | 10 |
|
9 | 11 | if TYPE_CHECKING: |
10 | 12 | from synapseclient import Synapse |
@@ -448,42 +450,38 @@ async def get_submission( |
448 | 450 | async def get_evaluation_submissions( |
449 | 451 | evaluation_id: str, |
450 | 452 | status: Optional[str] = None, |
451 | | - limit: int = 20, |
452 | | - offset: int = 0, |
| 453 | + *, |
453 | 454 | synapse_client: Optional["Synapse"] = None, |
454 | | -) -> dict: |
| 455 | +) -> AsyncGenerator[Dict[str, Any], None]: |
455 | 456 | """ |
456 | | - Retrieves all Submissions for a specified Evaluation queue. |
| 457 | + Generator to get all Submissions for a specified Evaluation queue. |
457 | 458 |
|
458 | 459 | <https://rest-docs.synapse.org/rest/GET/evaluation/evalId/submission/all.html> |
459 | 460 |
|
460 | 461 | Arguments: |
461 | 462 | evaluation_id: The ID of the evaluation queue. |
462 | 463 | status: Optionally filter submissions by a submission status, such as SCORED, VALID, |
463 | 464 | INVALID, OPEN, CLOSED or EVALUATION_IN_PROGRESS. |
464 | | - limit: Limits the number of submissions in a single response. Default to 20. |
465 | | - offset: The offset index determines where this page will start from. |
466 | | - An index of 0 is the first submission. Default to 0. |
467 | 465 | synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` |
468 | 466 | this will use the last created instance from the Synapse class constructor. |
469 | 467 |
|
470 | | - Returns: |
471 | | - # TODO: Support pagination in the return type. |
472 | | - A response JSON containing a paginated list of submissions for the evaluation queue. |
| 468 | + Yields: |
| 469 | + Individual Submission objects from each page of the response. |
473 | 470 | """ |
474 | 471 | from synapseclient import Synapse |
475 | 472 |
|
476 | 473 | client = Synapse.get_client(synapse_client=synapse_client) |
477 | 474 |
|
478 | 475 | uri = f"/evaluation/{evaluation_id}/submission/all" |
479 | | - query_params = {"limit": limit, "offset": offset} |
| 476 | + query_params = {} |
480 | 477 |
|
481 | 478 | if status: |
482 | 479 | query_params["status"] = status |
483 | 480 |
|
484 | | - response = await client.rest_get_async(uri, params=query_params) |
485 | | - |
486 | | - return response |
| 481 | + async for item in rest_get_paginated_async( |
| 482 | + uri=uri, params=query_params, synapse_client=client |
| 483 | + ): |
| 484 | + yield item |
487 | 485 |
|
488 | 486 |
|
489 | 487 | async def get_user_submissions( |
|
0 commit comments