Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZARP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
zavolan_group
pipelines
ZARP
Commits
ef68b765
Commit
ef68b765
authored
3 years ago
by
Dominik Burri
Browse files
Options
Downloads
Patches
Plain Diff
validate config on required and optional fields
#174
parent
b5db2001
No related branches found
No related tags found
1 merge request
!91
Config validation
Pipeline
#12872
failed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/input_files/config.yaml
+8
-5
8 additions, 5 deletions
tests/input_files/config.yaml
workflow/Snakefile
+36
-5
36 additions, 5 deletions
workflow/Snakefile
with
44 additions
and
10 deletions
tests/input_files/config.yaml
+
8
−
5
View file @
ef68b765
---
---
# Required fields
samples
:
"
../input_files/samples.tsv"
samples
:
"
../input_files/samples.tsv"
rule_config
:
"
../input_files/rule_config.yaml"
rule_config
:
"
../input_files/rule_config.yaml"
output_dir
:
"
results"
output_dir
:
"
results"
...
@@ -7,9 +8,11 @@
...
@@ -7,9 +8,11 @@
salmon_indexes
:
"
results/salmon_indexes"
salmon_indexes
:
"
results/salmon_indexes"
star_indexes
:
"
results/star_indexes"
star_indexes
:
"
results/star_indexes"
alfa_indexes
:
"
results/alfa_indexes"
alfa_indexes
:
"
results/alfa_indexes"
report_description
:
"
No
description
provided
by
user"
# Optional fields
report_logo
:
"
../../images/logo.128px.png"
optional
:
report_url
:
"
https://zavolan.biozentrum.unibas.ch/"
report_description
:
"
No
description
provided
by
user"
author_name
:
"
NA"
report_logo
:
"
../../images/logo.128px.png"
author_email
:
"
NA"
report_url
:
"
https://zavolan.biozentrum.unibas.ch/"
author_name
:
"
NA"
author_email
:
"
NA"
...
...
This diff is collapsed.
Click to expand it.
workflow/Snakefile
+
36
−
5
View file @
ef68b765
...
@@ -17,6 +17,37 @@ samples_table = pd.read_csv(
...
@@ -17,6 +17,37 @@ samples_table = pd.read_csv(
sep="\t",
sep="\t",
)
)
# Validate config with template config
template_config_path = os.path.join(
workflow.current_basedir,
'..',
'tests',
'input_files',
'config.yaml')
try:
with open(template_config_path) as _file:
template_config = yaml.safe_load(_file)
logger.info(f"Loaded template config from {template_config_path}.")
# Check if config contains required fields in example config
for key in template_config:
if key != 'optional':
assert key in config
except FileNotFoundError:
logger.error(f"No config file found at {template_config_path}! ")
raise
except AssertionError:
logger.error(f"Required config fields from {template_config_path} do not match {config.keys()}")
raise
# Check if optional field available
if 'optional' not in config:
config['optional'] = {}
# Check optional fields and include in config if not present
for optkey, value in template_config['optional'].items():
if optkey not in config['optional']:
config['optional'][optkey] = value
logger.info(f"Added optional field: \"{optkey}\" with value: \"{value}\" to config.")
# Parse YAML rule config file
# Parse YAML rule config file
if 'rule_config' in config and config['rule_config']:
if 'rule_config' in config and config['rule_config']:
try:
try:
...
@@ -1544,11 +1575,11 @@ rule prepare_multiqc_config:
...
@@ -1544,11 +1575,11 @@ rule prepare_multiqc_config:
"multiqc_config.yaml")
"multiqc_config.yaml")
params:
params:
logo_path = config['report_logo'],
logo_path = config['
optional']['
report_logo'],
multiqc_intro_text = config['report_description'],
multiqc_intro_text = config['
optional']['
report_description'],
url = config['report_url'],
url = config['
optional']['
report_url'],
author_name = config['author_name'],
author_name = config['
optional']['
author_name'],
author_email = config['author_email'],
author_email = config['
optional']['
author_email'],
additional_params = parse_rule_config(
additional_params = parse_rule_config(
rule_config,
rule_config,
current_rule=current_rule,
current_rule=current_rule,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment