Skip to content

Commit 400eb99

Browse files
anna-grimanna-grim
andauthored
Feat cloud gt (#109)
* feat: read gcs swcs * bug: cloud reading * bug: read zipped swcs --------- Co-authored-by: anna-grim <[email protected]>
1 parent 5660918 commit 400eb99

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/segmentation_skeleton_metrics/utils/swc_util.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,13 @@ def read_from_gcs_swc(self, bucket_name, path):
352352
def read_from_gcs_zips(self, bucket_name, zip_paths):
353353
pbar = tqdm(total=len(zip_paths), desc="Read SWCs")
354354
swc_dicts = deque()
355-
with ThreadPoolExecutor() as executor:
355+
356+
# test
357+
for zip_path in zip_paths:
358+
self.read_from_gcs_zip(bucket_name, zip_path)
359+
pbar.update(1)
360+
361+
with ProcessPoolExecutor() as executor:
356362
# Assign processes
357363
threads = list()
358364
for zip_path in zip_paths:
@@ -394,11 +400,11 @@ def read_from_gcs_zip(self, bucket_name, path):
394400
# Parse Zip
395401
swc_dicts = deque()
396402
zip_content = bucket.blob(path).download_as_bytes()
397-
with ZipFile(BytesIO(zip_content)) as zip_file:
403+
with ZipFile(BytesIO(zip_content), "r") as zip_file:
398404
with ThreadPoolExecutor() as executor:
399405
# Assign threads
400406
threads = list()
401-
for filename in util.list_files_in_zip(zip_content):
407+
for filename in zip_file.namelist():
402408
if self.confirm_read(filename):
403409
threads.append(
404410
executor.submit(

0 commit comments

Comments
 (0)