Script to get workflow spec information from a workflow spec id

This commit is contained in:
mike cullerton 2022-02-16 15:54:30 -05:00
parent ec4a86999b
commit fca6eb1582
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
from crc.api.common import ApiError
from crc.models.workflow import WorkflowSpecInfoSchema
from crc.scripts.script import Script
from crc.services.workflow_spec_service import WorkflowSpecService
class ScriptTemplate(Script):
def get_description(self):
return """Get workflow spec information from a workflow spec id"""
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
return self.do_task(task, study_id, workflow_id, *args, **kwargs)
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
if len(args) < 1:
raise ApiError(code='missing_spec_id',
message='The get_spec_from_id script requires a spec_id.')
spec_id = args[0]
workflow_spec = WorkflowSpecService().get_spec(spec_id)
return WorkflowSpecInfoSchema().dump(workflow_spec)