26
26
27
27
HOLD_REASON_SUBCODE = "55"
28
28
29
+ STATE_ATTRIBUTES = "ClusterId,ProcId,JobStatus,HoldReasonCode,HoldReasonSubCode,HoldReason"
30
+
29
31
subTemplate = """
30
32
# Environment
31
33
# -----------
@@ -94,7 +96,7 @@ def getCondorStatus(jobMetadata):
94
96
"""parse the condor_q or condor_history output for the job status
95
97
96
98
:param jobMetadata: dict with job metadata
97
- :type lines : dict[str, str | int]
99
+ :type jobMetadata : dict[str, str | int]
98
100
:returns: Status as known by DIRAC, and a reason if the job is being held
99
101
"""
100
102
if jobMetadata ["JobStatus" ] != 5 :
@@ -272,10 +274,9 @@ def getJobStatus(self, **kwargs):
272
274
273
275
# Prepare the command to get the status of the jobs
274
276
cmdJobs = " " .join (str (jobID ) for jobID in jobIDList )
275
- attributes = "ClusterId,ProcId,JobStatus,HoldReasonCode,HoldReasonSubCode,HoldReason"
276
277
277
278
# Get the status of the jobs currently active
278
- cmd = "condor_q %s -attributes %s -json" % (cmdJobs , attributes )
279
+ cmd = "condor_q %s -attributes %s -json" % (cmdJobs , STATE_ATTRIBUTES )
279
280
sp = subprocess .Popen (
280
281
shlex .split (cmd ),
281
282
stdout = subprocess .PIPE ,
@@ -290,10 +291,10 @@ def getJobStatus(self, **kwargs):
290
291
resultDict ["Message" ] = error
291
292
return resultDict
292
293
293
- jobMetadata = json .loads (output )
294
+ jobsMetadata = json .loads (output )
294
295
295
296
# Get the status of the jobs in the history
296
- condorHistCall = "condor_history %s -attributes %s -json" % (cmdJobs , attributes )
297
+ condorHistCall = "condor_history %s -attributes %s -json" % (cmdJobs , STATE_ATTRIBUTES )
297
298
sp = subprocess .Popen (
298
299
shlex .split (condorHistCall ),
299
300
stdout = subprocess .PIPE ,
@@ -308,12 +309,12 @@ def getJobStatus(self, **kwargs):
308
309
resultDict ["Message" ] = error
309
310
return resultDict
310
311
311
- jobMetadata += json .loads (output )
312
+ jobsMetadata += json .loads (output )
312
313
313
314
statusDict = {}
314
- # Build a set of job IDs found in jobMetadata
315
+ # Build a set of job IDs found in jobsMetadata
315
316
foundJobIDs = set ()
316
- for jobDict in jobMetadata :
317
+ for jobDict in jobsMetadata :
317
318
jobID = "%s.%s" % (jobDict ["ClusterId" ], jobDict ["ProcId" ])
318
319
statusDict [jobID ], _ = getCondorStatus (jobDict )
319
320
foundJobIDs .add (jobID )
0 commit comments