commit in intermediate changes to work on a bug

This commit is contained in:
Kelly McDonald 2021-07-26 13:00:11 -04:00
parent 48516e4009
commit b857fddbad
3 changed files with 68 additions and 43 deletions

View File

@ -400,6 +400,19 @@ paths:
summary: Provides a list of workflows specifications that can be added to a study manually. Please note that Protocol Builder will handle this most of the time.
tags:
- Workflow Specifications
parameters :
- name : libraries
in : query
required : false
description : True if we should return just library schemas
schema :
type : boolean
- name : standalone
in : query
required : false
description : True if we should return just standalone schemas
schema :
type : boolean
responses:
'200':
description: An array of workflow specifications
@ -551,36 +564,36 @@ paths:
responses:
'204':
description: The workflow specification has been removed.
/workflow-specification/standalone:
get:
operationId: crc.api.workflow.standalone_workflow_specs
summary: Provides a list of workflow specifications that can be run outside a study.
tags:
- Workflow Specifications
responses:
'200':
description: A list of workflow specifications
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/WorkflowSpec"
/workflow-specification/libraries:
get:
operationId: crc.api.workflow.library_workflow_specs
summary: Provides a list of workflow specifications that are considered libraries.
tags:
- Workflow Specifications
responses:
'200':
description: A list of workflow specifications
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/WorkflowSpec"
# /workflow-specification/standalone:
# get:
# operationId: crc.api.workflow.standalone_workflow_specs
# summary: Provides a list of workflow specifications that can be run outside a study.
# tags:
# - Workflow Specifications
# responses:
# '200':
# description: A list of workflow specifications
# content:
# application/json:
# schema:
# type: array
# items:
# $ref: "#/components/schemas/WorkflowSpec"
# /workflow-specification/libraries:
# get:
# operationId: crc.api.workflow.library_workflow_specs
# summary: Provides a list of workflow specifications that are considered libraries.
# tags:
# - Workflow Specifications
# responses:
# '200':
# description: A list of workflow specifications
# content:
# application/json:
# schema:
# type: array
# items:
# $ref: "#/components/schemas/WorkflowSpec"
/workflow-specification/{spec_id}/validate:
parameters:
- name: spec_id

View File

@ -20,10 +20,22 @@ from crc.services.workflow_processor import WorkflowProcessor
from crc.services.workflow_service import WorkflowService
def all_specifications():
def all_specifications(libraries=False,standalone=False):
if libraries and standalone:
raise ApiError('inconceivable!', 'You should specify libraries or standalone, but not both')
schema = WorkflowSpecModelSchema(many=True)
return schema.dump(session.query(WorkflowSpecModel).filter((WorkflowSpecModel.library==False)|(
WorkflowSpecModel.library==None)).all())
if libraries:
return schema.dump(session.query(WorkflowSpecModel)\
.filter(WorkflowSpecModel.library==True).all())
if standalone:
return schema.dump(session.query(WorkflowSpecModel)\
.filter(WorkflowSpecModel.standalone==True).all())
# this still returns standalone workflow specs as well, but by default
# we do not return specs marked as library
return schema.dump(session.query(WorkflowSpecModel)\
.filter((WorkflowSpecModel.library==False)|(
WorkflowSpecModel.library==None)).all())
def add_workflow_specification(body):
@ -158,15 +170,15 @@ def get_workflow_from_spec(spec_id):
return WorkflowApiSchema().dump(workflow_api_model)
def standalone_workflow_specs():
schema = WorkflowSpecModelSchema(many=True)
specs = WorkflowService.get_standalone_workflow_specs()
return schema.dump(specs)
# def standalone_workflow_specs():
# schema = WorkflowSpecModelSchema(many=True)
# specs = WorkflowService.get_standalone_workflow_specs()
# return schema.dump(specs)
def library_workflow_specs():
schema = WorkflowSpecModelSchema(many=True)
specs = WorkflowService.get_library_workflow_specs()
return schema.dump(specs)
# def library_workflow_specs():
# schema = WorkflowSpecModelSchema(many=True)
# specs = WorkflowService.get_library_workflow_specs()
# return schema.dump(specs)
def get_workflow(workflow_id, do_engine_steps=True):
"""Retrieve workflow based on workflow_id, and return it in the last saved State.

View File

@ -63,11 +63,11 @@ class WorkflowSpecModelSchema(SQLAlchemyAutoSchema):
libraries = marshmallow.fields.Function(lambda obj: [{'id':x.library.id,
'name':x.library.name,
'display_name':x.library.display_name} for x in
obj.libraries] )
obj.libraries] )
parents = marshmallow.fields.Function(lambda obj: [{'id':x.parent.id,
'name':x.parent.name,
'display_name':x.parent.display_name} for x in
obj.parents] )
obj.parents] )
class WorkflowState(enum.Enum):
hidden = "hidden"