-
Notifications
You must be signed in to change notification settings - Fork 187
/
schema_params.py
50 lines (36 loc) · 1.99 KB
/
schema_params.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import nf_core.schema
def schema_params(self):
"""Check that the schema describes all flat params in the pipeline.
The ``nextflow_schema.json`` pipeline schema should describe every flat parameter
returned from the ``nextflow config`` command (params that are objects or more complex structures are ignored).
* Failure: If parameters are found in ``nextflow_schema.json`` that are not in ``nextflow_schema.json``
* Warning: If parameters are found in ``nextflow_schema.json`` that are not in ``nextflow_schema.json``
"""
passed = []
warned = []
failed = []
# First, get the top-level config options for the pipeline
self.schema_obj = nf_core.schema.PipelineSchema()
self.schema_obj.get_schema_path(self.wf_path)
self.schema_obj.get_wf_params()
self.schema_obj.no_prompts = True
self.schema_obj.load_lint_schema()
# Remove any schema params not found in the config
removed_params = self.schema_obj.remove_schema_notfound_configs()
# Add schema params found in the config but not the schema
added_params = self.schema_obj.add_schema_found_configs()
# Invalid default parameters in nextflow.config
invalid_config_default_params = self.schema_obj.invalid_nextflow_config_default_parameters
if len(removed_params) > 0:
for param in removed_params:
warned.append("Schema param `{}` not found from nextflow config".format(param))
if len(added_params) > 0:
for param in added_params:
failed.append("Param `{}` from `nextflow config` not found in nextflow_schema.json".format(param))
if len(removed_params) == 0 and len(added_params) == 0:
passed.append("Schema matched params returned from nextflow config")
if len(invalid_config_default_params) > 0:
for param, msg in invalid_config_default_params.items():
failed.append(f"Default value for param `{param}` invalid: {msg}")
return {"passed": passed, "warned": warned, "failed": failed}