Skip to content

Commit 33eb3b7

Browse files
authored
Merge pull request #455 from hotosm/develop
hotfix: image uploading issues in odm
2 parents cea20d0 + b6e029f commit 33eb3b7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/backend/app/projects/image_processing.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,24 @@ async def download_images_from_s3(
132132
get_presigned_url(bucket_name, obj.object_name, 12) for obj in objects
133133
]
134134

135+
total_files = len(object_urls)
135136
async with aiohttp.ClientSession() as session:
136-
for i in range(0, len(object_urls), batch_size):
137+
for i in range(0, total_files, batch_size):
137138
batch = object_urls[i : i + batch_size]
139+
batch_number = i // batch_size + 1
140+
total_batches = (total_files + batch_size - 1) // batch_size
138141

142+
log.info(f"Processing batch {batch_number}/{total_batches}")
139143
tasks = [
140144
self.download_image(
141-
session, url, os.path.join(local_dir, f"file_{i + 1}.jpg")
145+
session, url, os.path.join(local_dir, f"file_{i + j + 1}.jpg")
142146
)
143-
for i, url in enumerate(batch)
147+
for j, url in enumerate(batch)
144148
]
145149
await asyncio.gather(*tasks)
146150

151+
log.info(f"Completed downloading {total_files} images")
152+
147153
def process_new_task(
148154
self,
149155
images: List[str],

0 commit comments

Comments
 (0)