Skip to content

Commit 8c13c25

Browse files
committed
fix: removed unused function
1 parent 4c1bf62 commit 8c13c25

File tree

11 files changed

+46
-123
lines changed

11 files changed

+46
-123
lines changed

release.notes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
*TransformationSystem
44

5-
NEW: (#7170)
6-
Implement a finer grained permissions model for Transformations.
5+
NEW: (#7170) Implement a finer grained permissions model for Transformations.
76

87
*DataManagementSystem
98

src/DIRAC/Interfaces/API/DiracAdmin.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -385,22 +385,6 @@ def getVOMSProxy(self, userDN, userGroup, vomsAttr=False, validity=43200, limite
385385
userDN, userGroup, limited=limited, requiredVOMSAttribute=vomsAttr, requiredTimeLeft=validity
386386
)
387387

388-
#############################################################################
389-
def getPilotProxy(self, userDN, userGroup, validity=43200):
390-
"""Retrieves a pilot proxy with default 12hr validity and stores
391-
this in a file in the local directory by default.
392-
393-
Example usage:
394-
395-
>>> gLogger.notice(diracAdmin.getVOMSProxy())
396-
{'OK': True, 'Value': }
397-
398-
:return: S_OK,S_ERROR
399-
400-
"""
401-
402-
return gProxyManager.getPilotProxyFromDIRACGroup(userDN, userGroup, requiredTimeLeft=validity)
403-
404388
#############################################################################
405389
def resetJob(self, jobID):
406390
"""Reset a job or list of jobs in the WMS. This operation resets the reschedule

src/DIRAC/Interfaces/scripts/dirac_admin_get_job_pilots.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
#!/usr/bin/env python
2-
########################################################################
3-
# File : dirac-admin-get-job-pilots
4-
# Author : Stuart Paterson
5-
########################################################################
62
"""
73
Retrieve info about pilots that have matched a given Job
84
@@ -17,22 +13,18 @@
1713
'LastUpdateTime': datetime.datetime(2011, 2, 21, 12, 39, 10),
1814
'OutputReady': 'True',
1915
'OwnerGroup': '/biomed',
20-
'PilotID': 2247L,
2116
'PilotJobReference': 'https://marlb.in2p3.fr:9000/biq6KT45Q',
2217
'PilotStamp': '',
2318
'Status': 'Done',
2419
'SubmissionTime': datetime.datetime(2011, 2, 21, 12, 27, 52),
2520
'TaskQueueID': 399L}}
2621
"""
27-
# pylint: disable=wrong-import-position
2822
from DIRAC.Core.Base.Script import Script
2923

3024

3125
@Script()
3226
def main():
33-
# Registering arguments will automatically add their description to the help menu
3427
Script.registerArgument(["JobID: DIRAC ID of the Job"])
35-
# parseCommandLine show help when mandatory arguments are not specified or incorrect argument
3628
_, args = Script.parseCommandLine(ignoreErrors=True)
3729

3830
from DIRAC import exit as DIRACExit
@@ -55,8 +47,8 @@ def main():
5547
errorList.append((job, result["Message"]))
5648
exitCode = 2
5749

58-
for error in errorList:
59-
print("ERROR %s: %s" % error)
50+
for job, error in errorList:
51+
print(f"ERROR for {job}: {error}")
6052

6153
DIRACExit(exitCode)
6254

src/DIRAC/Interfaces/scripts/dirac_admin_get_pilot_info.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
#!/usr/bin/env python
2-
########################################################################
3-
# File : dirac-admin-get-pilot-info
4-
# Author : Ricardo Graciani
5-
########################################################################
62
"""
73
Retrieve available info about the given pilot
84
@@ -16,14 +12,12 @@
1612
'LastUpdateTime': datetime.datetime(2011, 2, 21, 12, 49, 14),
1713
'OutputReady': 'False',
1814
'OwnerGroup': '/biomed',
19-
'PilotID': 2241L,
2015
'PilotJobReference': 'https://marlb.in2p3.fr:9000/2KHFrQjkw',
2116
'PilotStamp': '',
2217
'Status': 'Done',
2318
'SubmissionTime': datetime.datetime(2011, 2, 21, 12, 27, 52),
2419
'TaskQueueID': 399L}}
2520
"""
26-
# pylint: disable=wrong-import-position
2721
from DIRAC.Core.Base.Script import Script
2822

2923
extendedPrint = False
@@ -60,7 +54,6 @@ def main():
6054
for key in [
6155
"PilotJobReference",
6256
"Status",
63-
"OwnerDN",
6457
"OwnerGroup",
6558
"SubmissionTime",
6659
"DestinationSite",
@@ -82,10 +75,9 @@ def main():
8275
diracAdmin.log.notice(f"{tab}Job ID: {jobID}")
8376
tab += " "
8477
for key in [
85-
"OwnerDN",
86-
"OwnerGroup",
8778
"JobName",
8879
"Status",
80+
"OwnerGroup",
8981
"StartExecTime",
9082
"LastUpdateTime",
9183
"EndExecTime",
@@ -96,8 +88,8 @@ def main():
9688
else:
9789
print(diracAdmin.pPrint.pformat({gridID: res}))
9890

99-
for error in errorList:
100-
print("ERROR %s: %s" % error)
91+
for job, error in errorList:
92+
print(f"ERROR for {job}: {error}")
10193

10294
DIRACExit(exitCode)
10395

src/DIRAC/ResourceStatusSystem/Command/PilotCommand.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ def doNew(self, masterParams=None):
9393
return S_ERROR(f'"{element}" is not Site nor Resource')
9494

9595
if element == "Resource":
96-
pilotsResultPivot = self.pilots.getGroupedPilotSummary({}, ["GridSite", "DestinationSite", "OwnerGroup"])
96+
pilotsResultPivot = self.pilots.getGroupedPilotSummary(["GridSite", "DestinationSite", "OwnerGroup"])
9797
elif element == "Site":
98-
pilotsResultPivot = self.pilots.getGroupedPilotSummary({}, ["GridSite", "OwnerGroup"])
98+
pilotsResultPivot = self.pilots.getGroupedPilotSummary(["GridSite", "OwnerGroup"])
9999
else:
100100
# You should never see this error
101101
return S_ERROR(f'"{element}" is not Site nor Resource')

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.py

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def addPilotTQReference(self, pilotRef, taskQueueID, ownerGroup, gridType="DIRAC
4949
stamp = pilotStampDict[ref]
5050

5151
req = (
52-
"INSERT INTO PilotAgents( PilotJobReference, TaskQueueID, "
53-
+ "OwnerGroup, GridType, SubmissionTime, LastUpdateTime, Status, PilotStamp ) "
52+
"INSERT INTO PilotAgents "
53+
+ "(PilotJobReference, TaskQueueID, OwnerGroup, GridType, SubmissionTime, LastUpdateTime, Status, PilotStamp) "
5454
+ "VALUES ('%s',%d,'%s','%s',UTC_TIMESTAMP(),UTC_TIMESTAMP(),'Submitted','%s')"
5555
% (ref, int(taskQueueID), ownerGroup, gridType, stamp)
5656
)
@@ -574,61 +574,16 @@ def getPilotSummary(self, startdate="", enddate=""):
574574

575575
return S_OK(summary_dict)
576576

577-
# def getPilotSummaryShort( self, startTimeWindow = None, endTimeWindow = None, ce = '' ):
578-
# """
579-
# Spin off the method getPilotSummary. It is doing things in such a way that
580-
# do not make much sense. This method returns the pilots that were updated in the
581-
# time window [ startTimeWindow, endTimeWindow ), if they are present.
582-
# """
583-
#
584-
# sqlSelect = 'SELECT DestinationSite,Status,count(Status) FROM PilotAgents'
585-
#
586-
# whereSelect = []
587-
#
588-
# if startTimeWindow is not None:
589-
# whereSelect.append( ' LastUpdateTime >= "%s"' % startTimeWindow )
590-
# if endTimeWindow is not None:
591-
# whereSelect.append( ' LastUpdateTime < "%s"' % endTimeWindow )
592-
# if ce:
593-
# whereSelect.append( ' DestinationSite = "%s"' % ce )
594-
#
595-
# if whereSelect:
596-
# sqlSelect += ' WHERE'
597-
# sqlSelect += ' AND'.join( whereSelect )
598-
#
599-
# sqlSelect += ' GROUP BY DestinationSite,Status'
600-
#
601-
# resSelect = self._query( sqlSelect )
602-
# if not resSelect[ 'OK' ]:
603-
# return resSelect
604-
#
605-
# result = { 'Total' : collections.defaultdict( int ) }
606-
#
607-
# for row in resSelect[ 'Value' ]:
608-
#
609-
# ceName, statusName, statusCount = row
610-
#
611-
# if not ceName in result:
612-
# result[ ceName ] = {}
613-
# result[ ceName ][ statusName ] = int( statusCount )
614-
#
615-
# result[ 'Total' ][ statusName ] += int( statusCount )
616-
#
617-
# return S_OK( result )
618-
619577
##########################################################################################
620-
def getGroupedPilotSummary(self, selectDict, columnList):
578+
def getGroupedPilotSummary(self, columnList):
621579
"""
622580
The simplified pilot summary based on getPilotSummaryWeb method. It calculates pilot efficiency
623581
based on the same algorithm as in the Web version, basically takes into account Done and
624582
Aborted pilots only from the last day. The selection is done entirely in SQL.
625583
626-
:param dict selectDict: A dictionary to pass additional conditions to select statements, i.e.
627-
it allows to define start time for Done and Aborted Pilots. Unused.
628584
:param list columnList: A list of column to consider when grouping to calculate efficiencies.
629585
e.g. ['GridSite', 'DestinationSite'] is used to calculate efficiencies
630-
for sites and CEs. If we want to add an OwnerGroup it would be:
631-
['GridSite', 'DestinationSite', 'OwnerGroup'].
586+
for sites and CEs.
632587
:return: S_OK/S_ERROR with a dict containing the ParameterNames and Records lists.
633588
"""
634589

