yadage / yadage-schemas

schemas for packtivity and yadage for use in cap
MIT License
2 stars 1 forks source link

yadage-validate exit codes #4

Closed tiborsimko closed 7 years ago

tiborsimko commented 7 years ago

We'd like to use yadage-validate in Travis CI recipes. I noticed that yadage always returns exit code 0 even in case of failures.

Example with good YAML:

$ yadage-validate world_population_analysis.yaml 
workflow validates against schema
$ echo $?
0

Example with bad YAML:

$ yadage-validate invalid.yaml 
ERROR:yadage.validator_workflow:validation error
Traceback (most recent call last):
  File "/home/simko/.virtualenvs/yadage/lib/python2.7/site-packages/yadage/validator_workflow.py", line 36, in main
    workflow, toplevel=toplevel, schemadir=schemadir, validate=True)
  File "/home/simko/.virtualenvs/yadage/lib/python2.7/site-packages/yadage/workflow_loader.py", line 5, in workflow
    data = yadageschemas.load(source, toplevel, schema_name, schemadir, validate)
  File "/home/simko/.virtualenvs/yadage/lib/python2.7/site-packages/yadageschemas/__init__.py", line 172, in load
    validator(schema_name,schemadir).validate(data)
  File "/home/simko/.virtualenvs/yadage/lib/python2.7/site-packages/jsonschema/validators.py", line 130, in validate
    raise error
ValidationError: {'step': {'process': {'cmd': 'jupyter nbconvert --output-dir="{outputdir}" world_population_analysis.ipynb', 'process_type': 'string-interpolated-cmd'}, 'publisher': {'publisher_type': 'frompar-pub', 'outputmap': {'outputfile': 'outputfile'}}, 'environment': {u'imagetag': u'latest', 'image': 'reanahub/reana-demo-worldpopulation', u'envscript': u'', 'environment_type': 'docker-encapsulated', u'env': {}, u'resources': []}}, 'scheduler_type': 'singlestep-stage', 'parameters': None} is not valid under any of the given schemas

Failed validating u'oneOf' in schema[u'properties'][u'stages'][u'items'][u'properties'][u'scheduler']:
    {u'oneOf': [{u'$ref': u'scheduler/singlestep-stage-schema.json#'},
                {u'$ref': u'scheduler/multistep-stage-schema.json#'}],
     u'type': u'object'}

On instance[u'stages'][0][u'scheduler']:
    {'parameters': None,
     'scheduler_type': 'singlestep-stage',
     'step': {'environment': {u'env': {},
                              'environment_type': 'docker-encapsulated',
                              u'envscript': u'',
                              'image': 'reanahub/reana-demo-worldpopulation',
                              u'imagetag': u'latest',
                              u'resources': []},
              'process': {'cmd': 'jupyter nbconvert --output-dir="{outputdir}" world_population_analysis.ipynb',
                          'process_type': 'string-interpolated-cmd'},
              'publisher': {'outputmap': {'outputfile': 'outputfile'},
                            'publisher_type': 'frompar-pub'}}}
workflow does not validate against schema
$ echo $?
0

It would be more comfortable if yadage-validate returned 0 when things are OK and 1 otherwise, as is the usual convention with other validating programs.

(moved from https://github.com/diana-hep/yadage/issues/2)

lukasheinrich commented 7 years ago

closing.. was fixed in yadage and now moved here