Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/galaxy/tool_util/linters/cwl.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d30785e31577 | 1:56ad4e20f292 |
---|---|
1 """Linter for CWL tools.""" | |
2 | |
3 lint_tool_types = ["cwl"] | |
4 | |
5 from galaxy.tool_util.cwl.schema import schema_loader | |
6 | |
7 | |
8 def lint_cwl_validation(tool_source, lint_ctx): | |
9 """Determine in CWL tool validates against spec.""" | |
10 raw_reference = schema_loader.raw_process_reference(tool_source._source_path) | |
11 validation_exception = None | |
12 try: | |
13 schema_loader.process_definition(raw_reference) | |
14 except Exception as e: | |
15 validation_exception = e | |
16 if validation_exception: | |
17 lint_ctx.error("Failed to valdiate CWL artifact [%s]", validation_exception) | |
18 else: | |
19 lint_ctx.info("CWL appears to be valid.") | |
20 | |
21 | |
22 def lint_new_draft(tool_source, lint_ctx): | |
23 """Determine in CWL tool is valid, modern draft.""" | |
24 raw_reference = schema_loader.raw_process_reference(tool_source._source_path) | |
25 cwl_version = raw_reference.process_object.get("cwlVersion", None) | |
26 if cwl_version is None: | |
27 lint_ctx.error("CWL file does not contain a 'cwlVersion'") | |
28 if cwl_version not in ["v1.0"]: | |
29 lint_ctx.warn("CWL version [%s] is unknown, we recommend the v1.0 the stable release." % cwl_version) | |
30 else: | |
31 lint_ctx.info("Modern CWL version [%s]", cwl_version) | |
32 | |
33 | |
34 def lint_docker_image(tool_source, lint_ctx): | |
35 _, containers = tool_source.parse_requirements_and_containers() | |
36 if len(containers) == 0: | |
37 lint_ctx.warn("Tool does not specify a DockerPull source.") | |
38 else: | |
39 identifier = containers[0].identifier | |
40 lint_ctx.info("Tool will run in Docker image [%s]." % identifier) | |
41 | |
42 | |
43 def lint_description(tool_source, lint_ctx): | |
44 help = tool_source.parse_help() | |
45 if not help: | |
46 lint_ctx.warn("Description of tool is empty or absent.") | |
47 elif "TODO" in help: | |
48 lint_ctx.warn("Help contains TODO text.") |