src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ def export_getCurrentPilotCounters(cls, attrDict={}):
7575
@deprecated("Use addPilotTQRef")
7676
@classmethod
7777
def export_addPilotTQReference(
78-
cls, pilotRef, taskQueueID, ownerDN, ownerGroup, gridType="DIRAC", pilotStampDict={}
78+
cls, pilotRef, taskQueueID, ownerDN, ownerGroup, broker="Unknown", gridType="DIRAC", pilotStampDict={}
7979
):
8080
"""Add a new pilot job reference"""
8181

82-
return cls.pilotAgentsDB.addPilotTQReference(pilotRef, taskQueueID, ownerGroup, gridType, pilotStampDict)
82+
return cls.pilotAgentsDB.addPilotTQReference(pilotRef, taskQueueID, gridType, pilotStampDict)
8383

84-
types_addPilotTQRef = [list, int, str, str]
84+
types_addPilotTQRef = [list, int, str]
8585

8686
@classmethod
8787
def export_addPilotTQRef(cls, pilotRef, taskQueueID, ownerGroup, gridType="DIRAC", pilotStampDict={}):
@@ -265,19 +265,18 @@ def export_getPilotSummaryWeb(cls, selectDict, sortList, startItem, maxItems):
265265
return cls.pilotAgentsDB.getPilotSummaryWeb(selectDict, sortList, startItem, maxItems)
266266

