Skip to content

Commit ff85c84

Browse files
committed
feat: introduce addPilotReferences() method
1 parent 096bb08 commit ff85c84

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

src/DIRAC/Interfaces/API/DiracAdmin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ def getPilotInfo(self, gridReference):
553553
if not isinstance(gridReference, str):
554554
return self._errorReport("Expected string for pilot reference")
555555

556+
# TODO: to remove from v9.0
557+
gLogger.notice("Notice: 'TaskQueueID' will be removed from the output in v9.0.")
558+
556559
result = PilotManagerClient().getPilotInfo(gridReference)
557560
return result
558561

@@ -599,14 +602,16 @@ def getJobPilots(self, jobID):
599602
:param job: JobID
600603
:type job: integer or string
601604
:return: S_OK,S_ERROR
602-
603605
"""
604606
if isinstance(jobID, str):
605607
try:
606608
jobID = int(jobID)
607609
except ValueError as x:
608610
return self._errorReport(str(x), "Expected integer or string for existing jobID")
609611

612+
# TODO: remove this comment from v9.0
613+
gLogger.notice("Notice: 'TaskQueueID' will be removed from the output in v9.0.")
614+
610615
result = PilotManagerClient().getPilots(jobID)
611616
if result["OK"]:
612617
gLogger.notice(self.pPrint.pformat(result["Value"]))

src/DIRAC/WorkloadManagementSystem/Agent/StatesAccountingAgent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def execute(self):
7979
# PilotsHistory to Monitoring
8080
if "Monitoring" in self.pilotMonitoringOption:
8181
self.log.info("Committing PilotsHistory to Monitoring")
82+
83+
# TODO: remove this comment from v9.0
84+
self.log.notice("Notice: 'TaskQueueID' will be removed from the pilotAgentsDB in v9.0.")
85+
8286
result = PilotAgentsDB().getSummarySnapshot()
8387
now = datetime.datetime.utcnow()
8488
if not result["OK"]:

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Available methods are:
77
8+
addPilotReferences()
89
addPilotTQReference()
910
setPilotStatus()
1011
deletePilot()
@@ -20,6 +21,7 @@
2021
import datetime
2122
import decimal
2223
import threading
24+
from DIRAC.Core.Utilities.Decorators import deprecated
2325

2426
import DIRAC.Core.Utilities.TimeUtilities as TimeUtilities
2527
from DIRAC import S_ERROR, S_OK
@@ -38,6 +40,30 @@ def __init__(self, parentLogger=None):
3840
self.lock = threading.Lock()
3941

4042
##########################################################################################
43+
def addPilotReferences(self, pilotRef, ownerGroup, gridType="DIRAC", pilotStampDict={}):
44+
"""Add a new pilot job reference"""
45+
for ref in pilotRef:
46+
stamp = ""
47+
if ref in pilotStampDict:
48+
stamp = pilotStampDict[ref]
49+
50+
req = (
51+
"INSERT INTO PilotAgents( PilotJobReference, TaskQueueID, OwnerDN, "
52+
+ "OwnerGroup, Broker, GridType, SubmissionTime, LastUpdateTime, Status, PilotStamp ) "
53+
+ "VALUES ('%s',%d,%s,'%s','%s','%s',UTC_TIMESTAMP(),UTC_TIMESTAMP(),'Submitted','%s')"
54+
% (ref, 0, "Unknown", ownerGroup, "Unknown", gridType, stamp)
55+
)
56+
57+
result = self._update(req)
58+
if not result["OK"]:
59+
return result
60+
61+
if "lastRowId" not in result:
62+
return S_ERROR("PilotAgentsDB.addPilotReferences: Failed to retrieve a new Id.")
63+
64+
return S_OK()
65+
66+
@deprecated("Use addPilotReferences instead")
4167
def addPilotTQReference(
4268
self, pilotRef, taskQueueID, ownerDN, ownerGroup, broker="Unknown", gridType="DIRAC", pilotStampDict={}
4369
):

src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import datetime
66

77
from DIRAC import S_OK, S_ERROR
8+
from DIRAC.Core.Utilities.Decorators import deprecated
89
import DIRAC.Core.Utilities.TimeUtilities as TimeUtilities
910

1011
from DIRAC.Core.DISET.RequestHandler import RequestHandler
@@ -80,9 +81,17 @@ def export_getCurrentPilotCounters(cls, attrDict={}):
8081
return S_OK(resultDict)
8182

8283
##########################################################################################
84+
types_addPilotReferences = [list, str]
85+
86+
@classmethod
87+
def export_addPilotReferences(cls, pilotRef, ownerGroup, gridType="DIRAC", pilotStampDict={}):
88+
"""Add a new pilot job reference"""
89+
return cls.pilotAgentsDB.addPilotReferences(pilotRef, ownerGroup, gridType, pilotStampDict)
90+
8391
types_addPilotTQReference = [list, int, str, str]
8492

8593
@classmethod
94+
@deprecated("Use addPilotReferences instead")
8695
def export_addPilotTQReference(
8796
cls, pilotRef, taskQueueID, ownerDN, ownerGroup, broker="Unknown", gridType="DIRAC", pilotStampDict={}
8897
):

src/DIRAC/WorkloadManagementSystem/scripts/dirac_admin_add_pilot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def setTaskQueueID(self, value):
5151
5252
:return: S_OK()/S_ERROR()
5353
"""
54+
# TODO: remove this comment from v9.0
55+
gLogger.notice("Notice: 'TaskQueueID' will be removed from the pilotAgentsDB in v9.0.")
56+
5457
try:
5558
self.taskQueueID = int(value)
5659
except ValueError:

0 commit comments

Comments
 (0)