Skip to content

Commit

Permalink
print task name and projdir also for --dryrun and use same API as Com…
Browse files Browse the repository at this point in the history
…mands/status in checkStatusLoop. Fix #5060 (#5062)
  • Loading branch information
belforte authored and ddaina committed Aug 25, 2021
1 parent 36cc62f commit d982842
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
34 changes: 17 additions & 17 deletions src/python/CRABClient/ClientUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def cmd_exist(cmd):
except OSError:
return False

def checkStatusLoop(logger, server, api, uniquerequestname, targetstatus, cmdname):
def checkStatusLoop(logger, server, api, taskname, targetstatus, cmdname):
logger.info("Waiting for task to be processed")

maxwaittime = 900 #in second, changed to 15 minute max wait time, the original 1 hour is too long
Expand All @@ -679,7 +679,7 @@ def checkStatusLoop(logger, server, api, uniquerequestname, targetstatus, cmdnam
logger.debug("Start time:%s" % (startimestring))
logger.debug("Max wait time: %s s until : %s" % (maxwaittime, endtimestring))

#logger.debug('Looking up detailed status of task %s' % uniquerequestname)
#logger.debug('Looking up detailed status of task %s' % taskname)

continuecheck = True
tmpresult = None
Expand All @@ -689,38 +689,38 @@ def checkStatusLoop(logger, server, api, uniquerequestname, targetstatus, cmdnam
currenttime = time.time()
querytimestring = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(currenttime))

logger.debug("Looking up detailed status of task %s" % (uniquerequestname))

dictresult, status, reason = server.get(api=api, data={'workflow' : uniquerequestname})
dictresult = dictresult['result'][0]
logger.debug("Looking up status of task %s" % (taskname))
# use same call as in Commands/status.py
crabDBInfo, status, reason = server.get(api='task', data={'subresource':'search', 'workflow':taskname})

if status != 200:
msg = "Error when trying to check the task status."
msg += " Please check the task status later using 'crab status'."
logger.error(msg)
msg = "Problem retrieving status:\ninput:%s\noutput:%s\nreason:%s" % (str(uniquerequestname), str(dictresult), str(reason))
msg = "Problem retrieving status:\ninput:%s\noutput:%s\nreason:%s" % (str(taskname), str(crabDBInfo), str(reason))
raise RESTCommunicationException(msg)

logger.debug("Query Time: %s Task status: %s" % (querytimestring, dictresult['status']))

logger.info("Task status: %s" % (dictresult['status']))
if dictresult['status'] != tmpresult:
tmpresult = dictresult['status']
if dictresult['status'] in ['SUBMITFAILED', 'RESUBMITFAILED']:
taskStatus = getColumn(crabDBInfo, 'tm_task_status')
logger.debug("Query Time: %s Task status: %s" % (querytimestring, taskStatus))
logger.info("Task status: %s" % (taskStatus))
if taskStatus != tmpresult:
tmpresult = taskStatus
if taskStatus in ['SUBMITFAILED', 'RESUBMITFAILED']:
continuecheck = False
msg = "%sError%s:" % (colors.RED, colors.NORMAL)
msg += " The %s of your task has failed." % ("resubmission" if cmdname == "resubmit" else "submission")
logger.error(msg)
if dictresult['taskFailureMsg']:
taskFailureMsg = getColumn(crabDBInfo, 'tm_task_failure')
if taskFailureMsg:
msg = "%sFailure message%s:" % (colors.RED, colors.NORMAL)
msg += "\t%s" % (dictresult['taskFailureMsg'].replace('\n', '\n\t\t\t'))
msg += "\t%s" % (taskFailureMsg.replace('\n', '\n\t\t\t'))
logger.error(msg)
elif dictresult['status'] in ['SUBMITTED', 'UPLOADED', 'UNKNOWN']: #until the node_state file is available status is unknown
elif taskStatus in ['SUBMITTED', 'UPLOADED']:
continuecheck = False
else:
logger.info("Please wait...")
time.sleep(30)
elif dictresult['status'] in ['NEW', 'HOLDING', 'QUEUED', 'RESUBMIT']:
elif taskStatus in ['NEW', 'HOLDING', 'QUEUED', 'RESUBMIT']:
logger.info("Please wait...")
time.sleep(30)
else:
Expand Down
6 changes: 3 additions & 3 deletions src/python/CRABClient/Commands/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ def __call__(self):
originalConfig=self.configuration)

self.logger.info("%sSuccess%s: Your task has been delivered to the %s CRAB3 server." % (colors.GREEN, colors.NORMAL, self.instance))
self.logger.info("Task name: %s" % uniquerequestname)
projDir = os.path.join(getattr(self.configuration.General, 'workArea', '.'), self.requestname)
self.logger.info("Project dir: %s" % projDir)
if not (self.options.wait or self.options.dryrun):
self.logger.info("Task name: %s" % uniquerequestname)
projDir = os.path.join(getattr(self.configuration.General, 'workArea', '.'), self.requestname)
self.logger.info("Project dir: %s" % projDir)
self.logger.info("Please use ' crab status -d %s ' to check how the submission process proceeds.", projDir)
else:
targetTaskStatus = 'UPLOADED' if self.options.dryrun else 'SUBMITTED'
Expand Down

0 comments on commit d982842

Please sign in to comment.