Package: biomero
BIOMERO - BioImage analysis in OMEROTheBIOMEROframework, forBioImage analysis inOMERO, allows you to run (FAIR) bioimage analysis workflows directly from OMERO on a high-performance compute (HPC) cluster, remotely through SSH.The BIOMERO framework consists of this Python librarybiomero, together with theBIOMERO scriptsthat can be run directly from the OMERO web interface.The package includes theSlurmClientclass, which providesSSH-based connectivityand interaction with aSlurm(high-performance compute) cluster. The package enables users to submit jobs, monitor job status, retrieve job output, and perform other Slurm-related tasks. Additionally, the package offers functionality for configuring and managing paths to Slurm data and Singularity images (think Docker containers...), as well as specific FAIR image analysis workflows and their associated repositories.Overall, thebiomeropackage simplifies the integration of HPC functionality within the OMERO platform for admins and provides an efficient and end-user-friendly interface towards both the HPC and FAIR workflows.WARNING: Default settings will timeout your workflow jobs after45 minutes! SeeTime Limit on Slurmsection below for more info. Change configurations if you need longer running jobs.OverviewIn the figure below we show ourBIOMEROframework, forBioImage analysis inOMERO.BIOMERO consists of this Python library (biomero) and the integrations within OMERO, currently through ourBIOMERO scripts.QuickstartFor a quick overview of what this library can do for you, we can install an example setup locally with Docker:Setup a local OMERO w/ this library:Follow Quickstart ofhttps://github.com/Cellular-Imaging-Amsterdam-UMC/NL-BIOMEROSetup a local Slurm w/ SSH access:Follow Quickstart ofhttps://github.com/TorecLuik/slurm-docker-clusterUpload some data with OMERO.insight tolocalhostserver (... we are working on a web importer ... TBC)Try out some scripts fromhttps://github.com/NL-BioImaging/biomero-scripts(already installed in step 1!):Run scriptslurm/init/SLURM Init environment...Get a coffee or something. This will take at least 10 min to download all the workflow images. Maybe write a nice review onimage.scof this software, or here on theDiscussionstab of Github.Select your image / dataset and run scriptslurm/workflows/SLURM Run Workflow...Select at least one of theSelect how to import your results, e.g. changeImport into NEW Datasettext tohello worldSelect a fun workflow, e.g.cellpose.Change thenuc channelto the channel to segment (note that 0 is for grey, so 1,2,3 for RGB)Uncheck theuse gpu(step 2, our HPC cluster, doesn't come with GPU support built into the containers)Refresh your OMEROExploretab to see yourhello worlddataset with a mask image when the workflow is done!Prerequisites & Getting Started with BIOMEROSlurm RequirementsNote: This library has only been tested on Slurm versions 21.08.6 and 22.05.09 !Your Slurm cluster/login node needs to have:SSH access w/ public key (headless)SCP access (generally comes with SSH)7zip installedSingularity/Apptainer installed(Optional) Git installed, if you want your own job scriptsOMERO RequirementsYour OMEROprocessingnode needs to have:SSH client and access to the Slurm cluster (w/ private key / headless)SCP access to the Slurm clusterPython3.7+This library installedLatest release on PyPIpython3 -m pip install biomeroor latest Github versionpython3 -m pip install 'git+https://github.com/NL-BioImaging/biomero'uration setup at/etc/slurm-.iniRequirements for some scripts:python3 -m pip install ezomero==1.1.1 tifffile==2020.9.3and theOMERO CLI Zarr plugin.Your OMEROservernode needs to have:Some OMERO example scripts installed to interact with this library:My examples on github:https://github.com/NL-BioImaging/biomero-scriptsInstall those at/opt/omero/server/OMERO.server/lib/scripts/slurm/, e.g.git clone https://github.com/NL-BioImaging/biomero-scripts.git <path>/slurm!!NOTE: Do not installExample Minimal Slurm Scriptif you do not trust your users with your Slurm cluster. It has literal Command Injection for the SSH user as aFEATURE.Getting StartedTo connect an OMERO processor to a Slurm cluster using thebiomerolibrary, users can follow these steps:Setup passwordless public key authentication between your OMEROprocessorserver and your HPC server. E.g. follow  aSSH tutorialorthis one.You could use 1 Slurm account for allprocessorservers, and share the same private key to all of them.Or you could use unique accounts, but give them all the same alias in step 2.Create a SSH config file namedconfigin the.sshdirectory of (all) the OMEROprocessorservers, within theomerouser's home directory (~/.ssh/config). This file should specify the hostname, username, port, and private key path for the Slurm cluster, under some alias. This alias we will provide to the library. We provide an example in theresourcesdirectory.This will allow a uniform SSH naming, and makes the connection headless; making it easy for the library.Test the SSH connection manually!ssh slurm(as the omero user) should connect you to the Slurm server (given that you named itslurmin theconfig).Congratulations! Now the servers are connected. Next, we make sure to setup the connection between OMERO and Slurm.At this point, ensure that theslurm-config.inifile is correctly configured with the necessary SSH and Slurm settings, including the host, data path, images path, and model details. Customize the configuration according to the specific Slurm cluster setup. We provide an example in theresourcessection. To read it automatically, place thisinifile in one of the following locations (on the OMEROprocessorserver):/etc/slurm-config.ini~/slurm-config.iniInstall OMERO scripts fromOMERO Slurm Scripts, e.g.cd OMERO_DIST/lib/scriptsgit clone https://github.com/NL-BioImaging/biomero-scripts.git slurm!!NOTE: Do not installExample Minimal Slurm Scriptif you do not trust your users with your Slurm cluster. It has literal Command Injection for the SSH user as aFEATURE.InstallBIOMERO Scriptsrequirements, e.g.python3 -m pip install ezomero==1.1.1 tifffile==2020.9.3theOMERO CLI Zarr plugin, e.g.python3 -m pip install omero-cli-zarr==0.5.3&&yum install -y blosc-develthebioformats2raw-0.7.0, e.g.unzip -d /opt bioformats2raw-0.7.0.zip && export PATH="$PATH:/opt/bioformats2raw-0.7.0/bin"To finish setting up yourSlurmClientand Slurm server, run it once withinit_slurm=True. This is provided in a OMERO script form atinit/Slurm Init environment, which you just installed in previous step.Provide the configfile location explicitly if it is not a default one defined earlier, otherwise you can omit that field.Please note the requirements for your Slurm cluster. We do not install Singularity / 7zip on your cluster for you (at the time of writing).This operation will make it create the directories you provided in theslurm-config.ini, pull any described Singularity images to the server (note: might take a while), and generate (or clone from Git) any job scripts for these workflows:withSlurmClient.from_config(configfile=configfile,init_slurm=True)asslurmClient:slurmClient.validate(validate_slurm_setup=True)With the configuration files in place, you can utilize theSlurmClientclass from thebiomerolibrary to connect to the Slurm cluster over SSH, enabling the submission and management of Slurm jobs from an OMERO processor.BIOMERO scriptsThe easiest interaction from OMERO with this library currently is through our BIOMERO scripts, which are just a set of OMERO scripts using this library for all the steps one needs to run a image analysis workflow from OMERO on Slurm and retrieve the results back into OMERO.!!NOTE: Do not installExample Minimal Slurm Scriptif you do not trust your users with your Slurm cluster. It has literal Command Injection for the SSH user as aFEATURE.We have provided the BIOMERO scripts athttps://github.com/NL-BioImaging/biomero-scripts(hopefully installed in a previous step).For example,workflows/Slurm Run Workflowshould provide an easy way to send data to Slurm, run the configured and chosen workflow, poll Slurm until jobs are done (or errors) and retrieve the results when the job is done. This workflow script uses some of the other scripts, likedata/Slurm Image Transfer: to export your selected images / dataset / screen as TIFF files to a Slurm dir.data/Slurm Get Results: to import your Slurm job results back into OMERO as a zip, dataset or attachment.Other example OMERO scripts are:data/Slurm Get Update: to run while you are waiting on a job to finish on Slurm; it will try to get a%progress from your job's logfile. Depends on your job/workflow logging a%of course.workflows/Slurm Run Workflow Batched: This will allow you to run severalworkflows/Slurm Run Workflowin parallel, by batching your input images into smaller chunks (e.g. turn 64 images into 2 batches of 32 images each). It will then poll all these jobs.workflows/Slurm CellPose Segmentation: This is a more primitive script that only runs the actual workflowCellPose(if correctly configured). You will need to manually transfer data first (withSlurm Image Transfer) and manually retrieve data afterward (withSlurm Get Results).You are encouraged to create your own custom scripts. Do note the copy-left license enforced by OME.(Docker) containersWe host BIOMERO container dockerfiles atNL-BIOMERO, which publishes container images to our public dockerhubcellularimagingcf. Specifically thecellularimagingcf/biomeroimage is an OMERO processor container with BIOMERO library installed. When we release a new version of BIOMERO, we will also release a new version of these containers (because we deploy these locally at our Core Facility - Cellular Imaging).You can mount your specific configurations over those in the container, for example:# Run the biomero container
echo "Starting BIOMERO..."
podman run -d --rm --name biomero \
  -e CONFIG_omero_master_host=omeroserver \
  -e OMERO_WORKER_NAME=biomero \
  -e CONFIG_omero_logging_level=10 \
  --network omero \
  --volume /mnt/datadisk/omero:/OMERO \
  --volume /mnt/data:/data \
  --volume /my/slurm-config.ini:/etc/slurm-config.ini \
  --secret ssh-config,target=/tmp/.ssh/config --secret ssh-key,target=/tmp/.ssh/id_rsa --secret ssh-pubkey,target=/tmp/.ssh/id_rsa.pub  --secret ssh-known_hosts,target=/tmp/.ssh/known_hosts \
  --userns=keep-id:uid=1000,gid=997 \
  cellularimagingcf/biomero:0.2.3This will spin up the docker container (in Podman) with omero config (-e CONFIG_omero_..), mounting the required data drives (--volume /mnt/...) and adding a new slurm config (--volume /my/slurm-config.ini:/etc/slurm-config.ini) and the required SSH settings (--secret ...,target=/tmp/.ssh/...) to access the remote HPC.Note: theBIOMERO scriptsare installed on themain server, not on the BIOMERO processor.Note2: We will also update these containers with our own desired changes, so they will likely not be 1:1 copy with basic omero containers. Especially when we start making a nicer UI for BIOMERO. We will keep up-to-date with the OMERO releases when possible.See the tutorialsI have also provided tutorials on connecting to a Local or Cloud Slurm, and tutorials on how to add your FAIR workflows to this setup. Those can give some more insights as well.SSHNote: this library is built forSSH-based connections. If you could, it would be a lot easier to just have the OMEROprocessorserver and theslurmclient server be (on) the same machine: then you can just directly callsbatchand otherslurmcommands from OMERO scripts and Slurm would have better access to your data.This is mainly for those cases where you already have an external HPC cluster and want to connect your OMERO instance.Theoretically, you could extend theSlurmClientclass and change theruncommands to not use SSH, but just asubprocess. We might implement this if we need it in the future.
