Skip to content

Commit 652750d

Browse files
Robin VAN DE MERGHELRobin-Van-de-Merghel
authored andcommitted
feat: Add more functions from JobMonitoring to DiracX
1 parent 216e6b7 commit 652750d

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

src/DIRAC/WorkloadManagementSystem/FutureClient/JobMonitoringClient.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ def getJobsSites(self, jobIDs):
3232
def getJobsStatus(self, jobIDs):
3333
return self.fetch(["Status"], jobIDs)
3434

35+
@convertToReturnValue
36+
def getJobParameter(self, jobID, parName):
37+
# with DiracXClient() as api:
38+
# parameters = api.jobs.get_job_parameters(
39+
# job_id=jobID
40+
# )
41+
42+
# return parameters
43+
pass
44+
3545
@convertToReturnValue
3646
def getJobParameters(self, jobIDs):
3747
# if isinstance(jobIDs, int):
@@ -83,3 +93,73 @@ def cleanLFN(data):
8393
return_dict[job_id].append(cleanLFN(data))
8494

8595
return return_dict
96+
97+
@convertToReturnValue
98+
def getJobs(self, attrDict, cutDate=None):
99+
# TODO: Check, selectJobs is awful...
100+
# See if we do it
101+
pass
102+
103+
@convertToReturnValue
104+
def getJobJDL(self, jobID, original):
105+
with DiracXClient() as api:
106+
jdl = api.jobs.get_job_jdl(job_id=jobID)
107+
108+
if not jdl:
109+
return ""
110+
111+
if original:
112+
return jdl["OriginalJDL"]
113+
114+
return jdl["JDL"]
115+
116+
@convertToReturnValue
117+
def getJobLoggingInfo(self, jobID):
118+
fields = ["DateTime", "Source", "Status", "MinorStatus", "ApplicationStatus"] # CF Dirac.py
119+
120+
jobs = self.fetch(parameters=["LoggingInfo"] + fields, jobIDs=[jobID])
121+
122+
# Normally, only one job
123+
if len(jobs) == 0:
124+
return []
125+
job = jobs[0]
126+
127+
# Rearrange into a list, CF Dirac.py
128+
res = []
129+
for field in fields:
130+
res.append(job.get(field, ""))
131+
132+
return res
133+
134+
@convertToReturnValue
135+
def getJobSummary(self, jobID):
136+
return self.fetch(parameters=[], jobIDs=[jobID])
137+
138+
@convertToReturnValue
139+
def getJobsSummary(self, jobIDs):
140+
return self.fetch(parameters=[], jobIDs=jobIDs)
141+
142+
@convertToReturnValue
143+
def getJobAttributes(self, jobID, attrList=None):
144+
if not attrList:
145+
attrList = []
146+
147+
return self.fetch(parameters=attrList, jobIDs=[jobID])
148+
149+
@convertToReturnValue
150+
def getJobAttribute(self, jobID, attribute):
151+
return self.fetch(parameters=[attribute], jobIDs=[jobID])
152+
153+
@convertToReturnValue
154+
def getJobHeartBeatData(self, jobID):
155+
with DiracXClient() as api:
156+
res = api.jobs.get_job_heartbeat_info(job_id=jobID)
157+
158+
result = []
159+
for row in res:
160+
name = row["Name"]
161+
value = str(row["Value"])
162+
heartbeattime = row["HeartBeatTime"]
163+
# ('name', '"0.1"', 'time')
164+
# :)
165+
result.append((str(name), "%.01f" % (float(value.replace('"', ""))), str(heartbeattime)))

0 commit comments

Comments
 (0)