Skip to content

start_ml_model_training_job async

start_ml_model_training_job(
    data_processing_job_id: str,
    train_model_s3_location: str,
    *,
    config_overrides: Optional[AsyncneptunedataClientConfig] = None,
    id: Optional[str] = None,
    previous_model_training_job_id: Optional[str] = None,
    sagemaker_iam_role_arn: Optional[str] = None,
    neptune_iam_role_arn: Optional[str] = None,
    base_processing_instance_type: Optional[str] = None,
    training_instance_type: Optional[str] = None,
    training_instance_volume_size_in_gb: Optional[int] = None,
    training_time_out_in_seconds: Optional[int] = None,
    max_hpo_number_of_training_jobs: Optional[int] = None,
    max_hpo_parallel_training_jobs: Optional[int] = None,
    subnets: Optional[StringList] = None,
    security_group_ids: Optional[StringList] = None,
    volume_encryption_kms_key: Optional[str] = None,
    s3_output_encryption_kms_key: Optional[str] = None,
    enable_managed_spot_training: Optional[bool] = None,
    custom_model_training_parameters: Optional[CustomModelTrainingParameters] = None,
) -> StartMLModelTrainingJobOutput

Creates a new Neptune ML model training job. See Model training using the modeltraining command.

When invoking this operation in a Neptune cluster that has IAM authentication enabled, the IAM user or role making the request must have a policy attached that allows the neptune-db:StartMLModelTrainingJob IAM action in that cluster.

Parameters:

  • id (Optional[str], default: None ) –

    A unique identifier for the new job. The default is An autogenerated UUID.

  • previous_model_training_job_id (Optional[str], default: None ) –

    The job ID of a completed model-training job that you want to update incrementally based on updated data.

  • data_processing_job_id (str) –

    The job ID of the completed data-processing job that has created the data that the training will work with.

  • train_model_s3_location (str) –

    The location in Amazon S3 where the model artifacts are to be stored.

  • sagemaker_iam_role_arn (Optional[str], default: None ) –

    The ARN of an IAM role for SageMaker execution.This must be listed in your DB cluster parameter group or an error will occur.

  • neptune_iam_role_arn (Optional[str], default: None ) –

    The ARN of an IAM role that provides Neptune access to SageMaker and Amazon S3 resources. This must be listed in your DB cluster parameter group or an error will occur.

  • base_processing_instance_type (Optional[str], default: None ) –

    The type of ML instance used in preparing and managing training of ML models. This is a CPU instance chosen based on memory requirements for processing the training data and model.

  • training_instance_type (Optional[str], default: None ) –

    The type of ML instance used for model training. All Neptune ML models support CPU, GPU, and multiGPU training. The default is ml.p3.2xlarge. Choosing the right instance type for training depends on the task type, graph size, and your budget.

  • training_instance_volume_size_in_gb (Optional[int], default: None ) –

    The disk volume size of the training instance. Both input data and the output model are stored on disk, so the volume size must be large enough to hold both data sets. The default is 0. If not specified or 0, Neptune ML selects a disk volume size based on the recommendation generated in the data processing step.

  • training_time_out_in_seconds (Optional[int], default: None ) –

    Timeout in seconds for the training job. The default is 86,400 (1 day).

  • max_hpo_number_of_training_jobs (Optional[int], default: None ) –

    Maximum total number of training jobs to start for the hyperparameter tuning job. The default is 2. Neptune ML automatically tunes the hyperparameters of the machine learning model. To obtain a model that performs well, use at least 10 jobs (in other words, set maxHPONumberOfTrainingJobs to 10). In general, the more tuning runs, the better the results.

  • max_hpo_parallel_training_jobs (Optional[int], default: None ) –

    Maximum number of parallel training jobs to start for the hyperparameter tuning job. The default is 2. The number of parallel jobs you can run is limited by the available resources on your training instance.

  • subnets (Optional[StringList], default: None ) –

    The IDs of the subnets in the Neptune VPC. The default is None.

  • security_group_ids (Optional[StringList], default: None ) –

    The VPC security group IDs. The default is None.

  • volume_encryption_kms_key (Optional[str], default: None ) –

    The Amazon Key Management Service (KMS) key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instances that run the training job. The default is None.

  • s3_output_encryption_kms_key (Optional[str], default: None ) –

    The Amazon Key Management Service (KMS) key that SageMaker uses to encrypt the output of the processing job. The default is none.

  • enable_managed_spot_training (Optional[bool], default: None ) –

    Optimizes the cost of training machine-learning models by using Amazon Elastic Compute Cloud spot instances. The default is False.

  • custom_model_training_parameters (Optional[CustomModelTrainingParameters], default: None ) –

    The configuration for custom model training. This is a JSON object.

