generated from Sage-Bionetworks-Challenges/model-to-data-challenge-workflow
-
Notifications
You must be signed in to change notification settings - Fork 2
/
validate.cwl
80 lines (69 loc) · 2.24 KB
/
validate.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
73
74
75
76
77
78
79
80
#!/usr/bin/env cwl-runner
#
# Example validate submission file
#
cwlVersion: v1.0
class: CommandLineTool
baseCommand: python
hints:
DockerRequirement:
dockerPull: python:3.7
inputs:
- id: entity_type
type: string
- id: inputfile
type: File?
arguments:
- valueFrom: validate.py
- valueFrom: $(inputs.inputfile)
prefix: -s
- valueFrom: results.json
prefix: -r
- valueFrom: $(inputs.entity_type)
prefix: -e
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: validate.py
entry: |
#!/usr/bin/env python
import argparse
import json
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--results", required=True, help="validation results")
parser.add_argument("-e", "--entity_type", required=True, help="synapse entity type downloaded")
parser.add_argument("-s", "--submission_file", help="Submission File")
args = parser.parse_args()
if args.submission_file is None:
prediction_file_status = "INVALID"
invalid_reasons = ['Expected FileEntity type but found ' + args.entity_type]
else:
with open(args.submission_file,"r") as sub_file:
message = sub_file.read()
invalid_reasons = []
prediction_file_status = "VALIDATED"
if not message.startswith("test"):
invalid_reasons.append("Submission must have test column")
prediction_file_status = "INVALID"
result = {'submission_errors': "\n".join(invalid_reasons),
'submission_status': prediction_file_status}
with open(args.results, 'w') as o:
o.write(json.dumps(result))
outputs:
- id: results
type: File
outputBinding:
glob: results.json
- id: status
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['submission_status'])
- id: invalid_reasons
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['submission_errors'])