-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSubmissionDocker.cwl
67 lines (63 loc) · 2.16 KB
/
getSubmissionDocker.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
#!/usr/bin/env cwl-runner
#
# Extract the submitted Docker repository and Docker digest
#
cwlVersion: v1.0
class: CommandLineTool
baseCommand: python
inputs:
- id: submissionId
type: int
- id: synapseConfig
type: File
arguments:
- valueFrom: getSubmissionDocker.py
- valueFrom: $(inputs.submissionId)
prefix: -s
- valueFrom: results.json
prefix: -r
- valueFrom: $(inputs.synapseConfig.path)
prefix: -c
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: getSubmissionDocker.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("-r", "--results", required=True, help="download results info")
parser.add_argument("-c", "--synapseConfig", required=True, help="credentials file")
args = parser.parse_args()
syn = synapseclient.Synapse(configPath=args.synapseConfig)
syn.login()
sub = syn.getSubmission(args.submissionId, downloadLocation=".")
if sub.entity.entityType!='org.sagebionetworks.repo.model.docker.DockerRepository':
raise Exception('Expected DockerRepository type but found '+sub.entity.entityType)
result = {'dockerRepository':sub.get("dockerRepositoryName",""),'dockerDigest':sub.get("dockerDigest",""),'entityId':sub.entity.id}
with open(args.results, 'w') as o:
o.write(json.dumps(result))
outputs:
- id: dockerRepository
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['dockerRepository'])
- id: dockerDigest
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['dockerDigest'])
- id: entityId
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['entityId'])