From e1f07d5566aed6371638307e72f1c9e6c20c7ca5 Mon Sep 17 00:00:00 2001 From: Rob Syme Date: Mon, 2 Dec 2024 16:15:01 -0500 Subject: [PATCH] Revert changes to nf-core module --- .../nf-core/utils_nfcore_pipeline/main.nf | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/nf_core/pipeline-template/subworkflows/nf-core/utils_nfcore_pipeline/main.nf b/nf_core/pipeline-template/subworkflows/nf-core/utils_nfcore_pipeline/main.nf index f050f67072..5cb7bafef3 100644 --- a/nf_core/pipeline-template/subworkflows/nf-core/utils_nfcore_pipeline/main.nf +++ b/nf_core/pipeline-template/subworkflows/nf-core/utils_nfcore_pipeline/main.nf @@ -246,26 +246,27 @@ def logColours(monochrome_logs=true) { } // -// Return a single report from an object that may be a Path or List -// -def getSingleReport(multiqc_reports) { - switch (multiqc_reports) { - case Path: - return multiqc_reports - case List: - switch (multiqc_reports.size()) { - case 0: - log.warn("[${workflow.manifest.name}] No reports found from process 'MULTIQC'") - return null - case 1: - return multiqc_reports.first() - default: +// Attach the multiqc report to email +// +def attachMultiqcReport(multiqc_report) { + def mqc_report = null + try { + if (workflow.success) { + mqc_report = multiqc_report.getVal() + if (mqc_report.getClass() == ArrayList && mqc_report.size() >= 1) { + if (mqc_report.size() > 1) { log.warn("[${workflow.manifest.name}] Found multiple reports from process 'MULTIQC', will use only one") - return multiqc_reports.first() + } + mqc_report = mqc_report[0] } - default: - return null + } + } + catch (Exception all) { + if (multiqc_report) { + log.warn("[${workflow.manifest.name}] Could not attach MultiQC report to summary email") + } } + return mqc_report } // @@ -319,7 +320,7 @@ def completionEmail(summary_params, email, email_on_fail, plaintext_email, outdi email_fields['summary'] = summary << misc_fields // On success try attach the multiqc report - def mqc_report = getSingleReport(multiqc_report) + def mqc_report = attachMultiqcReport(multiqc_report) // Check if we are only sending emails on failure def email_address = email @@ -350,8 +351,7 @@ def completionEmail(summary_params, email, email_on_fail, plaintext_email, outdi if (email_address) { try { if (plaintext_email) { - new org.codehaus.groovy.GroovyException('Send plaintext e-mail, not HTML') - } +new org.codehaus.groovy.GroovyException('Send plaintext e-mail, not HTML') } // Try to send HTML e-mail using sendmail def sendmail_tf = new File(workflow.launchDir.toString(), ".sendmail_tmp.html") sendmail_tf.withWriter { w -> w << sendmail_html }