ga4gh / tool-registry-validator

Used to validate APIs that implement https://github.com/ga4gh/tool-registry-schemas
4 stars 1 forks source link

Update to schema-salad seems to affect validation #2

Closed denis-yuen closed 5 years ago

denis-yuen commented 7 years ago

A previously passing validation seems to fail after upgrading cwltool/schema-salad

$ sudo pip install cwltool==1.0.20160712154127
The directory '/home/dyuen/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip wit
h sudo, you may want sudo's -H flag.
The directory '/home/dyuen/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo,
 you may want sudo's -H flag.
Collecting cwltool==1.0.20160712154127
  Downloading cwltool-1.0.20160712154127.tar.gz (163kB)
    100% |████████████████████████████████| 163kB 3.2MB/s 
Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages (from cwltool==1.0.20160712154127)
Collecting ruamel.yaml==0.11.11 (from cwltool==1.0.20160712154127)
  Downloading ruamel.yaml-0.11.11-cp27-cp27mu-manylinux1_x86_64.whl (503kB)
    100% |████████████████████████████████| 512kB 2.5MB/s 
Requirement already satisfied: rdflib>=4.1.0 in /usr/local/lib/python2.7/dist-packages (from cwltool==1.0.20160712154127)
Requirement already satisfied: rdflib-jsonld>=0.3.0 in /usr/local/lib/python2.7/dist-packages (from cwltool==1.0.20160712154127)
Requirement already satisfied: shellescape in /usr/local/lib/python2.7/dist-packages (from cwltool==1.0.20160712154127)
Collecting schema-salad==1.14.20160708181155 (from cwltool==1.0.20160712154127)
  Downloading schema_salad-1.14.20160708181155-py2.py3-none-any.whl (46kB)
    100% |████████████████████████████████| 51kB 9.4MB/s 
Requirement already satisfied: typing in /usr/local/lib/python2.7/dist-packages (from cwltool==1.0.20160712154127)
Requirement already satisfied: ruamel.ordereddict in /usr/local/lib/python2.7/dist-packages (from ruamel.yaml==0.11.11->cwltool==1.0.20160712154127)
Requirement already satisfied: isodate in /usr/local/lib/python2.7/dist-packages (from rdflib>=4.1.0->cwltool==1.0.20160712154127)
Requirement already satisfied: pyparsing in /usr/local/lib/python2.7/dist-packages (from rdflib>=4.1.0->cwltool==1.0.20160712154127)
Requirement already satisfied: mistune in /usr/local/lib/python2.7/dist-packages (from schema-salad==1.14.20160708181155->cwltool==1.0.20160712154127)
Requirement already satisfied: avro in /usr/local/lib/python2.7/dist-packages (from schema-salad==1.14.20160708181155->cwltool==1.0.20160712154127)
Installing collected packages: ruamel.yaml, schema-salad, cwltool
  Found existing installation: ruamel.yaml 0.13.14
    Uninstalling ruamel.yaml-0.13.14:
      Successfully uninstalled ruamel.yaml-0.13.14
  Found existing installation: schema-salad 2.2.20170222151604
    Uninstalling schema-salad-2.2.20170222151604:
      Successfully uninstalled schema-salad-2.2.20170222151604
  Found existing installation: cwltool 1.0.20170217172322
    Uninstalling cwltool-1.0.20170217172322:
      Successfully uninstalled cwltool-1.0.20170217172322
  Running setup.py install for cwltool ... done
Successfully installed cwltool-1.0.20160712154127 ruamel.yaml-0.11.11 schema-salad-1.14.20160708181155

$ ga4gh-tool-registry-validate ga4gh-tool-discovery.yaml annotations.yml https://dockstore.org:8443/api/ga4gh/v1/tools                            
API returned valid response

$ sudo pip install --upgrade cwltool                                                                                                     [28/1876]
The directory '/home/dyuen/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip wit
h sudo, you may want sudo's -H flag.
The directory '/home/dyuen/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo,
 you may want sudo's -H flag.
Collecting cwltool
  Downloading cwltool-1.0.20170217172322-py2-none-any.whl (277kB)
    100% |████████████████████████████████| 286kB 3.8MB/s 
Requirement already up-to-date: shellescape<3.5,>=3.4.1 in /usr/local/lib/python2.7/dist-packages (from cwltool)
Collecting schema-salad<3,>=2.2.20170216125639 (from cwltool)
  Downloading schema-salad-2.2.20170222151604.tar.gz (295kB)
    100% |████████████████████████████████| 296kB 3.6MB/s 
