Skip to content

create_batch_segment_job async

create_batch_segment_job(
    job_name: Name,
    solution_version_arn: Arn,
    job_input: BatchSegmentJobInput,
    job_output: BatchSegmentJobOutput,
    role_arn: RoleArn,
    *,
    config_overrides: Optional[AsyncPersonalizeClientConfig] = None,
    filter_arn: Optional[Arn] = None,
    num_results: Optional[NumBatchResults] = None,
    tags: Optional[Tags] = None,
) -> CreateBatchSegmentJobResponse

Creates a batch segment job. The operation can handle up to 50 million records and the input file must be in JSON format. For more information, see Getting batch recommendations and user segments.

Parameters:

  • job_name (Name) –

    The name of the batch segment job to create.

  • solution_version_arn (Arn) –

    The Amazon Resource Name (ARN) of the solution version you want the batch segment job to use to generate batch segments.

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

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

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

    The number of predicted users generated by the batch segment job for each line of input data. The maximum number of users per segment is 5 million.

  • job_input (BatchSegmentJobInput) –

    The Amazon S3 path for the input data used to generate the batch segment job.

  • job_output (BatchSegmentJobOutput) –

    The Amazon S3 path for the 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.

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

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

Raises:

Source code in docs_src/capo_personalize/_services/async_personalize.py
async def create_batch_segment_job(
    self,
    job_name: "capo_personalize.types.name.Name",
    solution_version_arn: "capo_personalize.types.arn.Arn",
    job_input: "capo_personalize.types.batch_segment_job_input.BatchSegmentJobInput",
    job_output: "capo_personalize.types.batch_segment_job_output.BatchSegmentJobOutput",
    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,
    tags: Optional["capo_personalize.types.tags.Tags"] = None,
) -> "capo_personalize.types.create_batch_segment_job_response.CreateBatchSegmentJobResponse":
    """<p>Creates a batch segment job. The operation can handle up to 50 million records and the input file must be in JSON format. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/recommendations-batch.html">Getting batch recommendations and user segments</a>.</p>

    Args:
        job_name: <p>The name of the batch segment job to create.</p>
        solution_version_arn: <p>The Amazon Resource Name (ARN) of the solution version you want the batch segment job to use to generate batch segments.</p>
        filter_arn: <p>The ARN of the filter to apply to the batch segment 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 predicted users generated by the batch segment job for each line of input data. The maximum number of users per segment is 5 million.</p>
        job_input: <p>The Amazon S3 path for the input data used to generate the batch segment job.</p>
        job_output: <p>The Amazon S3 path for the 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>
        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 segment job.</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_segment_job_request.CreateBatchSegmentJobRequest]",
    ) -> AsyncOperationResponse[
        "capo_personalize.types.create_batch_segment_job_response.CreateBatchSegmentJobResponse"
    ]:
        import capo_personalize._operations.amazon_personalize.create_batch_segment_job

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

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

        return capo_personalize.types.create_batch_segment_job_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateBatchSegmentJob", redact_input=_redact_input),
    )
    input_: capo_personalize.types.create_batch_segment_job_request.CreateBatchSegmentJobRequest = {
        "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 tags is not None:
        input_["tags"] = tags

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