nielsboecker / HoloRepository-Core

A system for transforming medical imaging studies into holograms, storing them in the cloud and providing them to other systems.
GNU Affero General Public License v3.0
6 stars 8 forks source link

PIPELINE: Major refactoring needed [WIP] #45

Closed nielsboecker closed 5 years ago

nielsboecker commented 5 years ago

Description

Our HoloPipelines code base has some major flaws, which already lead to architectural and maintanance-wise problems:

Suggested solution

Major refactoring! :rocket:

Suggested new structure

/core/
   pipelines.controller.py                  # Only for direct local invocation
   main.server.py                           # Just to listen to endpoints and then
                                            # delegate to other files, like
                                            # jobs.controller or jobs_status
   jobs.controller.py                       # Start pipelines in production
   jobs_status.py                           # Keep track of jobs (could maybe
                                            # be kept in jobs.controller instead)
   garbage_collector.py                     # Perform the "clean up" for jobs

   /pipelines/
      bone_segmentation.pipeline.py
      abdominal_organs_segmentation.pipeline.py
      lung_segmentation.pipeline.py
      airway_segmentation.pipeline.py
      README.md                             # Descriptions of each pipeline, like 
                                            # in HoloPipelines/models/README.md

      /config/
         pipelines_list.json
         io_paths.py
         config.ini

      /tasks/
         /shared/
            receive_input.task.py
            dispatch_output.task.py
            resample_numpy.task.py
            rotate_numpy.task.py
            crop_numpy.task.py
            downscale_numpy.task.py
            convert_format.task.py
            simplify_mesh.task.py           # fast quadratic mesh simplification

         /bone_segmentation/
            segment_bone.task.py

         /abdominal_organs_segmentation/
            segment_abdominal_organs.task.py
            split_to_separate_organs.task.py  # probably out-of-scope
            colour_organs.task.py             # probably out-of-scope
            merge_separate_organs.task.py     # probably out-of-scope

         /lung_segmentation/
            segment_lung.task.py

         /airway_segmentation/
            segment_airway.task.py

      /services/
         format_conversion.service.py       # contains methods: 
                                            # - transform_dicom_to_nifty,
                                            # - transform_dicom_to_numpy, 
                                            # - transform_nifty_to_numpy, 
                                            # - transform_numpy_to_obj

      /wrappers/
         obj2gltf.wrapper.py
         lung_and_airway_segmentation.wrapper.py # Even though it's python code, we use
                                            # existing work as-is, so let's wrap it
         simplifier.wrapper.py              # Yet to implement

      /clients/
         http.client.py                     # does the technical network calls

      /adapters/
         niftynet.adapter.py                # uses http client to call "/model"

Files to delete

Open questions

nielsboecker commented 5 years ago

@boonwj Would appreciate your feedback on my ideas, and also if I forgot any key issues.

@UdomkarnBoonyaprasert you know this component best. Think about any potential issues this refactoring could create and how we could solve them, please.

nielsboecker commented 5 years ago

Update: The foo_bar.type.py naming scheme won't work because not valid python. Just leave out the postfix, through the directory / module name, it is obvious what kind of component it is.