Skip to content

Commit

Permalink
Handle spaces in filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
TorecLuik committed May 8, 2024
1 parent 44719e5 commit 7ef5184
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions data/_SLURM_Image_Transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def save_as_zarr(conn, suuid, image, folder_name=None):

# command = f'omero zarr -s "$CONFIG_omero_master_host" -k "{suuid}" export --bf Image:{image.getId()}'
cmd1 = 'export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:/bin/java::")'
command = f'omero zarr -s "{conn.host}" -k "{suuid}" --output {exp_dir} export Image:{image.getId()}'
command = f'omero zarr -s "{conn.host}" -k "{suuid}" --output "{exp_dir}" export Image:{image.getId()}'
cmd = cmd1 + " && " + command
logger.debug(cmd)
process = subprocess.Popen(
Expand Down Expand Up @@ -589,6 +589,19 @@ def run_script():
'_SLURM_Image_Transfer',
f"""Save multiple images as TIFF or ZARR
in a zip file and export them to SLURM.
Note that TIFF will be a rendered version of your image
as shown in OMERO.web currently: not the original pixel
values. This matters for e.g. Mask images, where each
ROI / mask should be a very specific pixel value.
ZARR will use the specific pixel values of the original
file, but you will need to convert it to a format that
the workflows can read (which is TIFF).
Please use SLURM_Run_Workflow directly instead if you
don't know how to convert ZARR to TIFF on Slurm!
Otherwise, use the conversion job on Slurm to convert.
This runs a script remotely on your SLURM cluster.
Connection ready? {slurmClient.validate()}""",
Expand Down Expand Up @@ -680,7 +693,7 @@ def run_script():

scripts.String(
constants.transfer.FOLDER, grouping="3",
description="Name of folder (and zip file) to store images",
description="Name of folder (and zip file) to store images. Don't use spaces!",
default=constants.transfer.FOLDER_DEFAULT),

version="1.9.0",
Expand Down
2 changes: 2 additions & 0 deletions workflows/SLURM_Run_Workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ def createFileName(client: omscripts.client, conn: BlitzGateway) -> str:

timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
filename = "_".join(objparams)
# Replace spaces with underscores in the filename
filename = filename.replace(" ", "_")
full_filename = f"{filename}_{timestamp}"
logger.debug("Filename: " + full_filename)
return full_filename
Expand Down

0 comments on commit 7ef5184

Please sign in to comment.