mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-22 12:48:25 +00:00
Fixing failing validation.
This commit is contained in:
parent
9b004d0dc6
commit
ebbb04a1af
@ -114,19 +114,16 @@ def validate_workflow_specification(spec_id, study_id=None, test_until=None):
|
||||
master_spec = WorkflowSpecService().master_spec
|
||||
if study_id is not None:
|
||||
study_model = session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
||||
if study_model is None:
|
||||
raise ApiError(code='invalid_study',
|
||||
message=f"Unable to validate Workflow because the"
|
||||
f" provided study id ({study_id}) does not exist.")
|
||||
statuses = WorkflowProcessor.run_master_spec(master_spec, study_model)
|
||||
if spec_id in statuses and statuses[spec_id]['status'] == 'disabled':
|
||||
raise ApiError(code='disabled_workflow',
|
||||
message=f"This workflow is disabled. {statuses[spec_id]['message']}")
|
||||
ts = time.time()
|
||||
WorkflowService.test_spec(spec_id, study_id, test_until)
|
||||
te = time.time()
|
||||
print('| %2.4f | % s ' % (te - ts, 'validate and complete all fields'))
|
||||
|
||||
ts = time.time()
|
||||
WorkflowService.test_spec(spec_id, study_id, test_until, required_only=True)
|
||||
te = time.time()
|
||||
print('| %2.4f | % s ' % (te - ts, 'validate only with required fields'))
|
||||
|
||||
except ApiError as ae:
|
||||
error = ae
|
||||
|
@ -167,15 +167,6 @@ class WorkflowService(object):
|
||||
# We return message so we can use it in a test
|
||||
return message
|
||||
|
||||
@staticmethod
|
||||
def raise_if_disabled(spec_id, study_id):
|
||||
"""Raise an exception of the workflow is not enabled and can not be executed."""
|
||||
if study_id is not None:
|
||||
study_model = session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
||||
status = StudyService._get_study_status(study_model)
|
||||
if spec_id in status and status[spec_id]['status'] == 'disabled':
|
||||
raise ApiError(code='disabled_workflow', message=f"This workflow is disabled. {status[spec_id]['message']}")
|
||||
|
||||
@staticmethod
|
||||
def test_spec(spec_id, validate_study_id=None, test_until=None, required_only=False):
|
||||
"""Runs a spec through it's paces to see if it results in any errors.
|
||||
@ -189,7 +180,6 @@ class WorkflowService(object):
|
||||
"""
|
||||
|
||||
workflow_model = WorkflowService.make_test_workflow(spec_id, validate_study_id)
|
||||
WorkflowService.raise_if_disabled(spec_id, validate_study_id)
|
||||
try:
|
||||
processor = WorkflowProcessor(workflow_model, validate_only=True)
|
||||
count = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user