24
24
from DIRAC .FrameworkSystem .Client .ProxyManagerClient import gProxyManager
25
25
from DIRAC .StorageManagementSystem .Client .StorageManagerClient import StorageManagerClient
26
26
from DIRAC .WorkloadManagementSystem .Client import JobStatus
27
- from DIRAC .WorkloadManagementSystem .Utilities .JobModel import JobDescriptionModel
28
- from DIRAC .WorkloadManagementSystem .Utilities .ParametricJob import generateParametricJobs , getParameterVectorLength
29
-
30
27
from DIRAC .WorkloadManagementSystem .Service .JobPolicy import (
31
28
RIGHT_DELETE ,
32
29
RIGHT_KILL ,
35
32
RIGHT_SUBMIT ,
36
33
JobPolicy ,
37
34
)
35
+ from DIRAC .WorkloadManagementSystem .Utilities .JobModel import JobDescriptionModel
38
36
from DIRAC .WorkloadManagementSystem .Utilities .ParametricJob import generateParametricJobs , getParameterVectorLength
39
37
40
38
MAX_PARAMETRIC_JOBS = 20
@@ -85,7 +83,6 @@ def initializeRequest(self):
85
83
self .maxParametricJobs = self .srv_getCSOption ("MaxParametricJobs" , MAX_PARAMETRIC_JOBS )
86
84
self .jobPolicy = JobPolicy (self .owner , self .ownerGroup , self .userProperties )
87
85
self .jobPolicy .jobDB = self .jobDB
88
- self .ownerDN = getDNForUsername (self .owner )["Value" ][0 ]
89
86
return S_OK ()
90
87
91
88
def __sendJobsToOptimizationMind (self , jids ):
@@ -128,6 +125,8 @@ def export_submitJob(self, jobDesc):
128
125
:return: S_OK/S_ERROR, a list of newly created job IDs in case of S_OK.
129
126
"""
130
127
128
+ ownerDN = getDNForUsername (self .owner )["Value" ][0 ]
129
+
131
130
if self .peerUsesLimitedProxy :
132
131
return S_ERROR (EWMSSUBM , "Can't submit using a limited proxy" )
133
132
@@ -160,9 +159,9 @@ def export_submitJob(self, jobDesc):
160
159
if nJobs > self .maxParametricJobs :
161
160
self .log .error (
162
161
"Maximum of parametric jobs exceeded:" ,
163
- "limit %d smaller than number of jobs %d" % ( self . maxParametricJobs , nJobs ) ,
162
+ f "limit { self . maxParametricJobs } smaller than number of jobs { nJobs } " ,
164
163
)
165
- return S_ERROR (EWMSJDL , "Number of parametric jobs exceeds the limit of %d" % self .maxParametricJobs )
164
+ return S_ERROR (EWMSJDL , f "Number of parametric jobs exceeds the limit of { self .maxParametricJobs } " )
166
165
result = generateParametricJobs (jobClassAd )
167
166
if not result ["OK" ]:
168
167
return result
@@ -190,7 +189,7 @@ def export_submitJob(self, jobDesc):
190
189
JobDescriptionModel (
191
190
** baseJobDescritionModel .dict (exclude_none = True ),
192
191
owner = self .owner ,
193
- ownerDN = self . ownerDN ,
192
+ ownerDN = ownerDN ,
194
193
ownerGroup = self .ownerGroup ,
195
194
vo = getVOForGroup (self .ownerGroup ),
196
195
)
@@ -218,9 +217,9 @@ def export_submitJob(self, jobDesc):
218
217
jobIDList .append (jobID )
219
218
220
219
# Set persistency flag
221
- retVal = gProxyManager .getUserPersistence (self . ownerDN , self .ownerGroup )
220
+ retVal = gProxyManager .getUserPersistence (ownerDN , self .ownerGroup )
222
221
if "Value" not in retVal or not retVal ["Value" ]:
223
- gProxyManager .setPersistency (self . ownerDN , self .ownerGroup , True )
222
+ gProxyManager .setPersistency (ownerDN , self .ownerGroup , True )
224
223
225
224
if parametricJob :
226
225
result = S_OK (jobIDList )
@@ -295,7 +294,8 @@ def __checkIfProxyUploadIsRequired(self):
295
294
296
295
:return: bool
297
296
"""
298
- result = gProxyManager .userHasProxy (self .ownerDN , self .ownerGroup , validSeconds = 18000 )
297
+ ownerDN = getDNForUsername (self .owner )["Value" ][0 ]
298
+ result = gProxyManager .userHasProxy (ownerDN , self .ownerGroup , validSeconds = 18000 )
299
299
if not result ["OK" ]:
300
300
self .log .error ("Can't check if the user has proxy uploaded" , result ["Message" ])
301
301
return True
@@ -407,18 +407,18 @@ def export_removeJob(self, jobIDs):
407
407
for jobID in validJobList :
408
408
resultTQ = self .taskQueueDB .deleteJob (jobID )
409
409
if not resultTQ ["OK" ]:
410
- self .log .warn ("Failed to remove job from TaskQueueDB" , "(%d ): %s" % ( jobID , resultTQ [" Message" ]) )
410
+ self .log .warn ("Failed to remove job from TaskQueueDB" , f"( { jobID } ): { resultTQ [' Message' ] } " )
411
411
error_count += 1
412
412
else :
413
413
count += 1
414
414
415
- if not ( result := self .jobLoggingDB .deleteJob (validJobList ) )["OK" ]:
415
+ if not self .jobLoggingDB .deleteJob (validJobList )["OK" ]:
416
416
self .log .error ("Failed to remove jobs from JobLoggingDB" , f"(n={ len (validJobList )} )" )
417
417
else :
418
418
self .log .info ("Removed jobs from JobLoggingDB" , f"(n={ len (validJobList )} )" )
419
419
420
420
if count > 0 or error_count > 0 :
421
- self .log .info ("Removed jobs from DB" , "(%d jobs with %d errors)" % ( count , error_count ) )
421
+ self .log .info ("Removed jobs from DB" , f"( { count } jobs with { error_count } errors)" )
422
422
423
423
if invalidJobList or nonauthJobList :
424
424
self .log .error (
@@ -446,12 +446,10 @@ def __deleteJob(self, jobID):
446
446
:param int jobID: job ID
447
447
:return: S_OK()/S_ERROR()
448
448
"""
449
- result = self .jobDB .setJobStatus (jobID , JobStatus .DELETED , "Checking accounting" )
450
- if not result ["OK" ]:
449
+ if not (result := self .jobDB .setJobStatus (jobID , JobStatus .DELETED , "Checking accounting" ))["OK" ]:
451
450
return result
452
451
453
- result = self .taskQueueDB .deleteJob (jobID )
454
- if not result ["OK" ]:
452
+ if not (result := self .taskQueueDB .deleteJob (jobID ))["OK" ]:
455
453
self .log .warn ("Failed to delete job from the TaskQueue" )
456
454
457
455
# if it was the last job for the pilot
@@ -469,8 +467,7 @@ def __deleteJob(self, jobID):
469
467
if not result ["OK" ]:
470
468
self .log .error ("Failed to get pilot info" , result ["Message" ])
471
469
return result
472
- pilotRef = result [0 ]["PilotJobReference" ]
473
- ret = self .pilotAgentsDB .deletePilot (pilot )
470
+ ret = self .pilotAgentsDB .deletePilot (result ["Value" ]["PilotJobReference" ])
474
471
if not ret ["OK" ]:
475
472
self .log .error ("Failed to delete pilot from PilotAgentsDB" , ret ["Message" ])
476
473
return ret
@@ -522,7 +519,7 @@ def __kill_delete_jobs(self, jobIDList, right):
522
519
deleteJobList = []
523
520
markKilledJobList = []
524
521
stagingJobList = []
525
- for jobID , sDict in result ["Value" ].items (): # can be an iterator
522
+ for jobID , sDict in result ["Value" ].items ():
526
523
if sDict ["Status" ] in (JobStatus .RUNNING , JobStatus .MATCHED , JobStatus .STALLED ):
527
524
killJobList .append (jobID )
528
525
elif sDict ["Status" ] in (
0 commit comments