Merge pull request #475 from sartography/bug/failed_validation
Fixing failing validation.
This commit is contained in:
commit
28e8a4b47e
|
@ -114,19 +114,16 @@ def validate_workflow_specification(spec_id, study_id=None, test_until=None):
|
||||||
master_spec = WorkflowSpecService().master_spec
|
master_spec = WorkflowSpecService().master_spec
|
||||||
if study_id is not None:
|
if study_id is not None:
|
||||||
study_model = session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
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)
|
statuses = WorkflowProcessor.run_master_spec(master_spec, study_model)
|
||||||
if spec_id in statuses and statuses[spec_id]['status'] == 'disabled':
|
if spec_id in statuses and statuses[spec_id]['status'] == 'disabled':
|
||||||
raise ApiError(code='disabled_workflow',
|
raise ApiError(code='disabled_workflow',
|
||||||
message=f"This workflow is disabled. {statuses[spec_id]['message']}")
|
message=f"This workflow is disabled. {statuses[spec_id]['message']}")
|
||||||
ts = time.time()
|
|
||||||
WorkflowService.test_spec(spec_id, study_id, test_until)
|
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)
|
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:
|
except ApiError as ae:
|
||||||
error = ae
|
error = ae
|
||||||
|
|
|
@ -167,15 +167,6 @@ class WorkflowService(object):
|
||||||
# We return message so we can use it in a test
|
# We return message so we can use it in a test
|
||||||
return message
|
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
|
@staticmethod
|
||||||
def test_spec(spec_id, validate_study_id=None, test_until=None, required_only=False):
|
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.
|
"""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)
|
workflow_model = WorkflowService.make_test_workflow(spec_id, validate_study_id)
|
||||||
WorkflowService.raise_if_disabled(spec_id, validate_study_id)
|
|
||||||
try:
|
try:
|
||||||
processor = WorkflowProcessor(workflow_model, validate_only=True)
|
processor = WorkflowProcessor(workflow_model, validate_only=True)
|
||||||
count = 0
|
count = 0
|
||||||
|
|
Loading…
Reference in New Issue