Story #9684
closed[Crunch2] [API] Add Workflow resource
100%
Description
Overview¶
Workflows serve the same purpose for Crunch v2 that PipelineTemplates do for Crunch v1. They store a parameterized workflow, written in CWL. Clients like Workbench and arvados-cwl-runner can let users browse Workflows, or run a specific Workflow with specified inputs.
Much like PipelineInstances include an instantiated copy of their PipelineTemplate, clients that want to run Workflows are expected to copy the entire workflow text into the right place (e.g., arvados-cwl-runner will make it a parameter of a ContainerRequest; crunch-run will mount that parameter as text inside the running Container).
Functional Requirements¶
Add a Workflow resource to the API server. It supports all the same fields and methods as PipelineTemplate, except that instead of a components
attribute, it has a workflow
attribute. This is a text column, intended to store a CWL workflow in its native YAML representation.
The Workflow has a validation that the workflow
attribute is either "blank" (nil or empty) or is valid YAML. [TODO: Is there an easy way to check that it's valid CWL?] A Workflow with workflow
text that is not good YAML is invalid.
The name
and description
attributes are set automatically from the CWL's label
and doc
fields, respectively, unless explicitly overridden by the client.
- On create, if either attribute is unset, if the
workflow
CWL includes the corresponding field, set our attribute from that value. - On update, if not
attribute_changed?
, andattribute_was
matches the value fromworkflow_was
, set our attribute from the corresponding field in theworkflow
CWL (including setting the attribute to nil if the field is no longer set in theworkflow
CWL).
Yes, this means that if a client manually sets the Workflow'sname
to match thelabel
in the CWL, then updates the CWL, thename
can be updated as well. This is a smidgen less than ideal, but we consider it worth the tradeoff for a simple implementation, and not too confusing anyway.
Update the API documentation to include information about the Workflow resource and methods. It should mention that workflow
should be CWL YAML, and the auto-update behavior of the name
and description
attributes.