Skip to content

Commit 9ed0823

Browse files
anna-grimanna-grim
andauthored
Feat cloud gt (#111)
* feat: read gcs swcs * bug: cloud reading * bug: read zipped swcs * bug: swc readers working * feat: supports cloud data * removed breaks --------- Co-authored-by: anna-grim <[email protected]>
1 parent 90c620b commit 9ed0823

File tree

1 file changed

+16
-0
lines changed
  • src/segmentation_skeleton_metrics/utils

1 file changed

+16
-0
lines changed

src/segmentation_skeleton_metrics/utils/util.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,22 @@ def list_gcs_subdirectories(bucket_name, prefix):
247247
return subdirs
248248

249249

250+
def upload_directory_to_gcs(bucket_name, source_dir, destination_dir):
251+
client = storage.Client()
252+
bucket = client.bucket(bucket_name)
253+
for root, _, files in os.walk(source_dir):
254+
for filename in files:
255+
local_path = os.path.join(root, filename)
256+
257+
# Compute the relative path and GCS destination path
258+
relative_path = os.path.relpath(local_path, start=source_dir)
259+
blob_path = os.path.join(destination_dir, relative_path).replace("\\", "/")
260+
261+
# Upload the file
262+
blob = bucket.blob(blob_path)
263+
blob.upload_from_filename(local_path)
264+
265+
250266
# --- Miscellaneous ---
251267
def get_segment_id(filename):
252268
"""

0 commit comments

Comments
 (0)