in files/lambda_code/call_cm_other_models_lambda.py [0:0]
def lambda_handler(event, context):
#uncomment to log event info
#logging.info(json.dumps(event))
filename=event['Records'][0]['s3']['object']['key']
filename_basename=os.path.basename(filename)
content=read_in_file_from_s3(NOTIFICATION_BUCKET_NAME,filename)
content_2=call_comprehehend_medical(the_input=content.decode("utf-8") ,call_type='detect_entities_v2') #decode to prevent error
custom_predictions=call_custom_comprehend_model(the_input=content.decode("utf-8"),endpoint_arn=COMPREHEND_CUSTOM_ENDPOINT)
content_3=copy.deepcopy(content_2) #make copy to avoid modifying original dictionary
content_3['Medical_Specialty_Prediction']=custom_predictions
content_4=search_dict_for_breast_cancer_genes(the_dict=content_3)
breast_cancer_genes_found=search_raw_text_for_breast_cancer_genes(raw_text=content.decode("utf-8"))
content_4['BREAST_CANCER_GENE_PREDICTIONS']=breast_cancer_genes_found
#export final output
#logging.info(json.dumps(content_4))
put_file_in_s3(f'''{filename_basename}_out''',json.dumps(content_4),OUTPUT_BUCKET_NAME)
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}