-
Notifications
You must be signed in to change notification settings - Fork 0
/
validationEmail.cwl
72 lines (65 loc) · 2.37 KB
/
validationEmail.cwl
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env cwl-runner
#
# Example sends validation emails to participants
#
cwlVersion: v1.0
class: CommandLineTool
baseCommand: python
inputs:
- id: submissionId
type: int
- id: synapseConfig
type: File
- id: status
type: string
- id: invalidReasons
type: string
arguments:
- valueFrom: validationEmail.py
- valueFrom: $(inputs.submissionId)
prefix: -s
- valueFrom: $(inputs.synapseConfig.path)
prefix: -c
- valueFrom: $(inputs.status)
prefix: --status
- valueFrom: $(inputs.invalidReasons)
prefix: -i
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: validationEmail.py
entry: |
#!/usr/bin/env python
import synapseclient
import argparse
import json
import os
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--submissionId", required=True, help="Submission ID")
parser.add_argument("-c", "--synapseConfig", required=True, help="credentials file")
parser.add_argument("--status", required=True, help="Prediction File Status")
parser.add_argument("-i","--invalid", required=True, help="Invalid reasons")
args = parser.parse_args()
syn = synapseclient.Synapse(configPath=args.synapseConfig)
syn.login()
sub = syn.getSubmission(args.submissionId)
userId = sub.userId
evaluation = syn.getEvaluation(sub.evaluationId)
if args.status == "INVALID":
subject = "Submission to '%s' invalid!" % evaluation.name
message = ["Hello %s,\n\n" % syn.getUserProfile(userId)['userName'],
"Your submission (%s) is invalid, below are the invalid reasons:\n\n" % sub.name,
args.invalid,
"\n\nSincerely,\nChallenge Administrator"]
else:
subject = "Submission to '%s' accepted!" % evaluation.name
message = ["Hello %s,\n\n" % syn.getUserProfile(userId)['userName'],
"Your submission (%s) is valid!\n\n" % sub.name,
"\nSincerely,\nChallenge Administrator"]
syn.sendMessage(
userIds=[userId],
messageSubject=subject,
messageBody="".join(message),
contentType="text/html")
outputs: []