@@ -1007,75 +1007,74 @@ def release(self):
10071007
10081008 def release_validators (self ):
10091009 """Allows all the validator job spawned by this job to complete"""
1010- with qdb .sql_connection .TRN :
1011- if self .command .software .type not in ('artifact transformation' ,
1012- 'private' ):
1013- raise qdb .exceptions .QiitaDBOperationNotPermittedError (
1014- "Only artifact transformation and private jobs can "
1015- "release validators" )
1016-
1017- # Check if all the validators are completed. Validator jobs can be
1018- # in two states when completed: 'waiting' in case of success
1019- # or 'error' otherwise
1020-
1010+ if self .command .software .type not in ('artifact transformation' ,
1011+ 'private' ):
1012+ raise qdb .exceptions .QiitaDBOperationNotPermittedError (
1013+ "Only artifact transformation and private jobs can "
1014+ "release validators" )
1015+
1016+ # Check if all the validators are completed. Validator jobs can be
1017+ # in two states when completed: 'waiting' in case of success
1018+ # or 'error' otherwise
1019+
1020+ validator_ids = ['%s [%s]' % (j .id , j .external_id )
1021+ for j in self .validator_jobs
1022+ if j .status not in ['waiting' , 'error' ]]
1023+
1024+ # Active polling - wait until all validator jobs are completed
1025+ # TODO: As soon as we see one errored validator, we should kill
1026+ # the other jobs and exit early. Don't wait for all of the jobs
1027+ # to complete.
1028+ while validator_ids :
1029+ jids = ', ' .join (validator_ids )
1030+ self .step = ("Validating outputs (%d remaining) via "
1031+ "job(s) %s" % (len (validator_ids ), jids ))
1032+ sleep (10 )
10211033 validator_ids = ['%s [%s]' % (j .id , j .external_id )
10221034 for j in self .validator_jobs
10231035 if j .status not in ['waiting' , 'error' ]]
10241036
1025- # Active polling - wait until all validator jobs are completed
1026- # TODO: As soon as we see one errored validator, we should kill
1027- # the other jobs and exit early. Don't wait for all of the jobs
1028- # to complete.
1029- while validator_ids :
1030- jids = ', ' .join ([j [0 ] for j in validator_ids ])
1031- self .step = ("Validating outputs (%d remaining) via "
1032- "job(s) %s" % (len (validator_ids ), jids ))
1033- sleep (10 )
1034- validator_ids = ['%s [%s]' % (j .id , j .external_id )
1035- for j in self .validator_jobs
1036- if j .status not in ['waiting' , 'error' ]]
1037-
1038- # Check if any of the validators errored
1039- errored = [j for j in self .validator_jobs
1040- if j .status == 'error' ]
1041- if errored :
1042- # At least one of the validators failed, Set the rest of the
1043- # validators and the current job as failed
1044- waiting = [j .id for j in self .validator_jobs
1045- if j .status == 'waiting' ]
1046-
1047- common_error = "\n " .join (
1048- ["Validator %s error message: %s" % (j .id , j .log .msg )
1049- for j in errored ])
1050-
1051- val_error = "%d sister validator jobs failed: %s" % (
1052- len (errored ), common_error )
1053- for j in waiting :
1054- ProcessingJob (j )._set_error (val_error )
1055-
1056- self ._set_error ('%d validator jobs failed: %s'
1057- % (len (errored ), common_error ))
1058- else :
1059- mapping = {}
1060- # Loop through all validator jobs and release them, allowing
1061- # to create the artifacts. Note that if any artifact creation
1062- # fails, the rollback operation will make sure that the
1063- # previously created artifacts are not in there
1064- for vjob in self .validator_jobs :
1065- mapping .update (vjob .release ())
1066-
1067- if mapping :
1068- sql = """INSERT INTO
1069- qiita.artifact_output_processing_job
1070- (artifact_id, processing_job_id,
1071- command_output_id)
1072- VALUES (%s, %s, %s)"""
1073- sql_args = [[aid , self .id , outid ]
1074- for outid , aid in mapping .items ()]
1037+ # Check if any of the validators errored
1038+ errored = [j for j in self .validator_jobs
1039+ if j .status == 'error' ]
1040+ if errored :
1041+ # At least one of the validators failed, Set the rest of the
1042+ # validators and the current job as failed
1043+ waiting = [j .id for j in self .validator_jobs
1044+ if j .status == 'waiting' ]
1045+
1046+ common_error = "\n " .join (
1047+ ["Validator %s error message: %s" % (j .id , j .log .msg )
1048+ for j in errored ])
1049+
1050+ val_error = "%d sister validator jobs failed: %s" % (
1051+ len (errored ), common_error )
1052+ for j in waiting :
1053+ ProcessingJob (j )._set_error (val_error )
1054+
1055+ self ._set_error ('%d validator jobs failed: %s'
1056+ % (len (errored ), common_error ))
1057+ else :
1058+ mapping = {}
1059+ # Loop through all validator jobs and release them, allowing
1060+ # to create the artifacts. Note that if any artifact creation
1061+ # fails, the rollback operation will make sure that the
1062+ # previously created artifacts are not in there
1063+ for vjob in self .validator_jobs :
1064+ mapping .update (vjob .release ())
1065+
1066+ if mapping :
1067+ sql = """INSERT INTO
1068+ qiita.artifact_output_processing_job
1069+ (artifact_id, processing_job_id,
1070+ command_output_id)
1071+ VALUES (%s, %s, %s)"""
1072+ sql_args = [[aid , self .id , outid ]
1073+ for outid , aid in mapping .items ()]
1074+ with qdb .sql_connection .TRN :
10751075 qdb .sql_connection .TRN .add (sql , sql_args , many = True )
1076-
1077- self ._update_and_launch_children (mapping )
1078- self ._set_status ('success' )
1076+ self ._update_and_launch_children (mapping )
1077+ self ._set_status ('success' )
10791078
10801079 def _complete_artifact_definition (self , artifact_data ):
10811080 """"Performs the needed steps to complete an artifact definition job
0 commit comments