Skip to content

update_campaign

update_campaign(
    campaign_arn: Arn,
    *,
    config_overrides: Optional[PersonalizeClientConfig] = None,
    solution_version_arn: Optional[Arn] = None,
    min_provisioned_tps: Optional[TransactionsPerSecond] = None,
    campaign_config: Optional[CampaignConfig] = None,
) -> UpdateCampaignResponse

Updates a campaign to deploy a retrained solution version with an existing campaign, change your campaign's minProvisionedTPS, or modify your campaign's configuration. For example, you can set enableMetadataWithRecommendations to true for an existing campaign.

To update a campaign to start automatically using the latest solution version, specify the following:

  • For the SolutionVersionArn parameter, specify the Amazon Resource Name (ARN) of your solution in SolutionArn/$LATEST format.

  • In the campaignConfig, set syncWithLatestSolutionVersion to true.

To update a campaign, the campaign status must be ACTIVE or CREATE FAILED. Check the campaign status using the DescribeCampaign operation.

You can still get recommendations from a campaign while an update is in progress. The campaign will use the previous solution version and campaign configuration to generate recommendations until the latest campaign update status is Active.

For more information about updating a campaign, including code samples, see Updating a campaign. For more information about campaigns, see Creating a campaign.

Parameters:

  • campaign_arn (Arn) –

    The Amazon Resource Name (ARN) of the campaign.

  • solution_version_arn (Optional[Arn], default: None ) –

    The Amazon Resource Name (ARN) of a new model to deploy. To specify the latest solution version of your solution, specify the ARN of your solution in SolutionArn/$LATEST format. You must use this format if you set syncWithLatestSolutionVersion to True in the CampaignConfig.

    To deploy a model that isn't the latest solution version of your solution, specify the ARN of the solution version.

    For more information about automatic campaign updates, see Enabling automatic campaign updates.

  • min_provisioned_tps (Optional[TransactionsPerSecond], default: None ) –

    Specifies the requested minimum provisioned transactions (recommendations) per second that Amazon Personalize will support. A high minProvisionedTPS will increase your bill. We recommend starting with 1 for minProvisionedTPS (the default). Track your usage using Amazon CloudWatch metrics, and increase the minProvisionedTPS as necessary.

  • campaign_config (Optional[CampaignConfig], default: None ) –

    The configuration details of a campaign.

Raises:

Source code in docs_src/capo_personalize/_services/personalize.py
def update_campaign(
    self,
    campaign_arn: "capo_personalize.types.arn.Arn",
    *,
    config_overrides: Optional[PersonalizeClientConfig] = None,
    solution_version_arn: Optional["capo_personalize.types.arn.Arn"] = None,
    min_provisioned_tps: Optional[
        "capo_personalize.types.transactions_per_second.TransactionsPerSecond"
    ] = None,
    campaign_config: Optional[
        "capo_personalize.types.campaign_config.CampaignConfig"
    ] = None,
) -> "capo_personalize.types.update_campaign_response.UpdateCampaignResponse":
    """<p> Updates a campaign to deploy a retrained solution version with an existing campaign, change your campaign's <code>minProvisionedTPS</code>, or modify your campaign's configuration. For example, you can set <code>enableMetadataWithRecommendations</code> to true for an existing campaign.</p> <p> To update a campaign to start automatically using the latest solution version, specify the following:</p> <ul> <li> <p>For the <code>SolutionVersionArn</code> parameter, specify the Amazon Resource Name (ARN) of your solution in <code>SolutionArn/$LATEST</code> format. </p> </li> <li> <p> In the <code>campaignConfig</code>, set <code>syncWithLatestSolutionVersion</code> to <code>true</code>. </p> </li> </ul> <p>To update a campaign, the campaign status must be ACTIVE or CREATE FAILED. Check the campaign status using the <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_DescribeCampaign.html">DescribeCampaign</a> operation.</p> <note> <p>You can still get recommendations from a campaign while an update is in progress. The campaign will use the previous solution version and campaign configuration to generate recommendations until the latest campaign update status is <code>Active</code>. </p> </note> <p>For more information about updating a campaign, including code samples, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/update-campaigns.html">Updating a campaign</a>. For more information about campaigns, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/campaigns.html">Creating a campaign</a>.</p>

    Args:
        campaign_arn: <p>The Amazon Resource Name (ARN) of the campaign.</p>
        solution_version_arn: <p>The Amazon Resource Name (ARN) of a new model to deploy. To specify the latest solution version of your solution, specify the ARN of your <i>solution</i> in <code>SolutionArn/$LATEST</code> format. You must use this format if you set <code>syncWithLatestSolutionVersion</code> to <code>True</code> in the <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_CampaignConfig.html">CampaignConfig</a>. </p> <p> To deploy a model that isn't the latest solution version of your solution, specify the ARN of the solution version. </p> <p> For more information about automatic campaign updates, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/campaigns.html#create-campaign-automatic-latest-sv-update">Enabling automatic campaign updates</a>. </p>
        min_provisioned_tps: <p>Specifies the requested minimum provisioned transactions (recommendations) per second that Amazon Personalize will support. A high <code>minProvisionedTPS</code> will increase your bill. We recommend starting with 1 for <code>minProvisionedTPS</code> (the default). Track your usage using Amazon CloudWatch metrics, and increase the <code>minProvisionedTPS</code> as necessary.</p>
        campaign_config: <p>The configuration details of a campaign.</p>

    Raises:
        capo_personalize.errors.invalid_input_exception.InvalidInputException: <p>Provide a valid value for the field or parameter.</p>
        capo_personalize.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource is in use.</p>
        capo_personalize.errors.resource_not_found_exception.ResourceNotFoundException: <p>Could not find the specified resource.</p>
        capo_personalize.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_personalize.types.update_campaign_request.UpdateCampaignRequest]",
    ) -> OperationResponse[
        "capo_personalize.types.update_campaign_response.UpdateCampaignResponse"
    ]:
        import capo_personalize._operations.amazon_personalize.update_campaign

        output, http_response = (
            capo_personalize._operations.amazon_personalize.update_campaign.update_campaign(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateCampaign")
    )
    input_: capo_personalize.types.update_campaign_request.UpdateCampaignRequest = {
        "campaign_arn": campaign_arn
    }
    if solution_version_arn is not None:
        input_["solution_version_arn"] = solution_version_arn
    if min_provisioned_tps is not None:
        input_["min_provisioned_tps"] = min_provisioned_tps
    if campaign_config is not None:
        input_["campaign_config"] = campaign_config

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