267267
##############################################################################
268-
types_getGroupedPilotSummary = [dict, list]
268+
types_getGroupedPilotSummary = [list]
269269

270270
@classmethod
271-
def export_getGroupedPilotSummary(cls, selectDict, columnList):
271+
def export_getGroupedPilotSummary(cls, columnList):
272272
"""
273273
Get pilot summary showing grouped by columns in columnList, all pilot states
274274
and pilot efficiencies in a single row.
275275
276-
:param selectDict: additional arguments to SELECT clause
277276
:param columnList: a list of columns to GROUP BY (less status column)
278277
:return: a dictionary containing column names and data records
279278
"""
280-
return cls.pilotAgentsDB.getGroupedPilotSummary(selectDict, columnList)
279+
return cls.pilotAgentsDB.getGroupedPilotSummary(columnList)
281280

282281
##############################################################################
283282
types_getPilots = [[str, int]]
@@ -339,8 +338,9 @@ def export_killPilot(cls, pilotRefList):
339338
return S_ERROR("Failed to get info for pilot " + pilotReference)
340339

341340
pilotDict = result["Value"][pilotReference]
342-
group = pilotDict["OwnerGroup"]
343-
queue = "@@@".join([group, pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]])
341+
queue = "@@@".join(
342+
[pilotDict["OwnerGroup"], pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]]
343+
)
344344
gridType = pilotDict["GridType"]
345345
pilotRefDict.setdefault(queue, {})
346346
pilotRefDict[queue].setdefault("PilotList", [])

src/DIRAC/WorkloadManagementSystem/Service/WMSUtilities.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
from DIRAC import S_OK, S_ERROR, gLogger, gConfig
88
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getQueue
9-
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getGroupOption, getUsernameForDN
9+
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getGroupOption, getUsernameForDN, getVOForGroup
10+
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1011
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
1112
from DIRAC.FrameworkSystem.Client.TokenManagerClient import gTokenManager
1213
from DIRAC.Resources.Computing.ComputingElementFactory import ComputingElementFactory
@@ -111,7 +112,7 @@ def killPilotsInQueues(pilotRefDict):
111112
ceFactory = ComputingElementFactory()
112113

