createDatasetImportJob method

Future<CreateDatasetImportJobResponse> createDatasetImportJob({
  1. required DataSource dataSource,
  2. required String datasetArn,
  3. required String jobName,
  4. ImportMode? importMode,
  5. bool? publishAttributionMetricsToS3,
  6. String? roleArn,
  7. List<Tag>? tags,
})

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. 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.

Related APIs

May throw InvalidInputException. May throw LimitExceededException. May throw ResourceAlreadyExistsException. May throw ResourceInUseException. May throw ResourceNotFoundException. May throw TooManyTagsException.

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

Parameter datasetArn : The ARN of the dataset that receives the imported data.

Parameter jobName : The name for the dataset import job.

Parameter importMode : 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.

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

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

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

Implementation

Future<CreateDatasetImportJobResponse> createDatasetImportJob({
  required DataSource dataSource,
  required String datasetArn,
  required String jobName,
  ImportMode? importMode,
  bool? publishAttributionMetricsToS3,
  String? roleArn,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonPersonalize.CreateDatasetImportJob'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'dataSource': dataSource,
      'datasetArn': datasetArn,
      'jobName': jobName,
      if (importMode != null) 'importMode': importMode.value,
      if (publishAttributionMetricsToS3 != null)
        'publishAttributionMetricsToS3': publishAttributionMetricsToS3,
      if (roleArn != null) 'roleArn': roleArn,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateDatasetImportJobResponse.fromJson(jsonResponse.body);
}