mammoth-rainbow-82717
11/08/2023, 3:58 PMget_many. Is that right?
Also, a related question, is there a reason that this function returns a list and doesn't yield instead?victorious-lawyer-58417
11/08/2023, 4:04 PMget_many would do the trickvictorious-lawyer-58417
11/08/2023, 4:05 PMmammoth-rainbow-82717
11/08/2023, 4:12 PM_get method seems to be an iterator. You are saying it will download all of the data regardless of that being an iterator?mammoth-rainbow-82717
11/08/2023, 4:26 PMclever-eve-42433
11/08/2023, 4:58 PMfull_path = f"s3://{s3_bucket}/{path}"
with S3(s3root=full_path, tmproot=output_path) as s3:
list_of_files = s3.list_paths()
# not all the files are the same size so shuffling for uniform distribution among batch
random.shuffle(list_of_files)
batched = [
list_of_files[i : i + sublist_size]
for i in range(0, len(list_of_files), sublist_size)
]
for i, batch in enumerate(batched):
with S3(s3root=full_path, tmproot=output_path) as s3:
[
os.rename(s3obj.path, os.path.join(output_path, s3obj.key))
for s3obj in s3.get_many(batch)
]
I have been running into issue with memory limits. To try and resolve this I implemented the batching strategy yet the memory is not cleared after the context manager has closedambitious-bird-15073
11/08/2023, 5:00 PM