Skip to content

create_batch_inference_job async

create_batch_inference_job(
    job_name: Name,
    solution_version_arn: Arn,
    job_input: BatchInferenceJobInput,
    job_output: BatchInferenceJobOutput,
    role_arn: RoleArn,
    *,
    config_overrides: Optional[AsyncPersonalizeClientConfig] = None,
    filter_arn: Optional[Arn] = None,
    num_results: Optional[NumBatchResults] = None,
    batch_inference_job_config: Optional[BatchInferenceJobConfig] = None,
    tags: Optional[Tags] = None,
    batch_inference_job_mode: Optional[BatchInferenceJobMode] = None,
    theme_generation_config: Optional[ThemeGenerationConfig] = None,
) -> CreateBatchInferenceJobResponse

Generates batch recommendations based on a list of items or users stored in Amazon S3 and exports the recommendations to an Amazon S3 bucket.

To generate batch recommendations, specify the ARN of a solution version and an Amazon S3 URI for the input and output data. For user personalization, popular items, and personalized ranking solutions, the batch inference job generates a list of recommended items for each user ID in the input file. For related items solutions, the job generates a list of recommended items for each item ID in the input file.

For more information, see Creating a batch inference job .

If you use the Similar-Items recipe, Amazon Personalize can add descriptive themes to batch recommendations. To generate themes, set the job's mode to THEME_GENERATION and specify the name of the field that contains item names in the input data.

For more information about generating themes, see Batch recommendations with themes from Content Generator .

You can't get batch recommendations with the Trending-Now or Next-Best-Action recipes.

Parameters:

  • job_name (Name) –

    The name of the batch inference job to create.

  • solution_version_arn (Arn) –

    The Amazon Resource Name (ARN) of the solution version that will be used to generate the batch inference recommendations.

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

    The ARN of the filter to apply to the batch inference job. For more information on using filters, see Filtering batch recommendations.

  • num_results (Optional[NumBatchResults], default: None ) –

    The number of recommendations to retrieve.

  • job_input (BatchInferenceJobInput) –

    The Amazon S3 path that leads to the input file to base your recommendations on. The input material must be in JSON format.

  • job_output (BatchInferenceJobOutput) –

    The path to the Amazon S3 bucket where the job's output will be stored.

  • role_arn (RoleArn) –

    The ARN of the Amazon Identity and Access Management role that has permissions to read and write to your input and output Amazon S3 buckets respectively.

  • batch_inference_job_config (Optional[BatchInferenceJobConfig], default: None ) –

    The configuration details of a batch inference job.

  • tags (Optional[Tags], default: None ) –

    A list of tags to apply to the batch inference job.

  • batch_inference_job_mode (Optional[BatchInferenceJobMode], default: None ) –

    The mode of the batch inference job. To generate descriptive themes for groups of similar items, set the job mode to THEME_GENERATION. If you don't want to generate themes, use the default BATCH_INFERENCE.

    When you get batch recommendations with themes, you will incur additional costs. For more information, see Amazon Personalize pricing.

  • theme_generation_config (Optional[ThemeGenerationConfig], default: None ) –

    For theme generation jobs, specify the name of the column in your Items dataset that contains each item's name.

Raises:

