Skip to content

create_flywheel

create_flywheel(
    flywheel_name: ComprehendArnName,
    data_access_role_arn: IamRoleArn,
    data_lake_s3_uri: FlywheelS3Uri,
    *,
    config_overrides: Optional[ComprehendClientConfig] = None,
    active_model_arn: Optional[ComprehendModelArn] = None,
    task_config: Optional[TaskConfig] = None,
    model_type: Optional[ModelType] = None,
    data_security_config: Optional[DataSecurityConfig] = None,
    client_request_token: Optional[ClientRequestTokenString] = None,
    tags: Optional[TagList] = None,
) -> CreateFlywheelResponse

A flywheel is an Amazon Web Services resource that orchestrates the ongoing training of a model for custom classification or custom entity recognition. You can create a flywheel to start with an existing trained model, or Comprehend can create and train a new model.

When you create the flywheel, Comprehend creates a data lake in your account. The data lake holds the training data and test data for all versions of the model.

To use a flywheel with an existing trained model, you specify the active model version. Comprehend copies the model's training data and test data into the flywheel's data lake.

To use the flywheel with a new model, you need to provide a dataset for training data (and optional test data) when you create the flywheel.

For more information about flywheels, see Flywheel overview in the Amazon Comprehend Developer Guide.

Parameters:

  • flywheel_name (ComprehendArnName) –

    Name for the flywheel.

  • active_model_arn (Optional[ComprehendModelArn], default: None ) –

    To associate an existing model with the flywheel, specify the Amazon Resource Number (ARN) of the model version. Do not set TaskConfig or ModelType if you specify an ActiveModelArn.

  • data_access_role_arn (IamRoleArn) –

    The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend the permissions required to access the flywheel data in the data lake.

  • task_config (Optional[TaskConfig], default: None ) –

    Configuration about the model associated with the flywheel. You need to set TaskConfig if you are creating a flywheel for a new model.

  • model_type (Optional[ModelType], default: None ) –

    The model type. You need to set ModelType if you are creating a flywheel for a new model.

  • data_lake_s3_uri (FlywheelS3Uri) –

    Enter the S3 location for the data lake. You can specify a new S3 bucket or a new folder of an existing S3 bucket. The flywheel creates the data lake at this location.

  • data_security_config (Optional[DataSecurityConfig], default: None ) –

    Data security configurations.

  • client_request_token (Optional[ClientRequestTokenString], default: None ) –

    A unique identifier for the request. If you don't set the client request token, Amazon Comprehend generates one.

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

    The tags to associate with this flywheel.

Raises:

