Category : amazon-web-services

I download a file from S3 like this: s3 = boto3.client(‘s3’) s3.download_file(‘testunzipping’,’DataPump_10000838.zip’,’/tmp/DataPump_10000838.zip’) For now it always works. However, I wanted to add some sort of error handling. How can I check or get an error message if the download fails. How would I know that there’s something wrong? Does boto3 offer any error handling functions? ..

Read more

Previously, I was uploading files to Amazon S3 like this and it worked fine: bucket.upload_fileobj( io.BytesIO(gzipped_content), fileName2, ExtraArgs={"ContentType": "text/plain"}) In this case, fileName2 was placed directly into the bucket’s root folder. Now I want to place fileName2 in sub folders. Like this: bucket/year/month/day/fileName2. I have variables year/month/day saved as strings with me. I tried this: ..

Read more

I’m new to Lambda and Python and I’ve faced an issue with my Lambda function. I have several JSON files stored in a S3 bucket, and I wish to convert all JSON files to CSV format. As I was referring to the Lambda function posted in this tutorial: https://sysadmins.co.za/convert-csv-to-json-files-with-aws-lambda-and-s3-events/ Lambda function: import json import csv ..

Read more

Recently, I have changed account on AWS and faced with weird error in Sagemaker. Basically, I’m just checking xgboost algo with some toy dataset in this manner: from sagemaker import image_uris xgb_image_uri = image_uris.retrieve("xgboost", boto3.Session().region_name, "1") clf = sagemaker.estimator.Estimator(xgb_image_uri, role, 1, ‘ml.c4.2xlarge’, output_path="s3://{}/output".format(session.default_bucket()), sagemaker_session=session) clf.fit(location_data) Then the training job is starting to be executed but ..

Read more

I am trying to create a lambda function with the below code and when I try to deploy and test the function I get errors. the idea I need for the function is that lambda should monitor a folder within s3 to see if the objects are in it for more than 1 hours and ..

Read more