|
13 | 13 | from .repr import make_repr |
14 | 14 |
|
15 | 15 |
|
| 16 | +def make_unique_filename(file_ext): |
| 17 | + return f"{str(uuid4())}{file_ext}" |
| 18 | + |
| 19 | + |
16 | 20 | def file_path_to_url_path(local_path, prepend_slash=True, path_class=None): |
17 | 21 | # force_windows is used in tests |
18 | 22 | 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 |
233 | 237 | self._transformation_matrix = transformation_matrix |
234 | 238 | self.is_remote = img_url is not None |
235 | 239 | 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") |
238 | 242 | if img_url is not None and (img_path is not None or offsets_path is not None): |
239 | 243 | raise ValueError( |
240 | 244 | "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 |
360 | 364 | self._options = options |
361 | 365 | self._coordination_values = coordination_values |
362 | 366 | self.is_remote = csv_url is not None |
363 | | - self.local_csv_uid = str(uuid4()) |
| 367 | + self.local_csv_uid = make_unique_filename(".csv") |
364 | 368 | if data_type is None: |
365 | 369 | raise ValueError("Expected data_type to be provided") |
366 | 370 | 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 |
453 | 457 | self.is_remote = False |
454 | 458 | else: |
455 | 459 | self.is_remote = True |
456 | | - self.local_dir_uid = str(uuid4()) |
| 460 | + self.local_dir_uid = make_unique_filename(".ome.zarr") |
457 | 461 |
|
458 | 462 | def convert_and_save(self, dataset_uid, obj_i, base_dir=None): |
459 | 463 | # Only create out-directory if needed |
@@ -550,7 +554,7 @@ def __init__(self, adata_path=None, adata_url=None, obs_feature_matrix_path=None |
550 | 554 | else: |
551 | 555 | self.is_remote = True |
552 | 556 | self.zarr_folder = None |
553 | | - self.local_dir_uid = str(uuid4()) |
| 557 | + self.local_dir_uid = make_unique_filename(".adata.zarr") |
554 | 558 | self._expression_matrix = obs_feature_matrix_path |
555 | 559 | self._cell_set_obs_names = obs_set_names |
556 | 560 | self._mappings_obsm_names = obs_embedding_names |
@@ -713,7 +717,7 @@ def __init__(self, zarr_path=None, zarr_url=None, **kwargs): |
713 | 717 | self.is_remote = False |
714 | 718 | else: |
715 | 719 | self.is_remote = True |
716 | | - self.local_dir_uid = str(uuid4()) |
| 720 | + self.local_dir_uid = make_unique_filename(".multivec.zarr") |
717 | 721 |
|
718 | 722 | def convert_and_save(self, dataset_uid, obj_i, base_dir=None): |
719 | 723 | # Only create out-directory if needed |
|
0 commit comments