Skip to content

Commit 794590c

Browse files
authored
Add file extensions (#299)
1 parent d2368fc commit 794590c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

vitessce/wrappers.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
from .repr import make_repr
1414

1515

16+
def make_unique_filename(file_ext):
17+
return f"{str(uuid4())}{file_ext}"
18+
19+
1620
def file_path_to_url_path(local_path, prepend_slash=True, path_class=None):
1721
# force_windows is used in tests
1822
url_path = str(PurePosixPath(PurePath(local_path) if path_class is None else path_class(local_path)))
@@ -233,8 +237,8 @@ def __init__(self, img_path=None, offsets_path=None, img_url=None, offsets_url=N
233237
self._transformation_matrix = transformation_matrix
234238
self.is_remote = img_url is not None
235239
self.is_bitmask = is_bitmask
236-
self.local_img_uid = str(uuid4())
237-
self.local_offsets_uid = str(uuid4())
240+
self.local_img_uid = make_unique_filename(".ome.tif")
241+
self.local_offsets_uid = make_unique_filename(".offsets.json")
238242
if img_url is not None and (img_path is not None or offsets_path is not None):
239243
raise ValueError(
240244
"Did not expect img_path or offsets_path to be provided with img_url")
@@ -360,7 +364,7 @@ def __init__(self, csv_path=None, csv_url=None, data_type=None, options=None, co
360364
self._options = options
361365
self._coordination_values = coordination_values
362366
self.is_remote = csv_url is not None
363-
self.local_csv_uid = str(uuid4())
367+
self.local_csv_uid = make_unique_filename(".csv")
364368
if data_type is None:
365369
raise ValueError("Expected data_type to be provided")
366370
if csv_url is not None and csv_path is not None:
@@ -453,7 +457,7 @@ def __init__(self, img_path=None, img_url=None, name="", is_bitmask=False, **kwa
453457
self.is_remote = False
454458
else:
455459
self.is_remote = True
456-
self.local_dir_uid = str(uuid4())
460+
self.local_dir_uid = make_unique_filename(".ome.zarr")
457461

458462
def convert_and_save(self, dataset_uid, obj_i, base_dir=None):
459463
# Only create out-directory if needed
@@ -550,7 +554,7 @@ def __init__(self, adata_path=None, adata_url=None, obs_feature_matrix_path=None
550554
else:
551555
self.is_remote = True
552556
self.zarr_folder = None
553-
self.local_dir_uid = str(uuid4())
557+
self.local_dir_uid = make_unique_filename(".adata.zarr")
554558
self._expression_matrix = obs_feature_matrix_path
555559
self._cell_set_obs_names = obs_set_names
556560
self._mappings_obsm_names = obs_embedding_names
@@ -713,7 +717,7 @@ def __init__(self, zarr_path=None, zarr_url=None, **kwargs):
713717
self.is_remote = False
714718
else:
715719
self.is_remote = True
716-
self.local_dir_uid = str(uuid4())
720+
self.local_dir_uid = make_unique_filename(".multivec.zarr")
717721

718722
def convert_and_save(self, dataset_uid, obj_i, base_dir=None):
719723
# Only create out-directory if needed

0 commit comments

Comments
 (0)