Skip to content

add_candidate async

add_candidate(
    *,
    config_overrides: Optional[AsyncSageMakerClientConfig] = None,
    leaderboard_arn: Optional[LeaderboardArn] = None,
    display_name: Optional[LeaderboardCandidateDisplayName] = None,
    labels: Optional[LeaderboardLabelMap] = None,
    candidate_config: Optional[LeaderboardCandidateConfig] = None,
    evaluation_results: Optional[LeaderboardEvaluationResultList] = None,
    client_token: Optional[LeaderboardClientToken] = None,
) -> AddCandidateResponse

Adds a candidate and its evaluation metrics to a leaderboard, or adds evaluation metrics to an existing candidate.

The candidate configuration (CandidateConfig) identifies the candidate. SageMaker derives the CandidateId from the configuration, so the same configuration always produces the same CandidateId on a leaderboard. The display name and labels aren't part of the identity.

If a candidate with the same configuration already exists on the leaderboard, AddCandidate updates it as follows:

  • Adds the evaluation metrics in the request to the candidate's existing metrics.

  • Replaces the candidate's labels if you specify Labels. If you don't specify Labels, the existing labels are kept.

  • Keeps the existing display name. DisplayName takes effect only when the candidate is created.

Parameters:

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

    The Amazon Resource Name (ARN) of the leaderboard to add the candidate to.

  • display_name (Optional[LeaderboardCandidateDisplayName], default: None ) –

    A display name for the candidate. SageMaker uses this value only when it creates the candidate. If the candidate already exists, SageMaker keeps its existing display name. The display name can't contain control characters or format characters.

  • labels (Optional[LeaderboardLabelMap], default: None ) –

    Key-value pairs that describe the candidate. Labels aren't part of the candidate's identity. If the candidate already exists, these labels replace its existing labels. To remove all labels, specify an empty map. If you don't specify labels, the existing labels are kept. Label keys and values can contain only Unicode letters, numbers, spaces, and the following characters: _ . : / = + - @.

  • candidate_config (Optional[LeaderboardCandidateConfig], default: None ) –

    The configuration that identifies the candidate. Candidates with the same configuration have the same CandidateId.

  • evaluation_results (Optional[LeaderboardEvaluationResultList], default: None ) –

    The evaluation metrics to add to the candidate, grouped by evaluation criterion.

  • client_token (Optional[LeaderboardClientToken], default: None ) –

    A unique, case-sensitive identifier for the request. If you don't specify a client token, the Amazon Web Services SDKs and the Amazon Web Services CLI generate one for you.

Raises:

  • ConflictException –

    There was a conflict when you attempted to modify a SageMaker entity such as an Experiment or Artifact.

  • ResourceLimitExceeded –

    You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.

  • ResourceNotFound –

    Resource being access is not found.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sagemaker/_services/async_sage_maker.py
async def add_candidate(
    self,
    *,
    config_overrides: Optional[AsyncSageMakerClientConfig] = None,
    leaderboard_arn: Optional[
        "capo_sagemaker.types.leaderboard_arn.LeaderboardArn"
    ] = None,
    display_name: Optional[
        "capo_sagemaker.types.leaderboard_candidate_display_name.LeaderboardCandidateDisplayName"
    ] = None,
    labels: Optional[
        "capo_sagemaker.types.leaderboard_label_map.LeaderboardLabelMap"
    ] = None,
    candidate_config: Optional[
        "capo_sagemaker.types.leaderboard_candidate_config.LeaderboardCandidateConfig"
    ] = None,
    evaluation_results: Optional[
        "capo_sagemaker.types.leaderboard_evaluation_result_list.LeaderboardEvaluationResultList"
    ] = None,
    client_token: Optional[
        "capo_sagemaker.types.leaderboard_client_token.LeaderboardClientToken"
    ] = None,
) -> "capo_sagemaker.types.add_candidate_response.AddCandidateResponse":
    """<p>Adds a candidate and its evaluation metrics to a leaderboard, or adds evaluation metrics to an existing candidate.</p> <p>The candidate configuration (<code>CandidateConfig</code>) identifies the candidate. SageMaker derives the <code>CandidateId</code> from the configuration, so the same configuration always produces the same <code>CandidateId</code> on a leaderboard. The display name and labels aren't part of the identity.</p> <p>If a candidate with the same configuration already exists on the leaderboard, <code>AddCandidate</code> updates it as follows:</p> <ul> <li> <p>Adds the evaluation metrics in the request to the candidate's existing metrics.</p> </li> <li> <p>Replaces the candidate's labels if you specify <code>Labels</code>. If you don't specify <code>Labels</code>, the existing labels are kept.</p> </li> <li> <p>Keeps the existing display name. <code>DisplayName</code> takes effect only when the candidate is created.</p> </li> </ul>

    Args:
        leaderboard_arn: <p>The Amazon Resource Name (ARN) of the leaderboard to add the candidate to.</p>
        display_name: <p>A display name for the candidate. SageMaker uses this value only when it creates the candidate. If the candidate already exists, SageMaker keeps its existing display name. The display name can't contain control characters or format characters.</p>
        labels: <p>Key-value pairs that describe the candidate. Labels aren't part of the candidate's identity. If the candidate already exists, these labels replace its existing labels. To remove all labels, specify an empty map. If you don't specify labels, the existing labels are kept. Label keys and values can contain only Unicode letters, numbers, spaces, and the following characters: <code>_ . : / = + - @</code>.</p>
        candidate_config: <p>The configuration that identifies the candidate. Candidates with the same configuration have the same <code>CandidateId</code>.</p>
        evaluation_results: <p>The evaluation metrics to add to the candidate, grouped by evaluation criterion.</p>
        client_token: <p>A unique, case-sensitive identifier for the request. If you don't specify a client token, the Amazon Web Services SDKs and the Amazon Web Services CLI generate one for you.</p>

    Raises:
        capo_sagemaker.errors.conflict_exception.ConflictException: <p>There was a conflict when you attempted to modify a SageMaker entity such as an <code>Experiment</code> or <code>Artifact</code>.</p>
        capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
        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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sagemaker.types.add_candidate_request.AddCandidateRequest]",
    ) -> AsyncOperationResponse[
        "capo_sagemaker.types.add_candidate_response.AddCandidateResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.add_candidate

        (
            output,
            http_response,
        ) = await capo_sagemaker._operations.sage_maker.add_candidate.async_add_candidate(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AddCandidate")
    )
    input_: capo_sagemaker.types.add_candidate_request.AddCandidateRequest = {}
    if leaderboard_arn is not None:
        input_["leaderboard_arn"] = leaderboard_arn
    if display_name is not None:
        input_["display_name"] = display_name
    if labels is not None:
        input_["labels"] = labels
    if candidate_config is not None:
        input_["candidate_config"] = candidate_config
    if evaluation_results is not None:
        input_["evaluation_results"] = evaluation_results
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output