Requirement already up-to-date: rdflib<4.3.0,>=4.2.2 in /usr/local/lib/python2.7/dist-packages (from cwltool)
Requirement already up-to-date: typing<3.6,>=3.5.2 in /usr/local/lib/python2.7/dist-packages (from cwltool)
Requirement already up-to-date: requests>=1.0 in /usr/local/lib/python2.7/dist-packages (from cwltool)
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/dist-packages (from cwltool)
Collecting ruamel.yaml>=0.12.4 (from cwltool)
  Downloading ruamel.yaml-0.13.14-cp27-cp27mu-manylinux1_x86_64.whl (512kB)
    100% |████████████████████████████████| 522kB 2.7MB/s 
Requirement already up-to-date: rdflib-jsonld<0.5.0,>=0.3.0 in /usr/local/lib/python2.7/dist-packages (from schema-salad<3,>=2.2.20170216125639->cwltool)
Requirement already up-to-date: mistune<0.8,>=0.7.3 in /usr/local/lib/python2.7/dist-packages (from schema-salad<3,>=2.2.20170216125639->cwltool)
Requirement already up-to-date: CacheControl<0.12,>=0.11.7 in /usr/local/lib/python2.7/dist-packages (from schema-salad<3,>=2.2.20170216125639->cwltool)
Requirement already up-to-date: lockfile>=0.9 in /usr/lib/python2.7/dist-packages (from schema-salad<3,>=2.2.20170216125639->cwltool)
Requirement already up-to-date: avro in /usr/local/lib/python2.7/dist-packages (from schema-salad<3,>=2.2.20170216125639->cwltool)
Requirement already up-to-date: isodate in /usr/local/lib/python2.7/dist-packages (from rdflib<4.3.0,>=4.2.2->cwltool)
Requirement already up-to-date: pyparsing in /usr/local/lib/python2.7/dist-packages (from rdflib<4.3.0,>=4.2.2->cwltool)
Requirement already up-to-date: appdirs>=1.4.0 in /usr/local/lib/python2.7/dist-packages (from setuptools->cwltool)
Requirement already up-to-date: packaging>=16.8 in /usr/local/lib/python2.7/dist-packages (from setuptools->cwltool)
Requirement already up-to-date: six>=1.6.0 in /usr/lib/python2.7/dist-packages (from setuptools->cwltool)
Requirement already up-to-date: ruamel.ordereddict in /usr/local/lib/python2.7/dist-packages (from ruamel.yaml>=0.12.4->cwltool)
Installing collected packages: ruamel.yaml, schema-salad, cwltool
  Found existing installation: ruamel.yaml 0.11.11
    Uninstalling ruamel.yaml-0.11.11:
      Successfully uninstalled ruamel.yaml-0.11.11
  Found existing installation: schema-salad 1.14.20160708181155
    Uninstalling schema-salad-1.14.20160708181155:
      Successfully uninstalled schema-salad-1.14.20160708181155
  Running setup.py install for schema-salad ... done
  Found existing installation: cwltool 1.0.20160712154127
    Uninstalling cwltool-1.0.20160712154127:
      Successfully uninstalled cwltool-1.0.20160712154127
Successfully installed cwltool-1.0.20170217172322 ruamel.yaml-0.13.14 schema-salad-2.2.20170222151604
$ ga4gh-tool-registry-validate ga4gh-tool-discovery.yaml annotations.yml https://dockstore.org:8443/api/ga4gh/v1/tools
/home/dyuen/.local/lib/python2.7/site-packages/ga4gh_tool_registry_validate-1.0-py2.7.egg/ga4gh_tool_registry/validate.py:71: UnsafeLoaderWarning: 
The default 'Loader' for 'load(stream)' without further arguments can be unsafe.
Use 'load(stream, Loader=ruamel.yaml.Loader)' explicitly if that is OK.
Alternatively include the following in your code:

  import warnings
  warnings.simplefilter('ignore', ruamel.yaml.error.UnsafeLoaderWarning)

