Skip to content

Commit d019813

Browse files
committed
fix: Fix PilotMonitoringPlotter
1 parent 91111c7 commit d019813

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
"""
2+
This class is used to define the plot using the plot attributes.
3+
"""
4+
5+
from DIRAC import S_OK
6+
7+
from DIRAC.MonitoringSystem.Client.Types.PilotMonitoring import PilotMonitoring
8+
from DIRAC.MonitoringSystem.private.Plotters.BasePlotter import BasePlotter
9+
10+
__RCSID__ = "$Id$"
11+
12+
13+
class WMSHistoryPlotter(BasePlotter):
14+
15+
"""
16+
.. class:: PilotMonitoringPlotter
17+
18+
It is used to crate the plots.
19+
20+
param: str _typeName monitoring type
21+
param: list _typeKeyFields list of keys what we monitor (list of attributes)
22+
"""
23+
24+
_typeName = "PilotMonitoring"
25+
_typeKeyFields = PilotMonitoring().keyFields
26+
27+
def reportNumberOfSubmissions(self, reportRequest):
28+
"""It is used to retrieve the data from the database.
29+
30+
:param dict reportRequest: contains attributes used to create the plot.
31+
:return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length
32+
"""
33+
retVal = self._getTimedData(
34+
startTime=reportRequest["startTime"],
35+
endTime=reportRequest["endTime"],
36+
selectField="NumTotal",
37+
preCondDict=reportRequest["condDict"],
38+
metadataDict=None,
39+
)
40+
if not retVal["OK"]:
41+
return retVal
42+
dataDict, granularity = retVal["Value"]
43+
return S_OK({"data": dataDict, "granularity": granularity})
44+
45+
def _plotNumberOfSubmissions(self, reportRequest, plotInfo, filename):
46+
"""It creates the plot.
47+
48+
:param dict reportRequest: plot attributes
49+
:param dict plotInfo: contains all the data which are used to create the plot
50+
:param str filename:
51+
:return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE
52+
"""
53+
metadata = {
54+
"title": "Pilot Submissions by %s" % reportRequest["grouping"],
55+
"starttime": reportRequest["startTime"],
56+
"endtime": reportRequest["endTime"],
57+
"span": plotInfo["granularity"],
58+
"skipEdgeColor": True,
59+
"ylabel": "Submissions",
60+
}
61+
62+
plotInfo["data"] = self._fillWithZero(
63+
granularity=plotInfo["granularity"],
64+
startEpoch=reportRequest["startTime"],
65+
endEpoch=reportRequest["endTime"],
66+
dataDict=plotInfo["data"],
67+
)
68+
69+
return self._generateStackedLinePlot(filename=filename, dataDict=plotInfo["data"], metadata=metadata)
70+
71+
def reportNumSucceeded(self, reportRequest):
72+
"""It is used to retrieve the data from the database.
73+
74+
:param dict reportRequest: contains attributes used to create the plot.
75+
:return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length
76+
"""
77+
retVal = self._getTimedData(
78+
startTime=reportRequest["startTime"],
79+
endTime=reportRequest["endTime"],
80+
selectField="NumSucceeded",
81+
preCondDict=reportRequest["condDict"],
82+
metadataDict=None,
83+
)
84+
if not retVal["OK"]:
85+
return retVal
86+
dataDict, granularity = retVal["Value"]
87+
return S_OK({"data": dataDict, "granularity": granularity})
88+
89+
def _plotNumberOfJobs(self, reportRequest, plotInfo, filename):
90+
"""It creates the plot.
91+
92+
:param dict reportRequest: plot attributes
93+
:param dict plotInfo: contains all the data which are used to create the plot
94+
:param str filename:
95+
:return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE
96+
"""
97+
metadata = {
98+
"title": "Jobs by %s" % reportRequest["grouping"],
99+
"starttime": reportRequest["startTime"],
100+
"endtime": reportRequest["endTime"],
101+
"span": plotInfo["granularity"],
102+
"skipEdgeColor": True,
103+
"ylabel": "jobs",
104+
}
105+
106+
plotInfo["data"] = self._fillWithZero(
107+
granularity=plotInfo["granularity"],
108+
startEpoch=reportRequest["startTime"],
109+
endEpoch=reportRequest["endTime"],
110+
dataDict=plotInfo["data"],
111+
)
112+
113+
return self._generateStackedLinePlot(filename=filename, dataDict=plotInfo["data"], metadata=metadata)

0 commit comments

Comments
 (0)