comparison env/lib/python3.9/site-packages/galaxy/tool_util/linters/cwl.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
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.")