But then you could also look at other Python libraries likesubmitit.SlurmClient classThe SlurmClient class is the main entrypoint in using this library.
It is a Python class that extends the Connection class from the Fabric library. It allows connecting to and interacting with a Slurm cluster over SSH.It includes attributes for specifying paths to directories for Slurm data and Singularity images, as well as specific paths, repositories, and Dockerhub information for different Singularity image models.The class provides methods for running commands on the remote Slurm host, submitting jobs, checking job status, retrieving job output, and tailing log files.It also offers afrom_configclass method to create aSlurmClientobject by reading configuration parameters from a file. Overall, the class provides a convenient way to work with Slurm clusters and manage job execution and monitoring.slurm-config.iniTheslurm-config.inifile is a configuration file used by thebiomeroPython package to specify various settings related to SSH and Slurm. Here is a brief description of its contents:[SSH]: This section contains SSH settings, including the alias for the SLURM SSH connection (host). Additional SSH configuration can be specified in the user's SSH config file or in/etc/fabric.yml.[SLURM]: This section includes settings specific to Slurm. It defines the paths on the SLURM entrypoint for storing data files (slurm_data_path), container image files (slurm_images_path), and Slurm job scripts (slurm_script_path). It also specifies the repository (slurm_script_repo) from which to pull the Slurm scripts.[MODELS]: This section is used to define different model settings. Each model has a unique key and requires corresponding values for<key>_repo(repository containing the descriptor.json file, which will describe parameters and where to find the image), and<key>_job(jobscript name and location in theslurm_script_repo). The example shows settings for several segmentation models, including Cellpose, Stardist, CellProfiler, DeepCell, and ImageJ.Note also that you can override the default Slurm job values using this model configuration, like memory, GPU, time limit, etc.
All values for sbatch can be applied (see e.g.here) and will be forwarded to the job command.For example# Run CellPose Slurm with 10 GB GPU
cellpose_job_gres=gpu:1g.10gb:1
# Run CellPose Slurm with 15 GB CPU memory
cellpose_job_mem=15GBTheslurm-config.inifile allows users to configure paths, repositories, and other settings specific to their Slurm cluster and thebiomeropackage, providing flexibility and customization options.Time Limit on SlurmAn important Slurm job config is the time limit:SBATCH --time=00:45:00is the default in BIOMERO (max 45 minutes per job).
The format isd-hh:mm:ssWARNING: After this time, the job will timeout and this scenario is not handled by BIOMERO (yet)! You will lose your processing progress.You can change this timeout value:For ALL workflows, in thejob_template.sh(e.g.#SBATCH --time=08:00:00for 8 hours)For ONE workflow, in theslurm-config.ini(e.g.cellpose_job_time=08:00:00for 8 hours)Per specific run, provide it in the OMERO script UI likeSLURM_CellPose_Segmentation.pyNote that it might take longer for Slurm to schedule your job if you put the time very high, or possibly even make it wait indefinitely (see --time explanation inhttps://slurm.schedmd.com/sbatch.html). We will work on smart timing, but for now it is hardcoded and configurable.How to add an existing workflowTo add an existing (containerized) workflow, add it to theslurm-config.inifile like in our example:# -------------------------------------# CELLPOSE SEGMENTATION# -------------------------------------# The path to store the container on the slurm_images_pathcellpose=cellpose# The (e.g. github) repository with the descriptor.json filecellpose_repo=https://github.com/TorecLuik/W_NucleiSegmentation-Cellpose/tree/v1.2.7# The jobscript in the 'slurm_script_repo'cellpose_job=jobs/cellpose.shHere,the name referenced for this workflow iscellposethe location of the container on slurm will be<slurm_images_path>/cellposethe code repository ishttps://github.com/TorecLuik/W_NucleiSegmentation-Cellposethe specific version we want isv1.2.7the container can be found on bitbucketunder the path given in the metadata file:descriptor.jsonthe location of the jobscript on slurm will be<slurm_script_repo>/jobs/cellpose.sh.This either references a git repo, where it matches this path,or it will be the location where the library will generate a jobscript (if no repo is given)Workflow metadata via descriptor.jsonA lot of the automation in this library is based on metadata of the workflow, provided in the source code of the workflow, specifically thedescriptor.json.For example, the OMERO script UI can be generated automatically, based on this descriptor. And also, the Slurm job script can be generated automatically, based on this descriptor.This metadata scheme is (based on) Cytomine / BIAFLOWS, and you can find details of it and how to create one yourself on their website, e.g. thisCytomine dev-guideor thisBIAFLOWS dev-guide.NOTE!We do not require thecytomine_<...>authentication parameters. They are not mandatory. In fact, we ignore them. But it might be beneficial to make your workflow compatible with Cytomine as well.SchemaAt this point, we are using thecytomine-0.1schema, in the future we will also want to support other schemas, likeBoutiques,commonwlorMLFlow.We will try to stay compatible with all such schemas (perhaps with less functionality because of missing metadata).At this point, we do not strictly validate the schema, we just read expected fields from thedescriptor.json.Multiple versionsNote that while it is possible to have multiple versions of the same workflow on Slurm (and select the desired one in OMERO), it is not possible to configure this yet. We assume for now you only want one version to start with. You can always update this config to download a new version to Slurm.I/OUnless you change theSlurmjob, the input is expected to be:Theinfolderparameterpointing to a folder with multiple input files/imagesThegtfolderparameter (Optional)pointing to aground-truthinput files, generally not needed for prediction / processing purposes.Theoutfolderparameterwhere you write all your output files (to get copied back to OMERO)Wrapper.pyNote that you can also use thewrapper.pysetup from BIAFLOWS to handle the I/O for you:withBiaflowsJob.from_cli(argv)asbj:# Change following to the actual problem class of the workflow...# 1. Prepare data for workflowin_imgs,gt_imgs,in_path,gt_path,out_path,tmp_path=prepare_data(problem_cls,bj,is_2d=True,**bj.flags)# 2. Run image analysis workflowbj.job.update(progress=25,statusComment="Launching workflow...")# Add here the code for running the analysis script# 3. Upload data to BIAFLOWS...# 4. Compute and upload metrics...# 5. Pipeline finished...This wrapper handles the input parameters for you, providing the input images asin_imgs, et cetera. Then you add your commandline call between point 2 and 3, and possibly some preprocessing between point 1 and 2:#add here the code for running the analysis scriptFor example, fromCellposecontainer workflow:...# 2. Run image analysis workflowbj.job.update(progress=25,statusComment="Launching workflow...")# Add here the code for running the analysis scriptprob_thresh=bj.parameters.prob_thresholddiameter=bj.parameters.diametercp_model=bj.parameters.cp_modeluse_gpu=bj.parameters.use_gpuprint(f"Chosen model:{cp_model}| Channel{nuc_channel}| Diameter{diameter}| Cell prob threshold{prob_thresh}| GPU{use_gpu}")cmd=["python","-m","cellpose","--dir",tmp_path,"--pretrained_model",f"{cp_model}","--save_tif","--no_npy","--chan","{:d}".format(nuc_channel),"--diameter","{:f}".format(diameter),"--cellprob_threshold","{:f}".format(prob_thresh)]ifuse_gpu:print("Using GPU!")cmd.append("--use_gpu")status=subprocess.run(cmd)ifstatus.returncode!=0:print("Running Cellpose failed, terminate")sys.exit(1)# Crop to original shapeforbimginin_imgs:shape=resized.get(bimg.filename,None)ifshape:img=imageio.imread(os.path.join(tmp_path,bimg.filename_no_extension+"_cp_masks.tif"))img=img[0:shape[0],0:shape[1]]imageio.imwrite(os.path.join(out_path,bimg.filename),img)else:shutil.copy(os.path.join(tmp_path,bimg.filename_no_extension+"_cp_masks.tif"),os.path.join(out_path,bimg.filename))# 3. Upload data to BIAFLOWSWe get the commandline parameters frombj.parameters(biaflows job) and provide that thecmdcommandline string. Then we run it withsubprocess.run(cmd)and check thestatus.We use atmp_pathto store both input and output, then move the output to theout_pathafter the processing is done.Also note that some preprocessing is done in step 1:# Make sure all images have at least 224x224 dimensions# and that minshape / maxshape * minshape >= 224# 0 = Grayscale (if input RGB, convert to grayscale)# 1,2,3 = rgb channelnuc_channel=bj.parameters.nuc_channelresized={}forbfimginin_imgs:...imageio.imwrite(os.path.join(tmp_path,bfimg.filename),img)Another example is thisimageJwrapper:...# 3. Call the image analysis workflow using the run scriptnj.job.update(progress=25,statusComment="Launching workflow...")command="/usr/bin/xvfb-run java -Xmx6000m -cp /fiji/jars/ij.jar ij.ImageJ --headless --console "\"-macro macro.ijm\"input={}, output={}, radius={}, min_threshold={}\"".format(in_path,out_path,nj.parameters.ij_radius,nj.parameters.ij_min_threshold)return_code=call(command,shell=True,cwd="/fiji")# waits for the subprocess to returnifreturn_code!=0:err_desc="Failed to execute the ImageJ macro (return code:{})".format(return_code)nj.job.update(progress=50,statusComment=err_desc)raiseValueError(err_desc)Once again, just a commandline--headlesscall toImageJ, wrapped in this Python script and this container.How to add your new custom workflowBuilding workflows like this will make them moreFAIR(also forsoftware) and uses best practices like code versioning and containerization!Also take a look at our in-depth tutorial on adding a Cellprofiler pipeline as a workflow to BIOMERO.Here is a shorter version:
Say you have a script in Python and you want to make it available on OMERO and Slurm.These are the steps required:Rewrite your script to be headless / to be executable on the commandline. This requires handling of commandline parameters as input.Make sure the I/O matches the Slurm job, seeprevious chapter.Describe these commandline parameters in adescriptor.json(see previouschapter). E.g.like this.Describe the requirements / environment of your script in arequirements.txt,like this. Make sure to pin your versions for future reproducability!Package your script in a Docker container. E.g.like this.Note: Please watch out for the pitfalls of reproducability with Dockerfiles:Always version your packages!.Publish your source code, Dockerfile and descriptor.json to a new Github repository (free for public repositories). You can generate a new repositoryfrom template, usingthis templateprovided by Neubias (BIAFLOWS). Then replace the input of the files with yours.(Recommended) Publish a new version of your code (e.g. v1.0.0). E.g.like this.Publish your container on Dockerhub (free for public repositories), using the same versioning as your source code.Like thisfrom Windows Docker orlike thisfrom a commandline.(Recommended) Please use a tag that equals your repository version, instead oflatest. This improves reproducability!(Optional) this library grabslatestif the code repository is given no version, but themasterbranch.Follow the steps from the previouschapter:Add details toslurm-config.iniRunSlurmClient.from_config(init_slurm=True)(e.g. the init environment script.)Slurm jobsGenerating jobsBy default,biomerowill generate basic slurm jobs for each workflow, based on the metadata provided indescriptor.jsonand ajob template.
It will replace$PARAMSwith the (non-cytomine_) parameters given indescriptor.json. See also theParameterssection below.How to add your own Slurm jobYou could change thejob templateand generate new jobs, by runningSlurmClient.from_config(init_slurm=True)(orslurmClient.update_slurm_scripts(generate_jobs=True))Or you could add your jobs to aGithub repositoryand reference this inslurm-config.ini, both in the fieldslurm_script_repoand every<workflow>_job:# -------------------------------------# REPOSITORIES# -------------------------------------# A (github) repository to pull the slurm scripts from.## Note:# If you provide no repository, we will generate scripts instead!# Based on the job_template and the descriptor.json#slurm_script_repo=https://github.com/TorecLuik/slurm-scripts[MODELS]# -------------------------------------# Model settings# -------------------------------------# ...# -------------------------------------# CELLPOSE SEGMENTATION# -------------------------------------# The path to store the container on the slurm_images_pathcellpose=cellpose# The (e.g. github) repository with the descriptor.json filecellpose_repo=https://github.com/TorecLuik/W_NucleiSegmentation-Cellpose/tree/v1.2.7# The jobscript in the 'slurm_script_repo'cellpose_job=jobs/cellpose.shYou can update the jobs by callingslurmClient.update_slurm_scripts(), which will pull the repository('s default branch).This might be useful, for example if you have other hardware requirements for your workflow(s) than the default job asks for, or if you want to run more than just 1 singularity container.ParametersThe library will provide the parameters from yourdescriptor.jsonas environment variables to the call. E.g.set DIAMETER=0; sbatch ....Other environment variables provided are:DATA_PATHMade of<slurm_data_path>/<input_folder>. The base dir for data folders for this execution. We expect it to contain/data/in,/data/inand/data/infolders in our template and data transfer setup.IMAGE_PATHMade of<slurm_images_path>/<model_path>, as described inslurm-config.iniIMAGE_VERSIONSINGULARITY_IMAGEAlready uses theIMAGE_VERSIONabove, as<container_name>_<IMAGE_VERSION>.sifWe (potentially) override the following Slurm job settings programmatically:--mail-user={email}(optional)--time={time}(optional)--output=omero-%4j.log(mandatory)We could add more overrides in the future, and perhaps make them available as global configuration variables inslurm-config.ini.BatchingWe can simply useSlurmfor running your workflow 1:1, so 1 job to 1 workflow. This could speed up your workflow already, asSlurmservers are likely equipped with strong CPU and GPU.However,Slurmis also built for parallel processing on multiple (or the same) servers. We can accomplish this by running multiple jobs for 1 workflow. This is simple forembarrassingly paralleltasks, like segmenting multiple images: just provide each job with a different set of input images. If you have 100 images, you could run 10 jobs on 10 images and (given enough resources available for you on Slurm) that could be 10x faster. In theory, you could run 1 job per image, but at some point you run into the overhead cost of Slurm (and OMERO) and it might actually slow down again (as you incur this cost a 100 times instead of 10 times).Using the GPU on SlurmNote, thedefaultSlurm job script will not request any GPU resources.This is because GPU resources are expensive and some programs do not work with GPU.We can insteadenablethe use of GPU by either providing our own Slurm job scripts, or setting an override value inslurm-config.ini:# -------------------------------------# CELLPOSE SEGMENTATION# -------------------------------------# The path to store the container on the slurm_images_pathcellpose=cellpose# The (e.g. github) repository with the descriptor.json filecellpose_repo=https://github.com/TorecLuik/W_NucleiSegmentation-Cellpose/tree/v1.2.7# The jobscript in the 'slurm_script_repo'cellpose_job=jobs/cellpose.sh# Override the default job values for this workflow# Or add a job value to this workflow# If you don't want to override, comment out / delete the line.# Run CellPose Slurm with 10 GB GPUcellpose_job_gres=gpu:1g.10gb:1In fact, any..._job_...=...configuration value will be forwarded to the Slurm commandline.Slurm commandline parameters override those in the script, so the above one requests 1 10GB gpu for Cellpose.E.g. you could also set the time limit higher:# -------------------------------------# CELLPOSE SEGMENTATION# -------------------------------------# The path to store the container on the slurm_images_pathcellpose=cellpose# The (e.g. github) repository with the descriptor.json filecellpose_repo=https://github.com/TorecLuik/W_NucleiSegmentation-Cellpose/tree/v1.2.7# The jobscript in the 'slurm_script_repo'cellpose_job=jobs/cellpose.sh# Override the default job values for this workflow# Or add a job value to this workflow# If you don't want to override, comment out / delete the line.# Run with longer time limitcellpose_job_time=00:30:00Now the CellPose job should run for maximum of 30 minutes, instead of the default.Transfering dataWe have added methods to this library to help with transferring data to theSlurmcluster, using the same SSH connection (via SCP or SFTP).slurmClient.transfer_data(...)Transfer data to the Slurm clusterslurmClient.unpack_data(...)Unpack zip file on the Slurm clusterslurmClient.zip_data_on_slurm_server(...)Zip data on the Slurm clusterslurmClient.copy_zip_locally(...)Transfer (zip) data from the Slurm clusterslurmClient.get_logfile_from_slurm(...)Transfer logfile from the Slurm clusterAnd more; see the docstring ofSlurmClientand example OMERO scripts.Testing the Python codeYou can test the library by installing the extra test dependencies:Create a venv to isolate the python install:python -m venv venvTestInstall OSC with test dependencies:venvTest/Scripts/python -m pip install .[test]Run pytest from this venv:venvTest/Scripts/pytestLoggingDebug logging can be enabled with the standard python logging module, for example with logging.basicConfig():import logging

logging.basicConfig(level='DEBUG')For example in (the__init__of) a script:if__name__=='__main__':logging.basicConfig(level=logging.INFO,format='%(asctime)s-%(name)s-%(levelname)s-%(message)s',stream=sys.stdout)runScript()