def main():
    """
    Creates and optionally starts an Amazon Lookout for Vision model using
    command line arguments.

    A new project, training dataset, optional test dataset, and model are created.
    After model training is completed, you can use the code in inference.py to try your
    model with an image.
    """
    logging.basicConfig(level=logging.INFO,
                        format="%(levelname)s: %(message)s")
    parser = argparse.ArgumentParser(usage=argparse.SUPPRESS)
    parser.add_argument("project", help="A unique name for your project")
    parser.add_argument(
        "bucket",
        help=
        "The bucket used to upload your manifest files and store training output"
    )
    parser.add_argument(
        "training",
        help="The S3 path where the service gets the training images.")
    parser.add_argument(
        "test",
        nargs="?",
        default=None,
        help="(Optional) The S3 path where the service gets the test images.")
    args = parser.parse_args()

    project_name = args.project
    bucket = args.bucket
    training_images = args.training
    test_images = args.test
    lookoutvision_client = boto3.client("lookoutvision")
    s3_resource = boto3.resource("s3")

    print(f"Storing information in s3://{bucket}/{project_name}/")
    print("Creating project...")
    Projects.create_project(lookoutvision_client, project_name)

    create_dataset(lookoutvision_client, s3_resource, bucket, project_name,
                   training_images, "train")
    if test_images is not None:
        create_dataset(lookoutvision_client, s3_resource, bucket, project_name,
                       test_images, "test")

    # Train the model and optionally start hosting.
    train_model(lookoutvision_client, bucket, project_name)
def test_create_project(make_stubber, error_code):
    lookoutvision_client = boto3.client('lookoutvision')
    lookoutvision_stubber = make_stubber(lookoutvision_client)
    project_name = 'test-project_name'
    project_arn = 'test-arn'

    lookoutvision_stubber.stub_create_project(project_name,
                                              project_arn,
                                              error_code=error_code)

    if error_code is None:
        got_project_arn = Projects.create_project(lookoutvision_client,
                                                  project_name)
        assert got_project_arn == project_arn
    else:
        with pytest.raises(ClientError) as exc_info:
            Projects.create_project(lookoutvision_client, project_name)
        assert exc_info.value.response['Error']['Code'] == error_code