Skip to content

Commit

Permalink
Improve onComplete logic
Browse files Browse the repository at this point in the history
  • Loading branch information
seppinho committed Jul 2, 2024
1 parent ee0f2f9 commit 11956a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ params {
]

service = [
name: "nf-imputationserver",
name: "Michigan Imputation Server",
email: null,
url : null
]
Expand Down
59 changes: 31 additions & 28 deletions workflows/imputationserver.nf
Original file line number Diff line number Diff line change
Expand Up @@ -124,41 +124,44 @@ workflow.onComplete {
def report = new CloudgeneReport()

if (!workflow.success) {
if (params.config.send_mail){
if (params.config.send_mail && params.user.email != null){
sendMail{
to "${params.user.email}"
subject "[${params.service.name}] Job ${params.project} failed."
body "Dear ${params.user.name}, \n Unfortunately, your job failed.\n\n More details about the errors can be found at the following link: ${params.service.url}/index.html#!jobs/${params.project}"
body "Dear ${params.user.name}, \n Your job has failed.\n\n More details about the errors can be found at the following link: ${params.service.url}/index.html#!jobs/${params.project}"
}
}
report.ok("Imputation failed. We have sent a notification email to <b>${params.user.email}</b>") report.error("Imputation failed.")
} else {
// imputation results
if ((params.merge_results === true || params.merge_results === "true") &&
(params.encryption.enabled === true || params.encryption.enabled === "true")) {

if (params.config.send_mail) {
sendMail{
to "${params.user.email}"
subject "[${params.service.name}] Job ${params.project} is complete."
body "Dear ${params.user.name}, \n Your imputation job has finished succesfully. The password for the imputation results is: ${params.encryption_password}\n\n You can download the results from the following link: ${params.service.url}/index.html#!jobs/${params.project}"
}
report.ok("Data have been exported successfully. We have sent a notification email to <b>${params.user.email}</b>")
} else {
report.ok("Data have been exported successfully. We encrypted the results with the following password <b>${params.encryption_password}</b>")
report.error("Imputation failed. We have sent a notification email to <b>${params.user.email}</b>")
return
}

// imputation job
if ((params.merge_results === true || params.merge_results === "true") &&
(params.encryption.enabled === true || params.encryption.enabled === "true")) {

if (params.config.send_mail && params.user.email != null) {
sendMail{
to "${params.user.email}"
subject "[${params.service.name}] Job ${params.project} is complete."
body "Dear ${params.user.name}, \n Your imputation job has finished succesfully. The password for the imputation results is: ${params.encryption_password}\n\n You can download the results from the following link: ${params.service.url}/index.html#!jobs/${params.project}"
}
//PGS results
report.ok("Data have been exported successfully. We have sent a notification email to <b>${params.user.email}</b>")
} else {
if (params.config.send_mail) {
sendMail{
to "${params.user.email}"
subject "[${params.service.name}] Job ${params.project} is complete."
body "Dear ${params.user.name}, \n Your PGS job has finished successfully. \n\n You can download the results from the following link: ${params.service.url}/index.html#!jobs/${params.project}"
}
report.ok("Data have been exported successfully. We have sent a notification email to <b>${params.user.email}</b>")
} else {
report.ok("Data have been exported successfully.")
}
report.ok("Data have been exported successfully. We encrypted the results with the following password <b>${params.encryption_password}</b>")
}
return
}

//PGS job
if (params.config.send_mail && params.user.email != null) {
sendMail{
to "${params.user.email}"
subject "[${params.service.name}] Job ${params.project} is complete."
body "Dear ${params.user.name}, \n Your PGS job has finished successfully. \n\n You can download the results from the following link: ${params.service.url}/index.html#!jobs/${params.project}"
}
report.ok("Data have been exported successfully. We have sent a notification email to <b>${params.user.email}</b>")
} else {
report.ok("Data have been exported successfully.")
}

}

0 comments on commit 11956a1

Please sign in to comment.