Skip to content

create_dataset_import_job

create_dataset_import_job(
    job_name: Name,
    dataset_arn: Arn,
    data_source: DataSource,
    *,
    config_overrides: Optional[PersonalizeClientConfig] = None,
    role_arn: Optional[RoleArn] = None,
    tags: Optional[Tags] = None,
    import_mode: Optional[ImportMode] = None,
    publish_attribution_metrics_to_s3: Optional[Boolean] = None,
) -> CreateDatasetImportJobResponse

Creates a job that imports training data from your data source (an Amazon S3 bucket) to an Amazon Personalize dataset. To allow Amazon Personalize to import the training data, you must specify an IAM service role that has permission to read from the data source, as Amazon Personalize makes a copy of your data and processes it internally. For information on granting access to your Amazon S3 bucket, see Giving Amazon Personalize Access to Amazon S3 Resources.

If you already created a recommender or deployed a custom solution version with a campaign, how new bulk records influence recommendations depends on the domain use case or recipe that you use. For more information, see How new data influences real-time recommendations.

By default, a dataset import job replaces any existing data in the dataset that you imported in bulk. To add new records without replacing existing data, specify INCREMENTAL for the import mode in the CreateDatasetImportJob operation.

Status

A dataset import job can be in one of the following states:

  • CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

To get the status of the import job, call DescribeDatasetImportJob, providing the Amazon Resource Name (ARN) of the dataset import job. The dataset import is complete when the status shows as ACTIVE. If the status shows as CREATE FAILED, the response includes a failureReason key, which describes why the job failed.

Importing takes time. You must wait until the status shows as ACTIVE before training a model using the dataset.

Related APIs

Parameters:

  • job_name (Name) –

    The name for the dataset import job.

  • dataset_arn (Arn) –

    The ARN of the dataset that receives the imported data.

  • data_source (DataSource) –

    The Amazon S3 bucket that contains the training data to import.

  • role_arn (Optional[RoleArn], default: None ) –

    The ARN of the IAM role that has permissions to read from the Amazon S3 data source.

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

    A list of tags to apply to the dataset import job.

  • import_mode (Optional[ImportMode], default: None ) –

    Specify how to add the new records to an existing dataset. The default import mode is FULL. If you haven't imported bulk records into the dataset previously, you can only specify FULL.

    • Specify FULL to overwrite all existing bulk data in your dataset. Data you imported individually is not replaced.

    • Specify INCREMENTAL to append the new records to the existing data in your dataset. Amazon Personalize replaces any record with the same ID with the new one.

  • publish_attribution_metrics_to_s3 (Optional[Boolean], default: None ) –

    If you created a metric attribution, specify whether to publish metrics for this import job to Amazon S3

Raises:

Source code in docs_src/capo_personalize/_services/personalize.py
def create_dataset_import_job(
    self,
    job_name: "capo_personalize.types.name.Name",
    dataset_arn: "capo_personalize.types.arn.Arn",
    data_source: "capo_personalize.types.data_source.DataSource",
    *,
    config_overrides: Optional[PersonalizeClientConfig] = None,
    role_arn: Optional["capo_personalize.types.role_arn.RoleArn"] = None,
    tags: Optional["capo_personalize.types.tags.Tags"] = None,
    import_mode: Optional["capo_personalize.types.import_mode.ImportMode"] = None,
    publish_attribution_metrics_to_s3: Optional[
        "capo_personalize.types.boolean.Boolean"
    ] = None,
) -> "capo_personalize.types.create_dataset_import_job_response.CreateDatasetImportJobResponse":
    """<p>Creates a job that imports training data from your data source (an Amazon S3 bucket) to an Amazon Personalize dataset. To allow Amazon Personalize to import the training data, you must specify an IAM service role that has permission to read from the data source, as Amazon Personalize makes a copy of your data and processes it internally. For information on granting access to your Amazon S3 bucket, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/granting-personalize-s3-access.html">Giving Amazon Personalize Access to Amazon S3 Resources</a>. </p> <p>If you already created a recommender or deployed a custom solution version with a campaign, how new bulk records influence recommendations depends on the domain use case or recipe that you use. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/how-new-data-influences-recommendations.html">How new data influences real-time recommendations</a>.</p> <important> <p>By default, a dataset import job replaces any existing data in the dataset that you imported in bulk. To add new records without replacing existing data, specify INCREMENTAL for the import mode in the CreateDatasetImportJob operation.</p> </important> <p> <b>Status</b> </p> <p>A dataset import job can be in one of the following states:</p> <ul> <li> <p>CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED</p> </li> </ul> <p>To get the status of the import job, call <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_DescribeDatasetImportJob.html">DescribeDatasetImportJob</a>, providing the Amazon Resource Name (ARN) of the dataset import job. The dataset import is complete when the status shows as ACTIVE. If the status shows as CREATE FAILED, the response includes a <code>failureReason</code> key, which describes why the job failed.</p> <note> <p>Importing takes time. You must wait until the status shows as ACTIVE before training a model using the dataset.</p> </note> <p class="title"> <b>Related APIs</b> </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_ListDatasetImportJobs.html">ListDatasetImportJobs</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_DescribeDatasetImportJob.html">DescribeDatasetImportJob</a> </p> </li> </ul>

    Args:
        job_name: <p>The name for the dataset import job.</p>
        dataset_arn: <p>The ARN of the dataset that receives the imported data.</p>
        data_source: <p>The Amazon S3 bucket that contains the training data to import.</p>
        role_arn: <p>The ARN of the IAM role that has permissions to read from the Amazon S3 data source.</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 dataset import job.</p>
        import_mode: <p>Specify how to add the new records to an existing dataset. The default import mode is <code>FULL</code>. If you haven't imported bulk records into the dataset previously, you can only specify <code>FULL</code>.</p> <ul> <li> <p>Specify <code>FULL</code> to overwrite all existing bulk data in your dataset. Data you imported individually is not replaced.</p> </li> <li> <p>Specify <code>INCREMENTAL</code> to append the new records to the existing data in your dataset. Amazon Personalize replaces any record with the same ID with the new one.</p> </li> </ul>
        publish_attribution_metrics_to_s3: <p>If you created a metric attribution, specify whether to publish metrics for this import job to Amazon S3</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.
    """

    def _handler(
        req: "OperationRequest[capo_personalize.types.create_dataset_import_job_request.CreateDatasetImportJobRequest]",
    ) -> OperationResponse[
        "capo_personalize.types.create_dataset_import_job_response.CreateDatasetImportJobResponse"
    ]:
        import capo_personalize._operations.amazon_personalize.create_dataset_import_job

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

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

        return capo_personalize.types.create_dataset_import_job_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateDatasetImportJob", redact_input=_redact_input),
    )
    input_: capo_personalize.types.create_dataset_import_job_request.CreateDatasetImportJobRequest = {
        "job_name": job_name,
        "dataset_arn": dataset_arn,
        "data_source": data_source,
    }
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if tags is not None:
        input_["tags"] = tags
    if import_mode is not None:
        input_["import_mode"] = import_mode
    if publish_attribution_metrics_to_s3 is not None:
        input_["publish_attribution_metrics_to_s3"] = (
            publish_attribution_metrics_to_s3
        )

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