CellProfiler / CellProfiler-plugins

Community-contributed and experimental CellProfiler modules.
http://plugins.cellprofiler.org/
56 stars 68 forks source link

RunCellpose unable to run headless #248

Closed jenna-tomkinson closed 5 months ago

jenna-tomkinson commented 5 months ago

Issue

When trying to use a pipeline that has the RunCellpose module, @MikeLippincott and I are running into an issue where it seems the cellprofiler-core is not finding this module, thus not allowing the pipeline to run properly. We are seeing this error in our logs:

Failed to load pipeline
Traceback (most recent call last):
  File "/home/lippincm/miniconda3/envs/cellprofiler_timelapse_env/lib/python3.8/site-packages/cellprofiler_core/pipeline/_pipeline.py", line 543, in setup_modules
    module = self.setup_module(
  File "/home/lippincm/miniconda3/envs/cellprofiler_timelapse_env/lib/python3.8/site-packages/cellprofiler_core/pipeline/_pipeline.py", line 569, in setup_module
    module = self.instantiate_module(module_name)
  File "/home/lippincm/miniconda3/envs/cellprofiler_timelapse_env/lib/python3.8/site-packages/cellprofiler_core/pipeline/_pipeline.py", line 197, in instantiate_module
    return instantiate_module(module_name)
  File "/home/lippincm/miniconda3/envs/cellprofiler_timelapse_env/lib/python3.8/site-packages/cellprofiler_core/utilities/core/modules/__init__.py", line 180, in instantiate_module
    module = get_module_class(module_name)()
  File "/home/lippincm/miniconda3/envs/cellprofiler_timelapse_env/lib/python3.8/site-packages/cellprofiler_core/utilities/core/modules/__init__.py", line 175, in get_module_class
    raise ValueError("Could not find the %s module" % module_class)
ValueError: Could not find the RunCellpose module

It is related to this specific function: https://github.com/CellProfiler/core/blob/9fbb218b018196569b413298db51e72de6c6a013/cellprofiler_core/utilities/core/modules/__init__.py#L128

In a previous project, we were able to run a pipeline with this plugin using CellProfiler v4.2.4. We are currently running with v4.2.6 with this environment file: https://github.com/WayScience/live_cell_timelapse_apoptosis/blob/main/python_env.yml

We appreciate any help with getting this resolved! Thanks!

bethac07 commented 5 months ago

Sanity check - what is the specific CellProfiler command line call generating this error?

jenna-tomkinson commented 5 months ago

Great point! I developed a utility file to run CellProfiler headless in parallel seen here: https://github.com/WayScience/live_cell_timelapse_apoptosis/blob/main/utils/cp_parallel.py

It calls this command line, where the parameters of the function fill in the paths:

command = [
            "cellprofiler",
            "-c",
            "-r",
            "-p",
            path_to_pipeline,
            "-o",
            path_to_output,
            "-i",
            path_to_images,
        ]
bethac07 commented 5 months ago

When running headless, you also have to add a flag pointing to the plugin directory if using plugins - does your script take care of that? If not, that's likely your issue!

jenna-tomkinson commented 5 months ago

Ahh, you are totally right, Beth! I found it right here in the CellProfiler wiki: https://github.com/CellProfiler/CellProfiler/wiki/Adapting-CellProfiler-to-a-LIMS-environment#cellprofiler-command-line-switches. Looks like I hadn't incorporated the flag into my script yet, glad to finally catch it. :fishing_pole_and_fish:

Thank you lots! 🙌 This should definitely fix the error, so I will close this issue now.