cbrain icon indicating copy to clipboard operation
cbrain copied to clipboard

Add support for specifying prerequisites for tasks created via API

Open prioux opened this issue 3 years ago • 0 comments

The API POST request should support adding prerequisites to newly created tasks. And it should also be supported by the PUT request to update prerequisites for existing tasks.

My suggestions is that a new pseudo-attribute be filled with a structure like this:

"prereqs": {
  "for_setup": {
    "1234": "Completed",
    "1235": "Queued"
  },
  "for_post_processing": {
    "2345": "Completed",
    "2346": "On CPU"
  }
}

This matches almost exactly how prereqs are stored in the task object, except for the fact that the task IDs are not prefixed with the uppercase letter T. (For robustness, the API should also accept them with the "T" present).

The structure itself would NOT be simply copied into the task object; instead the content of the structure must be iterated over and the prereqs reconstructed by invoking add_prerequisites(), and that for each task object created. A find_accessible must be made for the task IDs to make sure the user is not specifying dependencies on tasks that they do not have access to.

Optimization: In the case of creating task arrays, once the prereq structure has been built for the first task, you can simply dup() it for the others.

To remove prerequisites, support a value of "-" or nil in the params.

prioux avatar Jun 01 '21 16:06 prioux