Source code in docs_src/capo_personalize/_services/async_personalize.py
async def create_batch_inference_job(
    self,
    job_name: "capo_personalize.types.name.Name",
    solution_version_arn: "capo_personalize.types.arn.Arn",
    job_input: "capo_personalize.types.batch_inference_job_input.BatchInferenceJobInput",
    job_output: "capo_personalize.types.batch_inference_job_output.BatchInferenceJobOutput",
    role_arn: "capo_personalize.types.role_arn.RoleArn",
    *,
    config_overrides: Optional[AsyncPersonalizeClientConfig] = None,
    filter_arn: Optional["capo_personalize.types.arn.Arn"] = None,
    num_results: Optional[
        "capo_personalize.types.num_batch_results.NumBatchResults"
    ] = None,
    batch_inference_job_config: Optional[
        "capo_personalize.types.batch_inference_job_config.BatchInferenceJobConfig"
    ] = None,
    tags: Optional["capo_personalize.types.tags.Tags"] = None,
    batch_inference_job_mode: Optional[
        "capo_personalize.types.batch_inference_job_mode.BatchInferenceJobMode"
    ] = None,
    theme_generation_config: Optional[
        "capo_personalize.types.theme_generation_config.ThemeGenerationConfig"
    ] = None,
) -> "capo_personalize.types.create_batch_inference_job_response.CreateBatchInferenceJobResponse":
    """<p>Generates batch recommendations based on a list of items or users stored in Amazon S3 and exports the recommendations to an Amazon S3 bucket.</p> <p>To generate batch recommendations, specify the ARN of a solution version and an Amazon S3 URI for the input and output data. For user personalization, popular items, and personalized ranking solutions, the batch inference job generates a list of recommended items for each user ID in the input file. For related items solutions, the job generates a list of recommended items for each item ID in the input file.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/getting-batch-recommendations.html">Creating a batch inference job </a>.</p> <p> If you use the Similar-Items recipe, Amazon Personalize can add descriptive themes to batch recommendations. To generate themes, set the job's mode to <code>THEME_GENERATION</code> and specify the name of the field that contains item names in the input data.</p> <p> For more information about generating themes, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/themed-batch-recommendations.html">Batch recommendations with themes from Content Generator </a>. </p> <p>You can't get batch recommendations with the Trending-Now or Next-Best-Action recipes.</p>

    Args:
        job_name: <p>The name of the batch inference job to create.</p>
        solution_version_arn: <p>The Amazon Resource Name (ARN) of the solution version that will be used to generate the batch inference recommendations.</p>
        filter_arn: <p>The ARN of the filter to apply to the batch inference job. For more information on using filters, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter-batch.html">Filtering batch recommendations</a>.</p>
        num_results: <p>The number of recommendations to retrieve.</p>
        job_input: <p>The Amazon S3 path that leads to the input file to base your recommendations on. The input material must be in JSON format.</p>
        job_output: <p>The path to the Amazon S3 bucket where the job's output will be stored.</p>
        role_arn: <p>The ARN of the Amazon Identity and Access Management role that has permissions to read and write to your input and output Amazon S3 buckets respectively.</p>
        batch_inference_job_config: <p>The configuration details of a batch inference job.</p>
        tags: <p>A list of <a href="https://docs.aws.amazon.com/personalize/latest/dg/tagging-resources.html">tags</a> to apply to the batch inference job.</p>
        batch_inference_job_mode: <p>The mode of the batch inference job. To generate descriptive themes for groups of similar items, set the job mode to <code>THEME_GENERATION</code>. If you don't want to generate themes, use the default <code>BATCH_INFERENCE</code>.</p> <p> When you get batch recommendations with themes, you will incur additional costs. For more information, see <a href="https://aws.amazon.com/personalize/pricing/">Amazon Personalize pricing</a>. </p>
        theme_generation_config: <p>For theme generation jobs, specify the name of the column in your Items dataset that contains each item's name.</p>

    Raises:
        capo_personalize.errors.invalid_input_exception.InvalidInputException: <p>Provide a valid value for the field or parameter.</p>
        capo_personalize.errors.limit_exceeded_exception.LimitExceededException: <p>The limit on the number of requests per second has been exceeded.</p>
        capo_personalize.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The specified resource already exists.</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.too_many_tags_exception.TooManyTagsException: <p>You have exceeded the maximum number of tags you can apply to this resource. </p>
        capo_personalize.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_personalize.types.create_batch_inference_job_request.CreateBatchInferenceJobRequest]",
    ) -> AsyncOperationResponse[
        "capo_personalize.types.create_batch_inference_job_response.CreateBatchInferenceJobResponse"
    ]:
        import capo_personalize._operations.amazon_personalize.create_batch_inference_job

        (
            output,
            http_response,
        ) = await capo_personalize._operations.amazon_personalize.create_batch_inference_job.async_create_batch_inference_job(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_personalize.types.create_batch_inference_job_request.CreateBatchInferenceJobRequest",
    ) -> dict[str, Any]:
        import capo_personalize.types.create_batch_inference_job_request

        return capo_personalize.types.create_batch_inference_job_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateBatchInferenceJob", redact_input=_redact_input),
    )
    input_: capo_personalize.types.create_batch_inference_job_request.CreateBatchInferenceJobRequest = {
        "job_name": job_name,
        "solution_version_arn": solution_version_arn,
        "job_input": job_input,
        "job_output": job_output,
        "role_arn": role_arn,
    }
    if filter_arn is not None:
        input_["filter_arn"] = filter_arn
    if num_results is not None:
        input_["num_results"] = num_results
    if batch_inference_job_config is not None:
        input_["batch_inference_job_config"] = batch_inference_job_config
    if tags is not None:
        input_["tags"] = tags
    if batch_inference_job_mode is not None:
        input_["batch_inference_job_mode"] = batch_inference_job_mode
    if theme_generation_config is not None:
        input_["theme_generation_config"] = theme_generation_config

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