Skip to content

Refactor the CbrainTask class hierarchy #1512

@prioux

Description

@prioux

The old traditional class hierarchy for tasks in CBRAIN is messy.

At the top, we have CbrainTask.

Then underneath, we have subclasses that exist in two branches, where only one branch exist depending if the current Rails app is a BrainPortal or a Bourreau. The hieracrhy also depends on the type of integration that the task was implemented as (yuk, sentence!)

On a BrainPortal:

  # Standard integration, and old template-based Boutiques integration
  CbrainTask > PortalTask > CbrainTask::ToolName

  # New Boutiques integration
  CbrainTask > PortalTask > BoutiquesPortalTask > BoutiquesTask::ToolName

On a Bourreau, it's similar yet different but not the same yet almost identical:

  # Standard integration, and old template-based Boutiques integration
  CbrainTask > ClusterTask > CbrainTask::ToolName

  # New Boutiques integration
  CbrainTask > ClusterTask > BoutiquesClusterTask > BoutiquesTask::ToolName

The files that implement all the classes are:

  1. CbrainTask : app/models/cbrain_task.rb
  2. PortalTask : app/models/portal_task.rb
  3. BoutiquesPortalTask : app/models/boutiques_portal_task.rb
  4. CbrainTask::ToolName :
    a. (Standard integration): in a plugins, in cbrain_task/toolname/{portal|bourreau|common}/toolname.rb
    b. (Old Boutiques integration): from templates in lib/cbrain_task_generators
  5. BoutiquesPortalTask : app/models/boutiques_portal_task.rb
  6. BoutiquesTask::ToolName : Empty class generated dynamically at boot time
  7. ClusterTask : app/models/cluster_task.rb
  8. BoutiquesClusterTask : app/models/boutiques_cluster_task.rb
  9. BoutiquesTask : cbrain_plugins/cbrain-plugins-base/cbrain_task/boutiques_task/{portal|bourreau}/boutiques_task.rb ; this is an empty class that does not inherit from anything, and is used as a namespace for the other BoutiquesTask::ToolName constants

Now, the ideal refactoring would be to

  1. get rid of the two branches PortalTask vs ClusterTask
  2. move all the methods of these two classes into modules (maybe with the same names)
  3. have the CbrainTask class include one or the other of these now modules depending if we're on a Bourreau or Portal

Some consequences: we will need to either edit the code of all the tasks that are integrated in the standard way, to change e.g. CbrainTask::ToolName < PortalTask into CbrainTask::ToolName < CbrainTask or we can reassign the constants PortalTask and ClusterTask to be synonyms of CbrainTask (in that case, the new modules need new names)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BoutiquesBoutiques integrationPriority: LowTo implement when someone actually requests it!Refactoring

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions