I have a problem with SageMaker when I try to upload Data into S3 bucket . I get this error :
NameError Traceback (most recent call last) <ipython-input-26-d21b1cb0fcab> in <module>() 19 download('http://data.mxnet.io/data/caltech-256/caltech-256-60-train.rec') 20 ---> 21 upload_to_s3('train', 'caltech-256-60-train.rec') <ipython-input-26-d21b1cb0fcab> in upload_to_s3(channel, file) 13 data = open(file, "rb") 14 key = channel + '/' + file ---> 15 s3.Bucket(bucket).put_object(Key=key, Body=data) 16 17 NameError: name 'bucket' is not defined
Here is the script:
import os
import urllib.request
import boto3
def download(url):
filename = url.split("/")[-1]
if not os.path.exists(filename):
urllib.request.urlretrieve(url, filename)
def upload_to_s3(channel, file):
s3 = boto3.resource('s3')
data = open(file, "rb")
key = channel + '/' + file
s3.Bucket(bucket).put_object(Key=key, Body=data)
# caltech-256 download('http://data.mxnet.io/data/caltech-256/caltech-256-60-train.rec')
upload_to_s3('train', 'caltech-256-60-train.rec')
SageMaker provides the compute capacity to build, train and deploy ML models. You can load data from AWS S3 to SageMaker to create, train and deploy models in SageMaker. You can load data from AWS S3 into AWS SageMaker using the Boto3 library. In this tutorial, you’ll learn how to load data from AWS S3 into SageMaker jupyter notebook.
Show activity on this post. One way to solve this would be to save the CSV to the local storage on the SageMaker notebook instance, and then use the S3 API's via boto3 to upload the file as an s3 object. S3 docs for upload_file () available here.
S3 is a storage service from AWS. You can store any type of file such as CSV files or text files. SageMaker provides the compute capacity to build, train and deploy ML models. You can load data from AWS S3 to SageMaker to create, train and deploy models in SageMaker.
Amazon Sagemaker Workshop > Step Functions > Upload the data to S3 First you need to create a bucket for this experiment. Upload the data from the following public location to your own S3 bucket. To facilitate the work of the crawler use two different prefixs (folders): one for the billing information and one for reseller.
It is exactly as the error say, the variable bucket
is not defined.
you might want to do something like
bucket = <name of already created bucket in s3>
before you call
s3.Bucket(bucket).put_object(Key=key, Body=data)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With