MannLabs / SPARCSpy

9 stars 6 forks source link

GPU usage and numba int64 fix #15

Closed namsaraeva closed 1 year ago

namsaraeva commented 1 year ago

1) Added a line in workflows.py to check if GPU is available, and if yes, use GPU instead of CPU. Gives more flexibility when working on CPU-only cluster.

2) Added a fix for a numba error in segmentation.py to cast all integers to int64, since I had this error when calling our full_union.discard(0) which resulted in overload in numba's ol_set_discard.

namsaraeva commented 1 year ago

There was a bug:

def __init__(
            self,
            location_path,
            *args
            config_path="",
            intermediate_output=False,
            debug=False,
            overwrite=False,
            segmentation_f=None,
            extraction_f=None,
            classification_f=None,
            selection_f=None,
            **kwargs,
    )

Since *args was in between location_path and config_path, calling TimecourseProject(project_location, config_path, ...) with pre-defined config_path as str, threw this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 2
      1 #initialize project
----> 2 project = TimecourseProject(project_location, 
      3                             config_path, 
      4                             segmentation_f=MultithreadedCytosolCellposeTimecourseSegmentation,
      5                             extraction_f=TimecourseHDF5CellExtraction,
      6                             overwrite=False,
      7                             debug=False)

File /fs/gpfs41/lv07/fileset03/home/g_mann/namsaraeva/Packages/viper-core/src/vipercore/pipeline/project.py:409, in TimecourseProject.__init__(self, *args, **kwargs)
    408 def __init__(self, *args, **kwargs):
--> 409     super().__init__(*args, **kwargs)

File /fs/gpfs41/lv07/fileset03/home/g_mann/namsaraeva/Packages/viper-core/src/vipercore/pipeline/project.py:139, in Project.__init__(self, location_path, config_path, intermediate_output, debug, overwrite, segmentation_f, extraction_f, classification_f, selection_f, *args, **kwargs)
    137 # === setup segmentation ===
    138 if self.segmentation_f is not None:
--> 139     if not segmentation_f.__name__ in self.config: 
    140         raise ValueError(f"Config for {segmentation_f.__name__} is missing from the config file")
    142     seg_directory = os.path.join(self.project_location, self.DEFAULT_SEGMENTATION_DIR_NAME)

TypeError: argument of type 'NoneType' is not iterable

Moving *argsbehind solved it.

sophiamaedler commented 1 year ago

Looks good. Nice catch on the project code.