aces / cbrain

CBRAIN is a flexible Ruby on Rails framework for accessing and processing of large data on high-performance computing infrastructures.
GNU General Public License v3.0
71 stars 42 forks source link

Refactor Task Status #591

Open crocodoyle opened 7 years ago

crocodoyle commented 7 years ago

Currently Task Status is encoded as a string, and there is sort of a hierarchy defined in the CbrainTask class, as shown below. Testing a Task's status is messy, and there is no easy way to tell if a Task is Started/Stopped, if it can be Restarted, etc. Task Status should be refactored into a class that encodes the strings below into a better hierarchy.

  # List of status for tasks that have completed successfully.
  COMPLETED_STATUS  = [ "Completed" ]

  # List of status for tasks that are proceeding on the normal processing path.
  QUEUED_STATUS     = [ "New", "Standby", "Configured", "Queued", "On Hold", "Suspended", "Data Ready" ] # waiting for something

  # List of status for tasks that are actively processing (in Ruby stages or on CPU on the cluster)
  PROCESSING_STATUS = [ "Setting Up", "On CPU", "Post Processing" ] # actually running code

  # List of status for tasks that are considered active on the normal processing path.
  RUNNING_STATUS    = [ "New", "Setting Up", "Queued", "On CPU", "Data Ready", "Post Processing"] # main path

  # List of status for tasks that have failed.
  FAILED_STATUS     = [ "Failed To Setup", "Failed To PostProcess", "Failed On Cluster",
                        "Failed Setup Prerequisites", "Failed PostProcess Prerequisites",
                        "Terminated" ]

  # List of status for tasks that are on the 'recover' paths.
  RECOVER_STATUS    = [ "Recover Setup",    "Recover Cluster",    "Recover PostProcess",
                        "Recovering Setup", "Recovering Cluster", "Recovering PostProcess" ]

  # List of status for tasks that are on the 'restart' paths.
  RESTART_STATUS    = [ "Restart Setup",    "Restart Cluster",    "Restart PostProcess",
                        "Restarting Setup", "Restarting Cluster", "Restarting PostProcess" ]

  # List of other administrative status.
  OTHER_STATUS      = [ "Preset", "Duplicated" ]

  # List of status for tasks that are executing Ruby code.
  RUBY_STATUS       = [ "Setting Up", "Post Processing",
                        "Recovering Setup", "Recovering Cluster", "Recovering PostProcess",
                        "Restarting Setup", "Restarting Cluster", "Restarting PostProcess" ]

  # List of status for tasks that active in any way.
  ACTIVE_STATUS    = QUEUED_STATUS | PROCESSING_STATUS | RECOVER_STATUS | RESTART_STATUS

  # List of all status keywords.
  ALL_STATUS       = ACTIVE_STATUS | COMPLETED_STATUS | RUNNING_STATUS | FAILED_STATUS | OTHER_STATUS
prioux commented 7 years ago

That could be a very good idea, but it has to be done properly, with seemless integration.