Skip to content

Commit 8e03819

Browse files
committed
Change rename to full rename
1 parent 232cd1d commit 8e03819

1 file changed

Lines changed: 14 additions & 25 deletions

File tree

biomero_importer/utils/importer.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -334,41 +334,29 @@ def to_host_path(container_path: str) -> str | None:
334334
)
335335
)
336336

337-
# Rename decision based on output: compare filename base (handling multi-suffix like .ome.tiff) vs returned name
338-
if name and (full_path or alt_path):
337+
# Rename decision based on output: use the container's full name choice for OMERO
338+
if name and name.strip() and (full_path or alt_path) and local_alt:
339339
file_for_ext = full_path or alt_path
340340
fname = os.path.basename(file_for_ext)
341-
suffixes = PurePath(fname).suffixes # e.g. ['.ome', '.tiff']
342-
ext_combo = ''.join(suffixes)
343-
if ext_combo:
344-
base_no_ext = fname[:-len(ext_combo)]
345-
else:
346-
base_no_ext = os.path.splitext(fname)[0]
347-
348-
desired_base = str(name)
349-
# If desired name already contains the same extension combo, keep it; else append.
350-
if desired_base.endswith(ext_combo):
351-
desired_name_with_ext = desired_base
352-
desired_base_only = desired_base[: -len(ext_combo)] if ext_combo else desired_base
353-
else:
354-
desired_name_with_ext = f"{desired_base}{ext_combo}"
355-
desired_base_only = desired_base
356-
357-
if desired_base_only != base_no_ext and local_alt:
358-
# Store map keyed by the actual local path used for import, value includes extension
341+
desired_name = str(name).strip()
342+
343+
# Only rename if the desired name is different from the current filename
344+
if desired_name != fname:
345+
# Store map keyed by the actual local path used for import
346+
# The container has full control over the OMERO name (including extensions)
359347
rename_map = (
360348
self.data_package.get(
361349
PREPROC_RENAME_MAP_KEY, {}
362350
)
363351
or {}
364352
)
365-
rename_map[str(local_alt)] = desired_name_with_ext
353+
rename_map[str(local_alt)] = desired_name
366354
self.data_package[PREPROC_RENAME_MAP_KEY] = rename_map
367355
self.logger.debug(
368356
(
369-
"Rename needed: base vs name differ; "
370-
f"base='{base_no_ext}', name='{desired_base_only}', ext='{ext_combo}'. "
371-
f"Recorded rename for {local_alt} -> '{desired_name_with_ext}'"
357+
"Rename needed: container specified different name; "
358+
f"original='{fname}', desired='{desired_name}'. "
359+
f"Recorded rename for {local_alt} -> '{desired_name}'"
372360
)
373361
)
374362

@@ -873,8 +861,9 @@ def upload_files(self, conn, file_paths, dataset_id=None, screen_id=None, local_
873861

874862
@connection
875863
def rename_image_if_needed(self, conn, image_id, local_path):
876-
"""Rename Image 1:1 to the preprocessor 'name' using local output path.
864+
"""Rename Image to the full name specified by the preprocessor container.
877865
866+
The container has full control over the OMERO name, including extensions.
878867
Looks up PREPROC_RENAME_MAP_KEY by the processed local path used for import.
879868
Returns True if renamed, else False.
880869
"""

0 commit comments

Comments
 (0)