In most other cases you should consider using 'safe_load(stream)'
Traceback (most recent call last):
  File "/usr/local/bin/ga4gh-tool-registry-validate", line 11, in <module>
    load_entry_point('ga4gh-tool-registry-validate==1.0', 'console_scripts', 'ga4gh-tool-registry-validate')()
  File "build/bdist.linux-x86_64/egg/ga4gh_tool_registry/validate.py", line 79, in main
  File "/usr/local/lib/python2.7/dist-packages/schema_salad/schema.py", line 192, in load_schema
    schema_doc, schema_metadata = metaschema_loader.resolve_ref(schema_ref, "")
  File "/usr/local/lib/python2.7/dist-packages/schema_salad/ref_resolver.py", line 446, in resolve_ref
    raise ValueError(u"Expected CommentedMap or string, got %s: `%s`" % (type(ref), unicode(ref)))
ValueError: Expected CommentedMap or string, got <type 'dict'>: `{'$namespaces': {'toolreg': 'http://ga4gh.org/schemas/tool-registry-schemas#', 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#'}, '$base': 'http://ga4gh.org/schemas/tool-registry-schemas', '$graph': [{'doc': 'A tool document that describes how to test with one or more sample test JSON.', 'type': 'record', 'name': 'ToolTests', 'fields': {'test': {'doc': 'The test JSON content for this tool.', 'type': 'string'}, 'url': {'doc': 'Optional url to the test JSON used to test this tool', 'jsonldPredicate': '@id', 'type': ['null', 'string']}}}, {'doc': 'A tool dockerfile is a document that describes how to build a particular Docker image.', 'type': 'record', 'name': 'ToolDockerfile', 'fields': {'url': {'doc': 'Optional url to the dockerfile used to build this image, should include version information, and can include a git hash  (e.g. https://raw.githubusercontent.com/ICGC-TCGA-PanCancer/pcawg_delly_workflow/c83478829802b4d36374870843821abe1b625a71/delly_docker/Dockerfile )', 'jsonldPredicate': '@id', 'type': ['null', 'string']}, 'dockerfile': {'doc': 'The dockerfile content for this tool.', 'jsonldPredicate': 'toolreg:dockerfile', 'type': 'string'}}}, {'doc': 'Describes a class (type) of tool allowing us to categorize workflows, tools, and maybe even other entities (such as services) separately', 'type': 'record', 'name': 'ToolClass', 'fields': {'id': {'doc': 'The unique identifier for the class', 'jsonldPredicate': 'toolreg:id', 'type': ['null', 'string']}, 'description': {'doc': 'A longer explanation of what this class is and what it can accomplish', 'jsonldPredicate': 'rdfs:comment', 'type': ['null', 'string']}, 'name': {'doc': 'A short friendly name for the class', 'jsonldPredicate': 'toolreg:name', 'type': ['null', 'string']}}}, {'doc': 'A tool version describes a particular iteration of a tool as described by a reference to a specific image and dockerfile.', 'type': 'record', 'name': 'ToolVersion', 'fields': {'verified': {'doc': 'Reports whether this tool has been verified by a specific organization or individual', 'jsonldPredicate': 'toolreg:verified', 'type': ['null', 'boolean']}, 'name': {'doc': 'The name of the version.', 'jsonldPredicate': 'toolreg:name', 'type': ['null', 'string']}, 'url': {'doc': 'The URL for this tool in this registry, for example `http://agora.broadinstitute.org/tools/123456/1`', 'jsonldPredicate': '@id', 'type': 'string'}, 'image': {'doc': 'The docker path to the image (and version) for this tool. (e.g. quay.io/seqware/seqware_full/1.1)', 'type': ['null', 'string']}, 'meta-version': {'doc': 'The version of this tool version in the registry. Iterates when fields like the description, author, etc. are updated.', 'jsonldPredicate': 'toolreg:meta-version', 'type': 'string'}, 'descriptor-type': {'doc': 'The type (or types) of descriptors available.', 'type': ['null', {'items': 'string', 'type': 'array'}]}, 'dockerfile': {'doc': 'Reports if this tool has a dockerfile available.', 'jsonldPredicate': 'toolreg:dockerfile', 'type': ['null', 'boolean']}, 'id': {'doc': 'An identifier of the version of this tool for this particular tool registry, for example `v1`', 'jsonldPredicate': 'toolreg:id', 'type': 'string'}, 'verified-source': {'doc': 'Source of metadata that can support a verified tool, such as an email or URL', 'jsonldPredicate': 'toolreg:verified-source', 'type': ['null', 'string']}}}, {'doc': 'A tool (or described tool) describes one pairing of a tool as described in a descriptor file (which potentially describes multiple tools) and a Docker image.', 'documentRoot': True, 'type': 'record', 'name': 'Tool', 'fields': {'verified': {'doc': 'Reports whether this tool has been verified by a specific organization or individual', 'jsonldPredicate': 'toolreg:verified', 'type': ['null', 'boolean']}, 'description': {'doc': 'The description of the tool.', 'jsonldPredicate': 'rdfs:comment', 'type': ['null', 'string']}, 'versions': {'doc': 'A list of versions for this tool', 'type': {'items': 'ToolVersion', 'type': 'array'}}, 'url': {'doc': 'The URL for this tool in this registry, for example `http://agora.broadinstitute.org/tools/123456`', 'jsonldPredicate': '@id', 'type': 'string'}, 'contains': {'doc': 'An array of IDs for the applications that are stored inside this tool (for example `https://bio.tools/tool/mytum.de/SNAP2/1`)', 'type': ['null', {'items': 'string', 'type': 'array'}]}, 'signed': {'doc': 'Reports whether this tool has been signed.', 'type': ['null', 'boolean']}, 'meta-version': {'doc': 'The version of this tool in the registry. Iterates when fields like the description, author, etc. are updated.', 'jsonldPredicate': 'toolreg:meta-version', 'type': 'string'}, 'toolclass': {'doc': '', 'type': 'ToolClass'}, 'toolname': {'doc': 'The name of the tool.', 'type': ['null', 'string']}, 'author': {'doc': 'Contact information for the author of this tool entry in the registry. (More complex authorship information is handled by the descriptor)', 'type': 'string'}, 'organization': {'doc': 'The organization that published the image.', 'type': 'string'}, 'id': {'doc': 'A unique identifier of the tool, scoped to this registry, for example `123456` or `123456_v1`', 'jsonldPredicate': 'toolreg:id', 'type': 'string'}, 'verified-source': {'doc': 'Source of metadata that can support a verified tool, such as an email or URL', 'jsonldPredicate': 'toolreg:verified-source', 'type': ['null', 'string']}}}, {'doc': '', 'type': 'record', 'name': 'Error', 'fields': {'message': {'doc': '', 'type': ['null', 'string']}, 'code': {'doc': '', 'type': 'int'}}}, {'doc': 'A tool descriptor is a metadata document that describes one or more tools.', 'type': 'record', 'name': 'ToolDescriptor', 'fields': {'url': {'doc': 'Optional url to the tool descriptor used to build this image, should include version information, and can include a git hash (e.g. https://raw.githubusercontent.com/ICGC-TCGA-PanCancer/pcawg_delly_workflow/ea2a5db69bd20a42976838790bc29294df3af02b/delly_docker/Delly.cwl )', 'jsonldPredicate': '@id', 'type': ['null', 'string']}, 'descriptor': {'doc': 'The descriptor that represents this version of the tool. (CWL or WDL)', 'jsonldPredicate': 'toolreg:descriptor', 'type': 'string'}, 'type': {'doc': '', 'type': 'string'}}}, {'doc': 'Describes this registry to better allow for mirroring and indexing.', 'type': 'record', 'name': 'Metadata', 'fields': {'api-version': {'doc': 'The version of the GA4GH tool-registry API supported by this registry', 'type': 'string'}, 'country': {'doc': 'A country code for the registry (ISO 3166-1 alpha-3)', 'type': ['null', 'string']}, 'friendly-name': {'doc': 'A friendly name that can be used in addition to the hostname to describe a registry', 'type': ['null', 'string']}, 'version': {'doc': 'The version of this registry', 'type': 'string'}}}], 'name': 'file:///home/dyuen/dockstore/dockstore-webservice/tool-registry-validator/ga4gh-tool-discovery.yaml'}`

@tetron Any ideas? This may be a valid validation error, but I'm not sure how to interpret this

mr-c commented 7 years ago

Hey @denis-yuen , sorry for the breakage. This is from the enhanced error reporting feature.

The warning can be resolved with

https://github.com/common-workflow-language/schema_salad/blob/master/schema_salad/jsonld_context.py#L8

And it will likely fix the error. If not, then you can cast the Dict to a CommentedMap https://github.com/common-workflow-language/cwltool/blob/master/cwltool/load_tool.py#L59

tetron commented 7 years ago

@denis-yuen you can use schema_salad.sourceline.cmap() to convert the dict to a CommentedMap.

denis-yuen commented 7 years ago

Thanks for the hints, I think that works