Skip to content

Commit bb0b367

Browse files
author
Robin VAN DE MERGHEL
committed
fix: Removed every client function not used by anyone, and moved one from an agent.
1 parent 898be85 commit bb0b367

File tree

4 files changed

+2
-215
lines changed

4 files changed

+2
-215
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/PilotStatusAgent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def execute(self):
7070

7171
connection.close()
7272

73-
result = self.pilots.clearPilots(self.clearPilotsDelay, self.clearAbortedDelay)
73+
result = self.pilotDB.clearPilots(self.clearPilotsDelay, self.clearAbortedDelay) # type: ignore
7474
if not result["OK"]:
7575
self.log.warn("Failed to clear old pilots in the PilotAgentsDB")
7676

src/DIRAC/WorkloadManagementSystem/FutureClient/PilotManagerClient.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ def setPilotStatus(self, pilot_stamp, status, destination=None, reason=None, gri
2929
},
3030
)
3131

32-
@convertToReturnValue
33-
def clearPilots(self, interval=30, aborted_interval=7):
34-
with DiracXClient() as api:
35-
api.pilots.delete_pilots(age_in_days=interval, delete_only_aborted=False)
36-
api.pilots.delete_pilots(age_in_days=aborted_interval, delete_only_aborted=True)
37-
3832
@convertToReturnValue
3933
def deletePilot(self, pilot_stamp):
4034
with DiracXClient() as api:
@@ -119,39 +113,3 @@ def deletePilots(self, pilot_stamps):
119113
pilot_stamps = [pilot["PilotStamp"] for pilot in pilots]
120114

121115
return api.pilots.delete_pilots(pilot_stamps=pilot_stamps) # type: ignore
122-
123-
@convertToReturnValue
124-
def setJobForPilot(self, job_id, pilot_stamp, destination=None):
125-
raise NotImplementedError(
126-
"This function is used by no one. I won't be adapted into DiracX via a legacy adaptor."
127-
)
128-
129-
@convertToReturnValue
130-
def countPilots(self, condDict, older=None, newer=None):
131-
raise NotImplementedError(
132-
"This function is used by no one. I won't be adapted into DiracX via a legacy adaptor."
133-
)
134-
135-
@convertToReturnValue
136-
def selectPilots(self, condDict):
137-
raise NotImplementedError(
138-
"This function is used by no one. I won't be adapted into DiracX via a legacy adaptor."
139-
)
140-
141-
@convertToReturnValue
142-
def getCurrentPilotCounters(self, attrDict={}):
143-
raise NotImplementedError(
144-
"This function is used by no one. I won't be adapted into DiracX via a legacy adaptor."
145-
)
146-
147-
@convertToReturnValue
148-
def setPilotBenchmark(self, pilotRef, mark):
149-
raise NotImplementedError(
150-
"This function is used by no one. I won't be adapted into DiracX via a legacy adaptor."
151-
)
152-
153-
@convertToReturnValue
154-
def setAccountingFlag(self, pilotRef, flag="True"):
155-
raise NotImplementedError(
156-
"This function is used by no one. I won't be adapted into DiracX via a legacy adaptor."
157-
)

src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,6 @@ def _getRemotePilotOutput(self, pilotReference, pilotDict):
166166
# return res, correct or not
167167
return res
168168

169-
##############################################################################
170-
171-
types_storePilotOutput = [str, str, str]
172-
173-
@classmethod
174-
def export_storePilotOutput(cls, pilotReference, output, error):
175-
"""Store the pilot output and error"""
176-
return cls.pilotAgentsDB.storePilotOutput(pilotReference, output, error)
177-
178169
##############################################################################
179170
types_getPilotLoggingInfo = [str]
180171

@@ -227,16 +218,6 @@ def export_getPilotSummary(cls, startdate="", enddate=""):
227218

228219
# --------------- Moved to DiracX ---------------
229220

230-
types_selectPilots = [dict]
231-
232-
@classmethod
233-
def export_selectPilots(cls, condDict):
234-
"""Select pilots given the selection conditions"""
235-
# Used by no one
236-
return cls.pilotAgentsDB.selectPilots(condDict)
237-
238-
#############################################
239-
240221
types_getGroupedPilotSummary = [list]
241222

