Beispiel #1
0
def train(obj, input_s3_dir, output_s3_dir, hyperparams_file, ec2_type,
          volume_size, time_out, aws_tags, iam_role_arn, external_id,
          base_job_name, job_name, metric_names):
    """
    Command to train ML model(s) on SageMaker
    """
    logger.info(ASCII_LOGO)
    logger.info("Started training on SageMaker...\n")

    try:
        s3_model_location = api_cloud.train(
            dir=_config().sagify_module_dir,
            input_s3_dir=input_s3_dir,
            output_s3_dir=output_s3_dir,
            hyperparams_file=hyperparams_file,
            ec2_type=ec2_type,
            volume_size=volume_size,
            time_out=time_out,
            docker_tag=obj['docker_tag'],
            tags=aws_tags,
            aws_role=iam_role_arn,
            external_id=external_id,
            base_job_name=base_job_name,
            job_name=job_name,
            metric_names=[_val.strip() for _val in metric_names.split(',')]
            if metric_names else None)

        logger.info("Training on SageMaker succeeded")
        logger.info("Model S3 location: {}".format(s3_model_location))
    except ValueError as e:
        logger.info("{}".format(e))
        sys.exit(-1)
Beispiel #2
0
def train(obj, dir, job_name, input_s3_dir, output_s3_dir, hyperparams_file,
          ec2_type, volume_size, time_out, aws_tags):
    """
    Command to train ML model(s) on SageMaker
    """
    logger.info(ASCII_LOGO)
    logger.info("Started training on SageMaker...\n")

    try:
        s3_model_location = api_cloud.train(dir=dir,
                                            job_name=job_name,
                                            input_s3_dir=input_s3_dir,
                                            output_s3_dir=output_s3_dir,
                                            hyperparams_file=hyperparams_file,
                                            ec2_type=ec2_type,
                                            volume_size=volume_size,
                                            time_out=time_out,
                                            docker_tag=obj['docker_tag'],
                                            tags=aws_tags)

        logger.info("Training on SageMaker succeeded")
        logger.info("Model S3 location: {}".format(s3_model_location))
    except ValueError as e:
        logger.info("{}".format(e))
        sys.exit(-1)