Raises:

Source code in docs_src/capo_neptunedata/_services/async_neptunedata.py
async def start_ml_model_training_job(
    self,
    data_processing_job_id: str,
    train_model_s3_location: str,
    *,
    config_overrides: Optional[AsyncneptunedataClientConfig] = None,
    id: Optional[str] = None,
    previous_model_training_job_id: Optional[str] = None,
    sagemaker_iam_role_arn: Optional[str] = None,
    neptune_iam_role_arn: Optional[str] = None,
    base_processing_instance_type: Optional[str] = None,
    training_instance_type: Optional[str] = None,
    training_instance_volume_size_in_gb: Optional[int] = None,
    training_time_out_in_seconds: Optional[int] = None,
    max_hpo_number_of_training_jobs: Optional[int] = None,
    max_hpo_parallel_training_jobs: Optional[int] = None,
    subnets: Optional["capo_neptunedata.types.string_list.StringList"] = None,
    security_group_ids: Optional[
        "capo_neptunedata.types.string_list.StringList"
    ] = None,
    volume_encryption_kms_key: Optional[str] = None,
    s3_output_encryption_kms_key: Optional[str] = None,
    enable_managed_spot_training: Optional[bool] = None,
    custom_model_training_parameters: Optional[
        "capo_neptunedata.types.custom_model_training_parameters.CustomModelTrainingParameters"
    ] = None,
) -> "capo_neptunedata.types.start_ml_model_training_job_output.StartMLModelTrainingJobOutput":
    """<p>Creates a new Neptune ML model training job. See <a href="https://docs.aws.amazon.com/neptune/latest/userguide/machine-learning-api-modeltraining.html">Model training using the <code>modeltraining</code> command</a>.</p> <p>When invoking this operation in a Neptune cluster that has IAM authentication enabled, the IAM user or role making the request must have a policy attached that allows the <a href="https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#startmlmodeltrainingjob">neptune-db:StartMLModelTrainingJob</a> IAM action in that cluster.</p>

    Args:
        id: <p>A unique identifier for the new job. The default is An autogenerated UUID.</p>
        previous_model_training_job_id: <p>The job ID of a completed model-training job that you want to update incrementally based on updated data.</p>
        data_processing_job_id: <p>The job ID of the completed data-processing job that has created the data that the training will work with.</p>
        train_model_s3_location: <p>The location in Amazon S3 where the model artifacts are to be stored.</p>
        sagemaker_iam_role_arn: <p>The ARN of an IAM role for SageMaker execution.This must be listed in your DB cluster parameter group or an error will occur.</p>
        neptune_iam_role_arn: <p>The ARN of an IAM role that provides Neptune access to SageMaker and Amazon S3 resources. This must be listed in your DB cluster parameter group or an error will occur.</p>
        base_processing_instance_type: <p>The type of ML instance used in preparing and managing training of ML models. This is a CPU instance chosen based on memory requirements for processing the training data and model.</p>
        training_instance_type: <p>The type of ML instance used for model training. All Neptune ML models support CPU, GPU, and multiGPU training. The default is <code>ml.p3.2xlarge</code>. Choosing the right instance type for training depends on the task type, graph size, and your budget.</p>
        training_instance_volume_size_in_gb: <p>The disk volume size of the training instance. Both input data and the output model are stored on disk, so the volume size must be large enough to hold both data sets. The default is 0. If not specified or 0, Neptune ML selects a disk volume size based on the recommendation generated in the data processing step.</p>
        training_time_out_in_seconds: <p>Timeout in seconds for the training job. The default is 86,400 (1 day).</p>
        max_hpo_number_of_training_jobs: <p>Maximum total number of training jobs to start for the hyperparameter tuning job. The default is 2. Neptune ML automatically tunes the hyperparameters of the machine learning model. To obtain a model that performs well, use at least 10 jobs (in other words, set <code>maxHPONumberOfTrainingJobs</code> to 10). In general, the more tuning runs, the better the results.</p>
        max_hpo_parallel_training_jobs: <p>Maximum number of parallel training jobs to start for the hyperparameter tuning job. The default is 2. The number of parallel jobs you can run is limited by the available resources on your training instance.</p>
        subnets: <p>The IDs of the subnets in the Neptune VPC. The default is None.</p>
        security_group_ids: <p>The VPC security group IDs. The default is None.</p>
        volume_encryption_kms_key: <p>The Amazon Key Management Service (KMS) key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instances that run the training job. The default is None.</p>
        s3_output_encryption_kms_key: <p>The Amazon Key Management Service (KMS) key that SageMaker uses to encrypt the output of the processing job. The default is none.</p>
        enable_managed_spot_training: <p>Optimizes the cost of training machine-learning models by using Amazon Elastic Compute Cloud spot instances. The default is <code>False</code>.</p>
        custom_model_training_parameters: <p>The configuration for custom model training. This is a JSON object.</p>

    Raises:
        capo_neptunedata.errors.bad_request_exception.BadRequestException: <p>Raised when a request is submitted that cannot be processed.</p>
        capo_neptunedata.errors.client_timeout_exception.ClientTimeoutException: <p>Raised when a request timed out in the client.</p>
        capo_neptunedata.errors.constraint_violation_exception.ConstraintViolationException: <p>Raised when a value in a request field did not satisfy required constraints.</p>
        capo_neptunedata.errors.illegal_argument_exception.IllegalArgumentException: <p>Raised when an argument in a request is not supported.</p>
        capo_neptunedata.errors.invalid_argument_exception.InvalidArgumentException: <p>Raised when an argument in a request has an invalid value.</p>
        capo_neptunedata.errors.invalid_parameter_exception.InvalidParameterException: <p>Raised when a parameter value is not valid.</p>
        capo_neptunedata.errors.missing_parameter_exception.MissingParameterException: <p>Raised when a required parameter is missing.</p>
        capo_neptunedata.errors.ml_resource_not_found_exception.MLResourceNotFoundException: <p>Raised when a specified machine-learning resource could not be found.</p>
        capo_neptunedata.errors.preconditions_failed_exception.PreconditionsFailedException: <p>Raised when a precondition for processing a request is not satisfied.</p>
        capo_neptunedata.errors.too_many_requests_exception.TooManyRequestsException: <p>Raised when the number of requests being processed exceeds the limit.</p>
        capo_neptunedata.errors.unsupported_operation_exception.UnsupportedOperationException: <p>Raised when a request attempts to initiate an operation that is not supported.</p>
        capo_neptunedata.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_neptunedata.types.start_ml_model_training_job_input.StartMLModelTrainingJobInput]",
    ) -> AsyncOperationResponse[
        "capo_neptunedata.types.start_ml_model_training_job_output.StartMLModelTrainingJobOutput"
    ]:
        import capo_neptunedata._operations.amazon_neptune_dataplane.start_ml_model_training_job

        (
            output,
            http_response,
        ) = await capo_neptunedata._operations.amazon_neptune_dataplane.start_ml_model_training_job.async_start_ml_model_training_job(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartMLModelTrainingJob")
    )
    input_: capo_neptunedata.types.start_ml_model_training_job_input.StartMLModelTrainingJobInput = {
        "data_processing_job_id": data_processing_job_id,
        "train_model_s3_location": train_model_s3_location,
    }
    if id is not None:
        input_["id"] = id
    if previous_model_training_job_id is not None:
        input_["previous_model_training_job_id"] = previous_model_training_job_id
    if sagemaker_iam_role_arn is not None:
        input_["sagemaker_iam_role_arn"] = sagemaker_iam_role_arn
    if neptune_iam_role_arn is not None:
        input_["neptune_iam_role_arn"] = neptune_iam_role_arn
    if base_processing_instance_type is not None:
        input_["base_processing_instance_type"] = base_processing_instance_type
    if training_instance_type is not None:
        input_["training_instance_type"] = training_instance_type
    if training_instance_volume_size_in_gb is not None:
        input_["training_instance_volume_size_in_gb"] = (
            training_instance_volume_size_in_gb
        )
    if training_time_out_in_seconds is not None:
        input_["training_time_out_in_seconds"] = training_time_out_in_seconds
    if max_hpo_number_of_training_jobs is not None:
        input_["max_hpo_number_of_training_jobs"] = max_hpo_number_of_training_jobs
    if max_hpo_parallel_training_jobs is not None:
        input_["max_hpo_parallel_training_jobs"] = max_hpo_parallel_training_jobs
    if subnets is not None:
        input_["subnets"] = subnets
    if security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    if volume_encryption_kms_key is not None:
        input_["volume_encryption_kms_key"] = volume_encryption_kms_key
    if s3_output_encryption_kms_key is not None:
        input_["s3_output_encryption_kms_key"] = s3_output_encryption_kms_key
    if enable_managed_spot_training is not None:
        input_["enable_managed_spot_training"] = enable_managed_spot_training
    if custom_model_training_parameters is not None:
        input_["custom_model_training_parameters"] = (
            custom_model_training_parameters
        )

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