242223
@classmethod
@@ -250,46 +231,6 @@ def export_getGroupedPilotSummary(cls, columnList):
250231
"""
251232
return cls.pilotAgentsDB.getGroupedPilotSummary(columnList)
252233

253-
types_countPilots = [dict]
254-
255-
@classmethod
256-
def export_countPilots(cls, condDict, older=None, newer=None, timeStamp="SubmissionTime"):
257-
"""Count pilots"""
258-
# Used by no one
259-
return cls.pilotAgentsDB.countPilots(condDict, older, newer, timeStamp)
260-
261-
types_getCurrentPilotCounters = [dict]
262-
263-
@classmethod
264-
def export_getCurrentPilotCounters(cls, attrDict={}):
265-
"""Get pilot counters per Status with attrDict selection. Final statuses are given for
266-
the last day.
267-
"""
268-
# Used by no one
269-
270-
result = cls.pilotAgentsDB.getCounters("PilotAgents", ["Status"], attrDict, timeStamp="LastUpdateTime")
271-
if not result["OK"]:
272-
return result
273-
last_update = datetime.datetime.utcnow() - TimeUtilities.day
274-
resultDay = cls.pilotAgentsDB.getCounters(
275-
"PilotAgents", ["Status"], attrDict, newer=last_update, timeStamp="LastUpdateTime"
276-
)
277-
if not resultDay["OK"]:
278-
return resultDay
279-
280-
resultDict = {}
281-
for statusDict, count in result["Value"]:
282-
status = statusDict["Status"]
283-
resultDict[status] = count
284-
if status in PilotStatus.PILOT_FINAL_STATES:
285-
resultDict[status] = 0
286-
for statusDayDict, ccount in resultDay["Value"]:
287-
if status == statusDayDict["Status"]:
288-
resultDict[status] = ccount
289-
break
290-
291-
return S_OK(resultDict)
292-
293234
#############################################
294235
types_addPilotReferences = [list, str]
295236

@@ -302,46 +243,6 @@ def export_addPilotReferences(cls, pilotStamps, VO, gridType="DIRAC", pilotRefDi
302243

303244
return cls.pilotAgentsDB.addPilotReferences(pilot_references, VO, gridType, pilot_stamp_dict)
304245

305-
#############################################
306-
types_setJobForPilot = [[str, int], str]
307-
308-
@classmethod
309-
def export_setJobForPilot(cls, jobID, pilotRef, destination=None):
310-
"""Report the DIRAC job ID which is executed by the given pilot job"""
311-
# Used by no one.
312-
313-
result = cls.pilotAgentsDB.setJobForPilot(int(jobID), pilotRef)
314-
if not result["OK"]:
315-
return result
316-
result = cls.pilotAgentsDB.setCurrentJobID(pilotRef, int(jobID))
317-
if not result["OK"]:
318-
return result
319-
if destination:
320-
result = cls.pilotAgentsDB.setPilotDestinationSite(pilotRef, destination)
321-
322-
return result
323-
324-
#############################################
325-
types_setPilotBenchmark = [str, float]
326-
327-
@classmethod
328-
def export_setPilotBenchmark(cls, pilotRef, mark):
329-
"""Set the pilot agent benchmark"""
330-
# Used by no one.
331-
return cls.pilotAgentsDB.setPilotBenchmark(pilotRef, mark)
332-
333-
#############################################
334-
types_setAccountingFlag = [str]
335-
336-
@classmethod
337-
def export_setAccountingFlag(cls, pilotRef, flag="True"):
338-
"""Set the pilot AccountingSent flag"""
339-
# Used by no one
340-
return cls.pilotAgentsDB.setAccountingFlag(pilotRef, mark)
341-
342-
#############################################
343-
types_setPilotStatus = [str, str]
344-
345246
@classmethod
346247
def export_setPilotStatus(cls, pilotRef, status, destination=None, reason=None, gridSite=None, queue=None):
347248
"""Set the pilot agent status"""
@@ -355,7 +256,7 @@ def export_setPilotStatus(cls, pilotRef, status, destination=None, reason=None,
355256

356257
@classmethod
357258
def export_deletePilots(cls, pilotIDs):
358-
# Used by no one.
259+
# Used by no one. We keep it for tests.
359260
if isinstance(pilotIDs, str):
360261
return cls.pilotAgentsDB.deletePilot(pilotIDs)
361262

@@ -373,13 +274,6 @@ def export_deletePilots(cls, pilotIDs):
373274

374275
return S_OK()
375276

376-
#############################################
377-
types_clearPilots = [int, int]
378-
379-
@classmethod
380-
def export_clearPilots(cls, interval=30, aborted_interval=7):
381-
return cls.pilotAgentsDB.clearPilots(interval, aborted_interval)
382-
383277
#############################################
384278
types_getPilots = [[str, int]]
385279

tests/Integration/WorkloadManagementSystem/Test_PilotsClient.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -35,63 +35,22 @@ def test_PilotsDB():
3535
assert not res["OK"], res
3636
assert "Conflict" in res["Message"]
3737

38-
# =================
39-
# >>> Used by no one and the legacy adaptor won't forward it.
40-
# res = pilots.getCurrentPilotCounters({})
41-
# assert res["OK"], res["Message"]
42-
# assert "Submitted" in res["Value"]
43-
# =================
44-
4538
res = pilots.deletePilots("aPilot")
4639
assert res["OK"], res["Message"]
4740

48-
# =================
49-
# >>> Used by no one and the legacy adaptor won't forward it.
50-
# res = pilots.getCurrentPilotCounters({})
51-
# assert res["OK"], res["Message"]
52-
# =================
53-
5441
res = pilots.addPilotReferences(["anotherPilot"], "VO")
5542
assert res["OK"], res["Message"]
5643

57-
# =================
58-
# >>> TODO: Not adapted yet in DiracX
59-
# res = pilots.storePilotOutput("anotherPilot", "This is an output", "this is an error")
60-
# assert res["OK"], res["Message"]
61-
# res = pilots.getPilotOutput("anotherPilot")
62-
# assert res["OK"], res["Message"]
63-
# assert res["Value"] == {
64-
# "VO": "VO",
65-
# "StdErr": "this is an error",
66-
# "FileList": [],
67-
# "StdOut": "This is an output",
68-
# }
69-
# =================
70-
7144
res = pilots.getPilotInfo("anotherPilot")
7245
assert res["OK"], res["Message"]
7346
assert res["Value"]["anotherPilot"]["AccountingSent"] == "False"
7447
assert res["Value"]["anotherPilot"]["PilotJobReference"] == "anotherPilot"
7548

76-
# =================
77-
# >>> Used by no one and the legacy adaptor won't forward it.
78-
# res = pilots.selectPilots({})
79-
# assert res["OK"], res["Message"]
80-
# =================
81-
8249
# >>> TODO: Implement me
8350
# res = pilots.getPilotSummary("", "")
8451
# assert res["OK"], res["Message"]
8552
# assert res["Value"]["Total"]["Submitted"] >= 1
8653

87-
# =================
88-
# >>> Used by no one and the legacy adaptor won't forward it.
89-
# res = pilots.setAccountingFlag("anotherPilot", "True")
90-
# assert res["OK"], res["Message"]
91-
# ...
92-
# assert res["Value"]["anotherPilot"]["AccountingSent"] == "True"
93-
# =================
94-
9554
res = pilots.setPilotStatus("anotherPilot", "Running")
9655
assert res["OK"], res["Message"]
9756
res = pilots.getPilotInfo("anotherPilot")
@@ -101,32 +60,8 @@ def test_PilotsDB():
10160
res = pilots.getGroupedPilotSummary([])
10261
assert res["OK"], res["Message"] # We won't test result (hopefully tested in DiracX)
10362

104-
# =================
105-
# >>> Used by no one and the legacy adaptor won't forward it.
106-
# res = pilots.setJobForPilot(123, "anotherPilot")
107-
# assert res["OK"], res["Message"]
108-
# =================
109-
110-
# =================
111-
# >>> Used by no one and the legacy adaptor won't forward it.
112-
# res = pilots.setPilotBenchmark("anotherPilot", 12.3)
113-
# assert res["OK"], res["Message"]
114-
# =================
115-
116-
# =================
117-
# >>> Used by no one and the legacy adaptor won't forward it.
118-
# res = pilots.countPilots({})
119-
# assert res["OK"], res["Message"]
120-
# =================
121-
12263
res = pilots.deletePilots("anotherPilot")
12364
assert res["OK"], res["Message"]
12465
# Delete twice, second time an error is raised
12566
res = pilots.deletePilots("anotherPilot")
12667
assert not res["OK"], res["Message"]
127-
128-
# =================
129-
# >>> Used by no one and the legacy adaptor won't forward it.
130-
# res = pilots.getCurrentPilotCounters({})
131-
# assert res["OK"], res["Message"]
132-
# =================

0 commit comments

Comments
 (0)