Skip to content

list_candidates

list_candidates(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    leaderboard_arn: Optional[LeaderboardArn] = None,
    filters: Optional[LeaderboardCandidateFilters] = None,
    sort_by: Optional[LeaderboardSortBy] = None,
    sort_metric: Optional[LeaderboardSortMetric] = None,
    sort_order: Optional[LeaderboardSortOrder] = None,
    max_results: Optional[LeaderboardMaxResults] = None,
    next_token: Optional[NextToken] = None,
) -> ListCandidatesResponse

Lists the candidates on a leaderboard. You can filter the candidates by dataset or by evaluation criteria, and sort them by creation time or by a metric.

For each evaluation criterion, ListCandidates returns the metrics from the candidate's most recent evaluation run. To get all of a candidate's evaluation metrics, use GetCandidate.

Changes that you make with AddCandidate or DeleteCandidate can take a short time to appear in ListCandidates results.

Parameters:

  • leaderboard_arn (Optional[LeaderboardArn], default: None ) –

    The Amazon Resource Name (ARN) of the leaderboard.

  • filters (Optional[LeaderboardCandidateFilters], default: None ) –

    Filters that return only the candidates that match all of the filter values that you specify.

  • sort_by (Optional[LeaderboardSortBy], default: None ) –

    The field to sort the candidates by. If you specify METRIC, you must also specify SortMetric. If you don't specify SortBy, the candidates are sorted by CandidateId.

  • sort_metric (Optional[LeaderboardSortMetric], default: None ) –

    The metric to sort the candidates by. Required when SortBy is METRIC. The response includes only the candidates whose most recent evaluation run reports this metric.

  • sort_order (Optional[LeaderboardSortOrder], default: None ) –

    The sort order. The default is DESCENDING.

  • max_results (Optional[LeaderboardMaxResults], default: None ) –

    The maximum number of candidates to return in the response. The default is 20.

  • next_token (Optional[NextToken], default: None ) –

    If the result of the previous ListCandidates request was truncated, the response includes a NextToken. To retrieve the next set of candidates, use the token in the next request. Use the same Filters, SortBy, SortMetric, and SortOrder as in the previous request. Otherwise, ListCandidates returns a ValidationException error.

Raises:

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def list_candidates(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    leaderboard_arn: Optional[
        "capo_sagemaker.types.leaderboard_arn.LeaderboardArn"
    ] = None,
    filters: Optional[
        "capo_sagemaker.types.leaderboard_candidate_filters.LeaderboardCandidateFilters"
    ] = None,
    sort_by: Optional[
        "capo_sagemaker.types.leaderboard_sort_by.LeaderboardSortBy"
    ] = None,
    sort_metric: Optional[
        "capo_sagemaker.types.leaderboard_sort_metric.LeaderboardSortMetric"
    ] = None,
    sort_order: Optional[
        "capo_sagemaker.types.leaderboard_sort_order.LeaderboardSortOrder"
    ] = None,
    max_results: Optional[
        "capo_sagemaker.types.leaderboard_max_results.LeaderboardMaxResults"
    ] = None,
    next_token: Optional["capo_sagemaker.types.next_token.NextToken"] = None,
) -> "capo_sagemaker.types.list_candidates_response.ListCandidatesResponse":
    """<p>Lists the candidates on a leaderboard. You can filter the candidates by dataset or by evaluation criteria, and sort them by creation time or by a metric.</p> <p>For each evaluation criterion, <code>ListCandidates</code> returns the metrics from the candidate's most recent evaluation run. To get all of a candidate's evaluation metrics, use <code>GetCandidate</code>.</p> <p>Changes that you make with <code>AddCandidate</code> or <code>DeleteCandidate</code> can take a short time to appear in <code>ListCandidates</code> results.</p>

    Args:
        leaderboard_arn: <p>The Amazon Resource Name (ARN) of the leaderboard.</p>
        filters: <p>Filters that return only the candidates that match all of the filter values that you specify.</p>
        sort_by: <p>The field to sort the candidates by. If you specify <code>METRIC</code>, you must also specify <code>SortMetric</code>. If you don't specify <code>SortBy</code>, the candidates are sorted by <code>CandidateId</code>.</p>
        sort_metric: <p>The metric to sort the candidates by. Required when <code>SortBy</code> is <code>METRIC</code>. The response includes only the candidates whose most recent evaluation run reports this metric.</p>
        sort_order: <p>The sort order. The default is <code>DESCENDING</code>.</p>
        max_results: <p>The maximum number of candidates to return in the response. The default is 20.</p>
        next_token: <p>If the result of the previous <code>ListCandidates</code> request was truncated, the response includes a <code>NextToken</code>. To retrieve the next set of candidates, use the token in the next request. Use the same <code>Filters</code>, <code>SortBy</code>, <code>SortMetric</code>, and <code>SortOrder</code> as in the previous request. Otherwise, <code>ListCandidates</code> returns a <code>ValidationException</code> error.</p>

    Raises:
        capo_sagemaker.errors.resource_not_found.ResourceNotFound: <p>Resource being access is not found.</p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.list_candidates_request.ListCandidatesRequest]",
    ) -> OperationResponse[
        "capo_sagemaker.types.list_candidates_response.ListCandidatesResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.list_candidates

        output, http_response = (
            capo_sagemaker._operations.sage_maker.list_candidates.list_candidates(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListCandidates")
    )
    input_: capo_sagemaker.types.list_candidates_request.ListCandidatesRequest = {}
    if leaderboard_arn is not None:
        input_["leaderboard_arn"] = leaderboard_arn
    if filters is not None:
        input_["filters"] = filters
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if sort_metric is not None:
        input_["sort_metric"] = sort_metric
    if sort_order is not None:
        input_["sort_order"] = sort_order
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output