Skip to content

create_dataset async

create_dataset(
    dataset_type: DatasetType,
    project_arn: ProjectArn,
    *,
    config_overrides: Optional[AsyncRekognitionClientConfig] = None,
    dataset_source: Optional[DatasetSource] = None,
    tags: Optional[TagMap] = None,
) -> CreateDatasetResponse

This operation applies only to Amazon Rekognition Custom Labels.

Creates a new Amazon Rekognition Custom Labels dataset. You can create a dataset by using an Amazon Sagemaker format manifest file or by copying an existing Amazon Rekognition Custom Labels dataset.

To create a training dataset for a project, specify TRAIN for the value of DatasetType. To create the test dataset for a project, specify TEST for the value of DatasetType.

The response from CreateDataset is the Amazon Resource Name (ARN) for the dataset. Creating a dataset takes a while to complete. Use DescribeDataset to check the current status. The dataset created successfully if the value of Status is CREATE_COMPLETE.

To check if any non-terminal errors occurred, call ListDatasetEntries and check for the presence of errors lists in the JSON Lines.

Dataset creation fails if a terminal error occurs (Status = CREATE_FAILED). Currently, you can't access the terminal error information.

For more information, see Creating dataset in the Amazon Rekognition Custom Labels Developer Guide.

This operation requires permissions to perform the rekognition:CreateDataset action. If you want to copy an existing dataset, you also require permission to perform the rekognition:ListDatasetEntries action.

Parameters:

  • dataset_source (Optional[DatasetSource], default: None ) –

    The source files for the dataset. You can specify the ARN of an existing dataset or specify the Amazon S3 bucket location of an Amazon Sagemaker format manifest file. If you don't specify datasetSource, an empty dataset is created. To add labeled images to the dataset, You can use the console or call UpdateDatasetEntries.

  • dataset_type (DatasetType) –

    The type of the dataset. Specify TRAIN to create a training dataset. Specify TEST to create a test dataset.

  • project_arn (ProjectArn) –

    The ARN of the Amazon Rekognition Custom Labels project to which you want to asssign the dataset.

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

    A set of tags (key-value pairs) that you want to attach to the dataset.

Raises:

  • AccessDeniedException –

    You are not authorized to perform the action.

  • InternalServerError –

    Amazon Rekognition experienced a service issue. Try your call again.

  • InvalidParameterException –

    Input parameter violated a constraint. Validate your parameter before calling the API operation again.

  • InvalidS3ObjectException –

    Amazon Rekognition is unable to access the S3 object specified in the request.

  • LimitExceededException –

    An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: StartLabelDetection) will raise a LimitExceededException exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit.

  • ProvisionedThroughputExceededException –

    The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.

  • ResourceAlreadyExistsException –

    A resource with the specified ID already exists.

  • ResourceNotFoundException –

    The resource specified in the request cannot be found.

  • ThrottlingException –

    Amazon Rekognition is temporarily unable to process the request. Try your call again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To create an Amazon Rekognition Custom Labels dataset Creates an Amazon Rekognition Custom Labels dataset with a manifest file stored in an Amazon S3 bucket.

