@@ -82,20 +82,29 @@ def ListWorkflows(self):
82
82
}
83
83
84
84
def invoke_cwl_runner (self , cr_uuid , workflow_url , workflow_params , env ):
85
+ api = arvados .api_from_config (version = "v1" , apiconfig = {
86
+ "ARVADOS_API_HOST" : env ["ARVADOS_API_HOST" ],
87
+ "ARVADOS_API_TOKEN" : env ['ARVADOS_API_TOKEN' ],
88
+ "ARVADOS_API_HOST_INSECURE" : env ["ARVADOS_API_HOST_INSECURE" ] # NOQA
89
+ })
90
+
85
91
try :
86
92
with tempfile .NamedTemporaryFile () as inputtemp :
87
93
json .dump (workflow_params , inputtemp )
88
94
inputtemp .flush ()
89
- workflow_id = subprocess .check_output (["arvados-cwl-runner" , "--submit-request-uuid=" + cr_uuid , # NOQA
95
+ proc = subprocess .Popen (["arvados-cwl-runner" , "--submit-request-uuid=" + cr_uuid , # NOQA
90
96
"--submit" , "--no-wait" , "--api=containers" , # NOQA
91
- workflow_url , inputtemp .name ], env = env ).strip () # NOQA
97
+ workflow_url , inputtemp .name ], env = env ,
98
+ stdout = subprocess .PIPE , stderr = subprocess .PIPE ) # NOQA
99
+ (stdoutdata , stderrdata ) = proc .communicate ()
100
+ if proc .returncode != 0 :
101
+ api .container_requests ().update (uuid = cr_uuid , body = {"priority" : 0 ,
102
+ "properties" : {"arvados-cwl-runner-log" : stderrdata }}).execute ()
103
+ else :
104
+ api .container_requests ().update (uuid = cr_uuid , body = {"properties" : {"arvados-cwl-runner-log" : stderrdata }}).execute ()
92
105
except subprocess .CalledProcessError as e :
93
- api = arvados .api_from_config (version = "v1" , apiconfig = {
94
- "ARVADOS_API_HOST" : env ["ARVADOS_API_HOST" ],
95
- "ARVADOS_API_TOKEN" : env ['ARVADOS_API_TOKEN' ],
96
- "ARVADOS_API_HOST_INSECURE" : env ["ARVADOS_API_HOST_INSECURE" ] # NOQA
97
- })
98
- request = api .container_requests ().update (uuid = cr_uuid , body = {"priority" : 0 }).execute () # NOQA
106
+ api .container_requests ().update (uuid = cr_uuid , body = {"priority" : 0 ,
107
+ "properties" : {"arvados-cwl-runner-log" : str (e )}}).execute ()
99
108
100
109
@catch_exceptions
101
110
def RunWorkflow (self , body ):
@@ -132,6 +141,8 @@ def GetWorkflowLog(self, workflow_id):
132
141
else :
133
142
container = {"state" : "Queued" , "exit_code" : None }
134
143
144
+ stderr = request ["properties" ].get ("arvados-cwl-runner-log" , "" )
145
+
135
146
outputobj = {}
136
147
if request ["output_uuid" ]:
137
148
c = arvados .collection .CollectionReader (request ["output_uuid" ], api_client = api )
@@ -144,12 +155,11 @@ def keepref(d):
144
155
145
156
visit (outputobj , keepref )
146
157
147
- stderr = ""
148
158
if request ["log_uuid" ]:
149
159
c = arvados .collection .CollectionReader (request ["log_uuid" ], api_client = api )
150
160
if "stderr.txt" in c :
151
161
with c .open ("stderr.txt" ) as f :
152
- stderr = f .read ()
162
+ stderr + = f .read ()
153
163
154
164
r = {
155
165
"workflow_id" : request ["uuid" ],
0 commit comments