Skip to content

Commit

Permalink
Add file extensions (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
keller-mark authored Sep 21, 2023
1 parent d2368fc commit 794590c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions vitessce/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from .repr import make_repr


def make_unique_filename(file_ext):
return f"{str(uuid4())}{file_ext}"


def file_path_to_url_path(local_path, prepend_slash=True, path_class=None):
# force_windows is used in tests
url_path = str(PurePosixPath(PurePath(local_path) if path_class is None else path_class(local_path)))
Expand Down Expand Up @@ -233,8 +237,8 @@ def __init__(self, img_path=None, offsets_path=None, img_url=None, offsets_url=N
self._transformation_matrix = transformation_matrix
self.is_remote = img_url is not None
self.is_bitmask = is_bitmask
self.local_img_uid = str(uuid4())
self.local_offsets_uid = str(uuid4())
self.local_img_uid = make_unique_filename(".ome.tif")
self.local_offsets_uid = make_unique_filename(".offsets.json")
if img_url is not None and (img_path is not None or offsets_path is not None):
raise ValueError(
"Did not expect img_path or offsets_path to be provided with img_url")
Expand Down Expand Up @@ -360,7 +364,7 @@ def __init__(self, csv_path=None, csv_url=None, data_type=None, options=None, co
self._options = options
self._coordination_values = coordination_values
self.is_remote = csv_url is not None
self.local_csv_uid = str(uuid4())
self.local_csv_uid = make_unique_filename(".csv")
if data_type is None:
raise ValueError("Expected data_type to be provided")
if csv_url is not None and csv_path is not None:
Expand Down Expand Up @@ -453,7 +457,7 @@ def __init__(self, img_path=None, img_url=None, name="", is_bitmask=False, **kwa
self.is_remote = False
else:
self.is_remote = True
self.local_dir_uid = str(uuid4())
self.local_dir_uid = make_unique_filename(".ome.zarr")

def convert_and_save(self, dataset_uid, obj_i, base_dir=None):
# Only create out-directory if needed
Expand Down Expand Up @@ -550,7 +554,7 @@ def __init__(self, adata_path=None, adata_url=None, obs_feature_matrix_path=None
else:
self.is_remote = True
self.zarr_folder = None
self.local_dir_uid = str(uuid4())
self.local_dir_uid = make_unique_filename(".adata.zarr")
self._expression_matrix = obs_feature_matrix_path
self._cell_set_obs_names = obs_set_names
self._mappings_obsm_names = obs_embedding_names
Expand Down Expand Up @@ -713,7 +717,7 @@ def __init__(self, zarr_path=None, zarr_url=None, **kwargs):
self.is_remote = False
else:
self.is_remote = True
self.local_dir_uid = str(uuid4())
self.local_dir_uid = make_unique_filename(".multivec.zarr")

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

0 comments on commit 794590c

Please sign in to comment.