>>> await client.create_dataset(dataset_source={'GroundTruthManifest': {'S3Object': {'Bucket': 'my-bucket', 'Name': 'datasets/flowers_training/manifests/output/output.manifest'}}}, dataset_type='TRAIN', project_arn='arn:aws:rekognition:us-east-1:111122223333:project/my-project/1690474772815')
Source code in docs_src/capo_rekognition/_services/async_rekognition.py
async def create_dataset(
    self,
    dataset_type: "capo_rekognition.types.dataset_type.DatasetType",
    project_arn: "capo_rekognition.types.project_arn.ProjectArn",
    *,
    config_overrides: Optional[AsyncRekognitionClientConfig] = None,
    dataset_source: Optional[
        "capo_rekognition.types.dataset_source.DatasetSource"
    ] = None,
    tags: Optional["capo_rekognition.types.tag_map.TagMap"] = None,
) -> "capo_rekognition.types.create_dataset_response.CreateDatasetResponse":
    """<note> <p>This operation applies only to Amazon Rekognition Custom Labels.</p> </note> <p>Creates a new Amazon Rekognition Custom Labels dataset. You can create a dataset by using an Amazon Sagemaker format manifest file or by copying an existing Amazon Rekognition Custom Labels dataset.</p> <p>To create a training dataset for a project, specify <code>TRAIN</code> for the value of <code>DatasetType</code>. To create the test dataset for a project, specify <code>TEST</code> for the value of <code>DatasetType</code>. </p> <p>The response from <code>CreateDataset</code> is the Amazon Resource Name (ARN) for the dataset. Creating a dataset takes a while to complete. Use <a>DescribeDataset</a> to check the current status. The dataset created successfully if the value of <code>Status</code> is <code>CREATE_COMPLETE</code>. </p> <p>To check if any non-terminal errors occurred, call <a>ListDatasetEntries</a> and check for the presence of <code>errors</code> lists in the JSON Lines.</p> <p>Dataset creation fails if a terminal error occurs (<code>Status</code> = <code>CREATE_FAILED</code>). Currently, you can't access the terminal error information. </p> <p>For more information, see Creating dataset in the <i>Amazon Rekognition Custom Labels Developer Guide</i>.</p> <p>This operation requires permissions to perform the <code>rekognition:CreateDataset</code> action. If you want to copy an existing dataset, you also require permission to perform the <code>rekognition:ListDatasetEntries</code> action.</p>

    Args:
        dataset_source: <p> The source files for the dataset. You can specify the ARN of an existing dataset or specify the Amazon S3 bucket location of an Amazon Sagemaker format manifest file. If you don't specify <code>datasetSource</code>, an empty dataset is created. To add labeled images to the dataset, You can use the console or call <a>UpdateDatasetEntries</a>. </p>
        dataset_type: <p> The type of the dataset. Specify <code>TRAIN</code> to create a training dataset. Specify <code>TEST</code> to create a test dataset. </p>
        project_arn: <p> The ARN of the Amazon Rekognition Custom Labels project to which you want to asssign the dataset. </p>
        tags: <p>A set of tags (key-value pairs) that you want to attach to the dataset.</p>

    Raises:
        capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</p>
        capo_rekognition.errors.internal_server_error.InternalServerError: <p>Amazon Rekognition experienced a service issue. Try your call again.</p>
        capo_rekognition.errors.invalid_parameter_exception.InvalidParameterException: <p>Input parameter violated a constraint. Validate your parameter before calling the API operation again.</p>
        capo_rekognition.errors.invalid_s3_object_exception.InvalidS3ObjectException: <p>Amazon Rekognition is unable to access the S3 object specified in the request.</p>
        capo_rekognition.errors.limit_exceeded_exception.LimitExceededException: <p>An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: <code>StartLabelDetection</code>) will raise a <code>LimitExceededException</code> exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit. </p>
        capo_rekognition.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.</p>
        capo_rekognition.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>A resource with the specified ID already exists.</p>
        capo_rekognition.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request cannot be found.</p>
        capo_rekognition.errors.throttling_exception.ThrottlingException: <p>Amazon Rekognition is temporarily unable to process the request. Try your call again.</p>
        capo_rekognition.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create an Amazon Rekognition Custom Labels dataset
        Creates an Amazon Rekognition Custom Labels dataset with a manifest file stored in an Amazon S3 bucket.

        >>> await client.create_dataset(dataset_source={'GroundTruthManifest': {'S3Object': {'Bucket': 'my-bucket', 'Name': 'datasets/flowers_training/manifests/output/output.manifest'}}}, dataset_type='TRAIN', project_arn='arn:aws:rekognition:us-east-1:111122223333:project/my-project/1690474772815')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_rekognition.types.create_dataset_request.CreateDatasetRequest]",
    ) -> AsyncOperationResponse[
        "capo_rekognition.types.create_dataset_response.CreateDatasetResponse"
    ]:
        import capo_rekognition._operations.rekognition_service.create_dataset

        (
            output,
            http_response,
        ) = await capo_rekognition._operations.rekognition_service.create_dataset.async_create_dataset(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDataset")
    )
    input_: capo_rekognition.types.create_dataset_request.CreateDatasetRequest = {
        "dataset_type": dataset_type,
        "project_arn": project_arn,
    }
    if dataset_source is not None:
        input_["dataset_source"] = dataset_source
    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