Reputation: 1523
I am trying to download a file to sagemaker from my S3 bucket.
the path of the file is
s3://vemyone/input/dicom-images-train/1.2.276.0.7230010.3.1.2.8323329.1000.1517875165.878026/1.2.276.0.7230010.3.1.3.8323329.1000.1517875165.878025/1.2.276.0.7230010.3.1.4.8323329.1000.1517875165.878027.dcm
The path of that file is stored as a list element at train_fns[0]
.
the value of train_fns[0]
is
input/dicom-images-train/1.2.276.0.7230010.3.1.2.8323329.1000.1517875165.878026/1.2.276.0.7230010.3.1.3.8323329.1000.1517875165.878025/1.2.276.0.7230010.3.1.4.8323329.1000.1517875165.878027.dcm
I used the following code:
s3 = boto3.resource('s3')
bucketname = 'vemyone'
s3.Bucket(bucketname).download_file(train_fns[0][:], train_fns[0])
but I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'input/dicom-images-train/1.2.276.0.7230010.3.1.2.8323329.1000.1517875165.878026/1.2.276.0.7230010.3.1.3.8323329.1000.1517875165.878025/1.2.276.0.7230010.3.1.4.8323329.1000.1517875165.878027.dcm.5b003ba1'
I notice that some characters have appended itself at the end of the path.
how do I solve this problem?
Upvotes: 3
Views: 25300
Reputation: 3089
by the doc, first argument is file key, second argument is path for local file:
s3 = boto3.resource('s3')
bucketname = 'vemyone'
s3.Bucket(bucketname).download_file(train_fns[0], '/path/to/local/file')
Upvotes: 3