Source code in docs_src/capo_comprehend/_services/comprehend.py
def create_flywheel(
    self,
    flywheel_name: "capo_comprehend.types.comprehend_arn_name.ComprehendArnName",
    data_access_role_arn: "capo_comprehend.types.iam_role_arn.IamRoleArn",
    data_lake_s3_uri: "capo_comprehend.types.flywheel_s3_uri.FlywheelS3Uri",
    *,
    config_overrides: Optional[ComprehendClientConfig] = None,
    active_model_arn: Optional[
        "capo_comprehend.types.comprehend_model_arn.ComprehendModelArn"
    ] = None,
    task_config: Optional["capo_comprehend.types.task_config.TaskConfig"] = None,
    model_type: Optional["capo_comprehend.types.model_type.ModelType"] = None,
    data_security_config: Optional[
        "capo_comprehend.types.data_security_config.DataSecurityConfig"
    ] = None,
    client_request_token: Optional[
        "capo_comprehend.types.client_request_token_string.ClientRequestTokenString"
    ] = None,
    tags: Optional["capo_comprehend.types.tag_list.TagList"] = None,
) -> "capo_comprehend.types.create_flywheel_response.CreateFlywheelResponse":
    """<p>A flywheel is an Amazon Web Services resource that orchestrates the ongoing training of a model for custom classification or custom entity recognition. You can create a flywheel to start with an existing trained model, or Comprehend can create and train a new model.</p> <p>When you create the flywheel, Comprehend creates a data lake in your account. The data lake holds the training data and test data for all versions of the model.</p> <p>To use a flywheel with an existing trained model, you specify the active model version. Comprehend copies the model's training data and test data into the flywheel's data lake.</p> <p>To use the flywheel with a new model, you need to provide a dataset for training data (and optional test data) when you create the flywheel.</p> <p>For more information about flywheels, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/flywheels-about.html"> Flywheel overview</a> in the <i>Amazon Comprehend Developer Guide</i>.</p>

    Args:
        flywheel_name: <p>Name for the flywheel.</p>
        active_model_arn: <p>To associate an existing model with the flywheel, specify the Amazon Resource Number (ARN) of the model version. Do not set <code>TaskConfig</code> or <code>ModelType</code> if you specify an <code>ActiveModelArn</code>.</p>
        data_access_role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend the permissions required to access the flywheel data in the data lake.</p>
        task_config: <p>Configuration about the model associated with the flywheel. You need to set <code>TaskConfig</code> if you are creating a flywheel for a new model.</p>
        model_type: <p>The model type. You need to set <code>ModelType</code> if you are creating a flywheel for a new model.</p>
        data_lake_s3_uri: <p>Enter the S3 location for the data lake. You can specify a new S3 bucket or a new folder of an existing S3 bucket. The flywheel creates the data lake at this location.</p>
        data_security_config: <p>Data security configurations.</p>
        client_request_token: <p>A unique identifier for the request. If you don't set the client request token, Amazon Comprehend generates one.</p>
        tags: <p>The tags to associate with this flywheel.</p>

    Raises:
        capo_comprehend.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_comprehend.errors.invalid_request_exception.InvalidRequestException: <p>The request is invalid.</p>
        capo_comprehend.errors.kms_key_validation_exception.KmsKeyValidationException: <p>The KMS customer managed key (CMK) entered cannot be validated. Verify the key and re-enter it.</p>
        capo_comprehend.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource name is already in use. Use a different name and try your request again.</p>
        capo_comprehend.errors.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>The maximum number of resources per account has been exceeded. Review the resources, and then try your request again.</p>
        capo_comprehend.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource ARN was not found. Check the ARN and try your request again.</p>
        capo_comprehend.errors.resource_unavailable_exception.ResourceUnavailableException: <p>The specified resource is not available. Check the resource and try your request again.</p>
        capo_comprehend.errors.too_many_requests_exception.TooManyRequestsException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
        capo_comprehend.errors.too_many_tags_exception.TooManyTagsException: <p>The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request. </p>
        capo_comprehend.errors.unsupported_language_exception.UnsupportedLanguageException: <p>Amazon Comprehend can't process the language of the input text. For a list of supported languages, <a href="https://docs.aws.amazon.com/comprehend/latest/dg/supported-languages.html">Supported languages</a> in the Comprehend Developer Guide. </p>
        capo_comprehend.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_comprehend.types.create_flywheel_request.CreateFlywheelRequest]",
    ) -> OperationResponse[
        "capo_comprehend.types.create_flywheel_response.CreateFlywheelResponse"
    ]:
        import capo_comprehend._operations.comprehend_20171127.create_flywheel

        output, http_response = (
            capo_comprehend._operations.comprehend_20171127.create_flywheel.create_flywheel(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateFlywheel")
    )
    input_: capo_comprehend.types.create_flywheel_request.CreateFlywheelRequest = {
        "flywheel_name": flywheel_name,
        "data_access_role_arn": data_access_role_arn,
        "data_lake_s3_uri": data_lake_s3_uri,
    }
    if active_model_arn is not None:
        input_["active_model_arn"] = active_model_arn
    if task_config is not None:
        input_["task_config"] = task_config
    if model_type is not None:
        input_["model_type"] = model_type
    if data_security_config is not None:
        input_["data_security_config"] = data_security_config
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token
    if tags is not None:
        input_["tags"] = tags

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