From dbd6e0d1b1a945a4af3bf5f7bc472c0871372186 Mon Sep 17 00:00:00 2001 From: bethac07 Date: Wed, 16 Apr 2025 15:28:19 -0400 Subject: [PATCH 1/3] Draft 1 of Podman --- active_plugins/runcellpose.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/active_plugins/runcellpose.py b/active_plugins/runcellpose.py index 47426d20..73ed14b7 100644 --- a/active_plugins/runcellpose.py +++ b/active_plugins/runcellpose.py @@ -114,19 +114,20 @@ def create_settings(self): text="Rescale images before running Cellpose", value=True, doc="""\ -Reminds the user that the normalization step will be performed to ensure suimilar segmentation behaviour in the RunCellpose +Reminds the user that the normalization step will be performed to ensure similar segmentation behaviour in the RunCellpose module and the Cellpose app. """ ) self.docker_or_python = Choice( - text="Run CellPose in docker or local python environment", - choices=["Docker", "Python"], + text="Run CellPose in a Docker/Podman container or local python environment", + choices=["Docker", "Podman", "Python"], value="Docker", doc="""\ If Docker is selected, ensure that Docker Desktop is open and running on your -computer. On first run of the RunCellpose plugin, the Docker container will be +computer; likewise for Podman, ensure Podman Desktop is running. On first run +of the RunCellpose plugin, the Docker container will be downloaded. However, this slow downloading process will only have to happen once. @@ -393,7 +394,7 @@ def visible_settings(self): vis_settings = [self.rescale, self.docker_or_python] - if self.docker_or_python.value == "Docker": + if self.docker_or_python.value in ["Docker","Podman"]: vis_settings += [self.docker_image] vis_settings += [self.mode, self.x_name] @@ -575,9 +576,12 @@ def run(self, workspace): except Exception as e: print(f"Unable to clear GPU memory. You may need to restart CellProfiler to change models. {e}") - elif self.docker_or_python.value == "Docker": - # Define how to call docker - docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + else: + if self.docker_or_python.value == "Docker": + # Define how to call docker + docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + else: + docker_path = "podman" if sys.platform.lower().startswith("win") else "/opt/podman/bin/podman" # Create a UUID for this run unique_name = str(uuid.uuid4()) # Directory that will be used to pass images to the docker container From a2a6f830865e8061916d97ec16cc216deec8443d Mon Sep 17 00:00:00 2001 From: bethac07 Date: Wed, 16 Apr 2025 15:36:42 -0400 Subject: [PATCH 2/3] First draft of changes for ilastik --- active_plugins/runilastik.py | 46 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/active_plugins/runilastik.py b/active_plugins/runilastik.py index 8f5499da..d43c4675 100644 --- a/active_plugins/runilastik.py +++ b/active_plugins/runilastik.py @@ -83,11 +83,12 @@ def create_settings(self): self.docker_or_local = Choice( text="Run ilastik in docker or local environment", - choices=["Docker", "Local"], + choices=["Docker", "Podman", "Local"], value="Docker", doc="""\ If Docker is selected, ensure that Docker Desktop is open and running on your -computer. On first run of the Runilastik plugin, the Docker container will be +computer; likewise for Podman, ensure Podman Desktop is running. On first run +of the Runilastik plugin, the Docker container will be downloaded. However, this slow downloading process will only have to happen once. @@ -165,7 +166,7 @@ def settings(self): def visible_settings(self): vis_settings = [self.docker_or_local] - if self.docker_or_local.value == "Docker": + if self.docker_or_local.value in ["Docker","Podman"]: vis_settings += [self.docker_choice] if self.docker_choice == "select your own": @@ -225,9 +226,27 @@ def run(self, workspace): fout.close() - if self.docker_or_local.value == "Docker": - # Define how to call docker - docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + if self.docker_or_local.value == "Local": + + if self.executable.value[-4:] == ".app": + executable = os.path.join(self.executable.value, "Contents/MacOS/ilastik") + else: + executable = self.executable.value + + fout_name = fout.name + fin_name = fin.name + + cmd = [ + executable, + "--headless", + "--project", self.project_file.value] + + else: + if self.docker_or_local.value == "Docker": + # Define how to call docker + docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + else: + docker_path = "podman" if sys.platform.lower().startswith("win") else "/opt/podman/bin/podman" # The project file is stored in a directory which can be pointed to the docker model_file = self.project_file.value model_directory = os.path.dirname(os.path.abspath(model_file)) @@ -250,21 +269,6 @@ def run(self, workspace): "--project", f"/model/{os.path.basename(model_file)}" ] - if self.docker_or_local.value == "Local": - - if self.executable.value[-4:] == ".app": - executable = os.path.join(self.executable.value, "Contents/MacOS/ilastik") - else: - executable = self.executable.value - - fout_name = fout.name - fin_name = fin.name - - cmd = [ - executable, - "--headless", - "--project", self.project_file.value] - cmd += ["--output_format", "hdf5"] From eb0668fd354fbac9074b769d050524f0c87d0873 Mon Sep 17 00:00:00 2001 From: bethac07 Date: Wed, 16 Apr 2025 18:01:59 -0400 Subject: [PATCH 3/3] update docstring --- active_plugins/runilastik.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active_plugins/runilastik.py b/active_plugins/runilastik.py index d43c4675..f26d88c3 100644 --- a/active_plugins/runilastik.py +++ b/active_plugins/runilastik.py @@ -82,7 +82,7 @@ def create_settings(self): super(Runilastik, self).create_settings() self.docker_or_local = Choice( - text="Run ilastik in docker or local environment", + text="Run ilastik in a container (Docker or Podman) or local environment", choices=["Docker", "Podman", "Local"], value="Docker", doc="""\