I would like to place a csv file in an S3 bucket and get predictions from a Sagemaker model using batch transform job automatically. I would like to do that by using s3 event notification (upon csv upload) to trigger a Lambda function which would do a batch transform job. The lambda function I have written so far is this:
import boto3
sagemaker = boto3.client('sagemaker')
input_data_path = 's3://yeex/upload/examples.csv'.format(default_bucket, 's3://yeex/upload/', 'examples.csv')
output_data_path = 's3://nooz/download/'.format(default_bucket, 's3://nooz/download')
transform_job = sagemaker.transformer.Transformer(
model_name = y_xgboost_21,
instance_count = 1,
instance_type = 'ml.m5.large',
strategy = 'SingleRecord',
assemble_with = 'Line',
output_path = output_data_path,
base_transform_job_name='y-test-batch',
sagemaker_session=sagemaker.Session(),
accept = 'text/csv')
transform_job.transform(data = input_data_path,
content_type = 'text/csv',
split_type = 'Line')
The error it returns is that object sagemaker does not have module transform What is the syntax I should use in Lambda function?
transformeris not a valid method that you can call on asagemakerclient. You can review the available methods here boto3.amazonaws.com/v1/documentation/api/latest/reference/…import sagemaker(not boto3) might work.