Skip to content

Commit 1fb0fbf

Browse files
committed
get_evaluation_submissions returns generator object
1 parent 3cb1915 commit 1fb0fbf

File tree

6 files changed

+333
-140
lines changed

6 files changed

+333
-140
lines changed

synapseclient/api/evaluation_services.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"""
55

66
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
810

911
if TYPE_CHECKING:
1012
from synapseclient import Synapse
@@ -448,42 +450,38 @@ async def get_submission(
448450
async def get_evaluation_submissions(
449451
evaluation_id: str,
450452
status: Optional[str] = None,
451-
limit: int = 20,
452-
offset: int = 0,
453+
*,
453454
synapse_client: Optional["Synapse"] = None,
454-
) -> dict:
455+
) -> AsyncGenerator[Dict[str, Any], None]:
455456
"""
456-
Retrieves all Submissions for a specified Evaluation queue.
457+
Generator to get all Submissions for a specified Evaluation queue.
457458
458459
<https://rest-docs.synapse.org/rest/GET/evaluation/evalId/submission/all.html>
459460
460461
Arguments:
461462
evaluation_id: The ID of the evaluation queue.
462463
status: Optionally filter submissions by a submission status, such as SCORED, VALID,
463464
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.
467465
synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)`
468466
this will use the last created instance from the Synapse class constructor.
469467
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.
473470
"""
474471
from synapseclient import Synapse
475472

476473
client = Synapse.get_client(synapse_client=synapse_client)
477474

478475
uri = f"/evaluation/{evaluation_id}/submission/all"
479-
query_params = {"limit": limit, "offset": offset}
476+
query_params = {}
480477

481478
if status:
482479
query_params["status"] = status
483480

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
487485

488486

489487
async def get_user_submissions(

0 commit comments

Comments
 (0)