Skip to content

Commit c2f8807

Browse files
authored
Merge pull request #35 from RachelTucker/OTHER-update-bulk-get-sample
OTHER: fixing indentation problem in bulk get sample which was only retrieving the first object per chunk
2 parents 65a3fda + 29913a0 commit c2f8807

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

samples/gettingData.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import os
1313
import tempfile
14+
import time
1415

1516
from ds3 import ds3
1617

@@ -30,13 +31,13 @@
3031

3132
# create a dictionary to map our retrieved objects to temporary files
3233
# if you want to keep the retreived files on disk, this is not necessary
33-
tempFiles={}
34+
tempFiles = {}
3435

3536
# while we still have chunks to retrieve
3637
while len(chunkIds) > 0:
3738
# get a list of the available chunks that we can get
3839
availableChunks = client.get_job_chunks_ready_for_client_processing_spectra_s3(
39-
ds3.GetJobChunksReadyForClientProcessingSpectraS3Request(bulkGetResult.result['JobId']))
40+
ds3.GetJobChunksReadyForClientProcessingSpectraS3Request(bulkGetResult.result['JobId']))
4041

4142
chunks = availableChunks.result['ObjectsList']
4243

@@ -55,15 +56,15 @@
5556
for obj in chunk['ObjectList']:
5657
# if we haven't create a temporary file for this object yet, create one
5758
if obj['Name'] not in list(tempFiles.keys()):
58-
tempFiles[obj['Name']]=tempfile.mkstemp()
59-
60-
# get the object
61-
objectStream = open(tempFiles[obj['Name']][1], "wb")
62-
client.get_object(ds3.GetObjectRequest(bucketName,
63-
obj['Name'],
64-
objectStream,
65-
offset = int(obj['Offset']),
66-
job = bulkGetResult.result['JobId']))
59+
tempFiles[obj['Name']] = tempfile.mkstemp()
60+
61+
# get the object
62+
objectStream = open(tempFiles[obj['Name']][1], "wb")
63+
client.get_object(ds3.GetObjectRequest(bucketName,
64+
obj['Name'],
65+
objectStream,
66+
offset=int(obj['Offset']),
67+
job=bulkGetResult.result['JobId']))
6768

6869
# iterate over the temporary files, printing out their names, then closing and and removing them
6970
for objName in list(tempFiles.keys()):

0 commit comments

Comments
 (0)