@@ -907,17 +907,7 @@ def check_watched_items(self):
907907 def check_watched_item (self , job_state : AsynchronousJobState ) -> Union [AsynchronousJobState , None ]:
908908 raise NotImplementedError ()
909909
910- def finish_job (self , job_state : AsynchronousJobState ):
911- """
912- Get the output/error for a finished job, pass to `job_wrapper.finish`
913- and cleanup all the job's temporary files.
914- """
915- galaxy_id_tag = job_state .job_wrapper .get_id_tag ()
916- external_job_id = job_state .job_id
917-
918- # To ensure that files below are readable, ownership must be reclaimed first
919- job_state .job_wrapper .reclaim_ownership ()
920-
910+ def _collect_job_output (self , job_id : int , external_job_id : Optional [str ], job_state : JobState ):
921911 # wait for the files to appear
922912 which_try = 0
923913 collect_output_success = True
@@ -931,11 +921,25 @@ def finish_job(self, job_state: AsynchronousJobState):
931921 if which_try == self .app .config .retry_job_output_collection :
932922 stdout = ""
933923 stderr = job_state .runner_states .JOB_OUTPUT_NOT_RETURNED_FROM_CLUSTER
934- log .error ("(%s/%s) %s: %s" , galaxy_id_tag , external_job_id , stderr , unicodify (e ))
924+ log .error ("(%s/%s) %s: %s" , job_id , external_job_id , stderr , unicodify (e ))
935925 collect_output_success = False
936926 else :
937927 time .sleep (1 )
938928 which_try += 1
929+ return collect_output_success , stdout , stderr
930+
931+ def finish_job (self , job_state : AsynchronousJobState ):
932+ """
933+ Get the output/error for a finished job, pass to `job_wrapper.finish`
934+ and cleanup all the job's temporary files.
935+ """
936+ galaxy_id_tag = job_state .job_wrapper .get_id_tag ()
937+ external_job_id = job_state .job_id
938+
939+ # To ensure that files below are readable, ownership must be reclaimed first
940+ job_state .job_wrapper .reclaim_ownership ()
941+
942+ collect_output_success , stdout , stderr = self ._collect_job_output (galaxy_id_tag , external_job_id , job_state )
939943
940944 if not collect_output_success :
941945 job_state .fail_message = stderr
0 commit comments