113114
for key, pilotDict in pilotRefDict.items():
114-
owner, group, site, ce, queue = key.split("@@@")
115+
pilotGroup, site, ce, queue = key.split("@@@")
115116
result = getQueue(site, ce, queue)
116117
if not result["OK"]:
117118
return result
@@ -122,13 +123,20 @@ def killPilotsInQueues(pilotRefDict):
122123
return result
123124
ce = result["Value"]
124125

125-
group = getGroupOption(group, "VOMSRole", group)
126-
ret = gProxyManager.getPilotProxyFromVOMSGroup(owner, group)
127-
if not ret["OK"]:
128-
gLogger.error("Could not get proxy:", f"User '{owner}' Group '{group}' : {ret['Message']}")
129-
return S_ERROR("Failed to get the pilot's owner proxy")
130-
proxy = ret["Value"]
131-
ce.setProxy(proxy)
126+
pilotDN = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotDN")
127+
128+
if pilotGroup and pilotDN:
129+
res = getUsernameForDN(pilotDN)
130+
if not res["OK"]:
131+
return res
132+
owner = res["Value"]
133+
group = getGroupOption(pilotGroup, "VOMSRole", pilotGroup)
134+
ret = gProxyManager.getPilotProxyFromVOMSGroup(owner, group)
135+
if not ret["OK"]:
136+
gLogger.error("Could not get proxy:", f"User '{owner}' Group '{group}' : {ret['Message']}")
137+
return S_ERROR("Failed to get the pilot's owner proxy")
138+
proxy = ret["Value"]
139+
ce.setProxy(proxy)
132140

133141
pilotList = pilotDict["PilotList"]
134142
result = ce.killJob(pilotList)

src/DIRAC/WorkloadManagementSystem/scripts/dirac_admin_add_pilot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
This script is here to solve specifically this issue, even though it can be used for other things too.
99
1010
Example:
11-
$ dirac-admin-add-pilot htcondor:123456 user user_group DIRAC A11D8D2E-60F8-17A6-5520-E2276F41 --Status=Running
11+
$ dirac-admin-add-pilot htcondor:123456 group DIRAC A11D8D2E-60F8-17A6-5520-E2276F41 --Status=Running
1212
1313
"""
1414

@@ -88,7 +88,7 @@ def main():
8888
if not DErrno.cmpError(res, DErrno.EWMSNOPILOT):
8989
gLogger.error(res["Message"])
9090
DIRACExit(1)
91-
res = pmc.addPilotTQRef([pilotRef], params.taskQueueID, ownerGroup, "Unknown", gridType, {pilotRef: pilotStamp})
91+
res = pmc.addPilotTQRef([pilotRef], params.taskQueueID, ownerGroup, gridType, {pilotRef: pilotStamp})
9292
if not res["OK"]:
9393
gLogger.error(res["Message"])
9494
DIRACExit(1)

tests/Integration/WorkloadManagementSystem/Test_PilotAgentsDB.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ def cleanUpPilots(pilotRef):
8080

8181
def test_basic():
8282
"""usual insert/verify"""
83-
res = paDB.addPilotTQReference(
84-
["pilotRef"],
85-
123,
86-
"ownerGroup",
87-
)
83+
res = paDB.addPilotTQReference(["pilotRef"], 123, "ownerGroup")
8884
assert res["OK"] is True
8985

9086
res = paDB.deletePilot("pilotRef")
@@ -101,16 +97,14 @@ def test_getGroupedPilotSummary(mocked_fcn):
10197
"""
10298
stateCount = [10, 50, 7, 3, 12, 8, 6, 4]
10399
testGroup = "ownerGroup"
104-
testGroupVO = "ownerGroupVO"
105100
testCE = "TestCE"
106101
testSite = "TestSite"
107102

108103
mocked_fcn.return_value = "ownerGroupVO"
109104

110105
pilotRef = preparePilots(stateCount, testSite, testCE, testGroup)
111-
selectDict = {}
112106
columnList = ["GridSite", "DestinationSite", "OwnerGroup"]
113-
res = paDB.getGroupedPilotSummary(selectDict, columnList)
107+
res = paDB.getGroupedPilotSummary(columnList)
114108

115109
cleanUpPilots(pilotRef)
116110
expectedParameterList = [
@@ -144,7 +138,6 @@ def test_getGroupedPilotSummary(mocked_fcn):
144138
assert len(record) == len(expectedParameterList)
145139
assert record[0] == testSite
146140
assert record[1] == testCE
147-
assert record[2] == testGroupVO
148141

149142
# pilot state counts:
150143
for i, entry in enumerate(record[3:11]):

0 commit comments

Comments
 (0)