Skip to content

Commit a15849b

Browse files
authored
Merge pull request #206 from ewels/schema-summary-rewrite
Rewrite the schema summary log
2 parents 2831fe9 + b43f53e commit a15849b

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

.nf-core-lint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
files_unchanged:
2+
- lib/NfcoreSchema.groovy

lib/NfcoreSchema.groovy

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ class NfcoreSchema {
191191

192192
// Remove an element from a JSONArray
193193
private static JSONArray removeElement(jsonArray, element){
194-
def list = []
194+
def list = []
195195
int len = jsonArray.length()
196-
for (int i=0;i<len;i++){
196+
for (int i=0;i<len;i++){
197197
list.add(jsonArray.get(i).toString())
198-
}
198+
}
199199
list.remove(element)
200200
JSONArray jsArray = new JSONArray(list)
201201
return jsArray
@@ -213,7 +213,7 @@ class NfcoreSchema {
213213
// If the param was required, change this
214214
if (definition[key].has("required")) {
215215
def cleaned_required = removeElement(definition[key].required, ignore_param)
216-
definition[key].put("required", cleaned_required)
216+
definition[key].put("required", cleaned_required)
217217
}
218218
}
219219
}
@@ -482,10 +482,10 @@ class NfcoreSchema {
482482
}
483483
workflow_summary['runName'] = workflow.runName
484484
if (workflow.containerEngine) {
485-
workflow_summary['containerEngine'] = "$workflow.containerEngine"
485+
workflow_summary['containerEngine'] = workflow.containerEngine
486486
}
487487
if (workflow.container) {
488-
workflow_summary['container'] = "$workflow.container"
488+
workflow_summary['container'] = workflow.container
489489
}
490490
workflow_summary['launchDir'] = workflow.launchDir
491491
workflow_summary['workDir'] = workflow.workDir
@@ -506,17 +506,7 @@ class NfcoreSchema {
506506
def params_value = params.get(param)
507507
def schema_value = group_params.get(param).default
508508
def param_type = group_params.get(param).type
509-
if (schema_value == null) {
510-
if (param_type == 'boolean') {
511-
schema_value = false
512-
}
513-
if (param_type == 'string') {
514-
schema_value = ''
515-
}
516-
if (param_type == 'integer') {
517-
schema_value = 0
518-
}
519-
} else {
509+
if (schema_value != null) {
520510
if (param_type == 'string') {
521511
if (schema_value.contains('$projectDir') || schema_value.contains('${projectDir}')) {
522512
def sub_string = schema_value.replace('\$projectDir', '')
@@ -535,8 +525,13 @@ class NfcoreSchema {
535525
}
536526
}
537527

538-
if (params_value != schema_value) {
539-
sub_params.put("$param", params_value)
528+
// We have a default in the schema, and this isn't it
529+
if (schema_value != null && params_value != schema_value) {
530+
sub_params.put(param, params_value)
531+
}
532+
// No default in the schema, and this isn't empty
533+
else if (schema_value == null && params_value != "" && params_value != null && params_value != false) {
534+
sub_params.put(param, params_value)
540535
}
541536
}
542537
}
@@ -549,22 +544,23 @@ class NfcoreSchema {
549544
* Beautify parameters for summary and return as string
550545
*/
551546
private static String params_summary_log(workflow, params, json_schema) {
547+
Map colors = log_colours(params.monochrome_logs)
552548
String output = ''
553549
def params_map = params_summary_map(workflow, params, json_schema)
554550
def max_chars = params_max_chars(params_map)
555551
for (group in params_map.keySet()) {
556552
def group_params = params_map.get(group) // This gets the parameters of that particular group
557553
if (group_params) {
558-
output += group + '\n'
554+
output += colors.bold + group + colors.reset + '\n'
559555
for (param in group_params.keySet()) {
560-
output += " \u001B[1m" + param.padRight(max_chars) + ": \u001B[1m" + group_params.get(param) + '\n'
556+
output += " " + colors.blue + param.padRight(max_chars) + ": " + colors.green + group_params.get(param) + colors.reset + '\n'
561557
}
562558
output += '\n'
563559
}
564560
}
565-
output += "[Only displaying parameters that differ from pipeline default]\n"
566561
output += dashed_line(params.monochrome_logs)
567-
output += '\n\n' + dashed_line(params.monochrome_logs)
562+
output += colors.dim + "\n Only displaying parameters that differ from defaults.\n" + colors.reset
563+
output += dashed_line(params.monochrome_logs)
568564
return output
569565
}
570566

0 commit comments

Comments
 (0)