1
1
"""
2
- This class is used to define the plot using the plot attributes.
2
+ this class is used to define the plot using the plot attributes.
3
3
"""
4
4
5
5
from DIRAC import S_OK
@@ -19,6 +19,7 @@ class DataOperationPlotter(BasePlotter):
19
19
"""
20
20
21
21
_typeName = "DataOperation"
22
+
22
23
_typeKeyFields = DataOperation ().keyFields
23
24
24
25
_reportSuceededTransfersName = "Successful transfers"
@@ -32,6 +33,11 @@ def _reportFailedTransfers(self, reportRequest):
32
33
return self .__reportTransfers (reportRequest , "Failed" , ("Succeeded" , 1 ))
33
34
34
35
def __reportTransfers (self , reportRequest , titleType , togetherFieldsToPlot ):
36
+ """It is used to retrieve the data from the database.
37
+
38
+ :param dict reportRequest: contains attributes used to create the plot.
39
+ :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length
40
+ """
35
41
retVal = self ._getTimedData (
36
42
reportRequest ["startTime" ],
37
43
reportRequest ["endTime" ],
@@ -68,38 +74,51 @@ def __plotTransfers(self, reportRequest, plotInfo, filename, titleType, together
68
74
}
69
75
return self ._generateTimedStackedBarPlot (filename , plotInfo ["graphDataDict" ], metadata )
70
76
71
- _reportQualityName = "Efficiency by protocol "
77
+ _reportQualityName = "Transfer Efficiency "
72
78
73
79
def _reportQuality (self , reportRequest ):
74
- selectFields = ["TransferOK" , "TransferTotal" ]
80
+ """It is used to retrieve the data from the database.
81
+
82
+ :param dict reportRequest: contains attributes used to create the plot.
83
+ :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length
84
+ """
85
+ # Retrieve the number of succeded transfers
75
86
retVal = self ._getTimedData (
76
87
reportRequest ["startTime" ],
77
88
reportRequest ["endTime" ],
78
- selectFields ,
89
+ "TransferOK" ,
90
+ preCondDict = reportRequest ["condDict" ],
91
+ metadataDict = None ,
92
+ )
93
+ # Retrieve the number of total transfers
94
+ retTotVal = self ._getTimedData (
95
+ reportRequest ["startTime" ],
96
+ reportRequest ["endTime" ],
97
+ "TransferTotal" ,
79
98
preCondDict = reportRequest ["condDict" ],
80
99
metadataDict = None ,
81
100
)
82
101
if not retVal ["OK" ]:
83
102
return retVal
103
+ if not retTotVal ["OK" ]:
104
+ return retTotVal
84
105
dataDict , granularity = retVal ["Value" ]
85
- if len (dataDict ) > 1 :
86
- # Get the total for the plot
87
- selectFields = ["TransferOK" , "TransferTotal" ]
88
- retVal = self ._getTimedData (
89
- reportRequest ["startTime" ],
90
- reportRequest ["endTime" ],
91
- selectFields ,
92
- preCondDict = reportRequest ["condDict" ],
93
- metadataDict = None ,
94
- )
95
- if not retVal ["OK" ]:
96
- return retVal
97
- totalDict = retVal ["Value" ][0 ]
98
- for key in totalDict :
99
- dataDict [key ] = totalDict [key ]
100
- return S_OK ({"data" : dataDict , "granularity" : granularity })
106
+ totDataDict , granularity = retTotVal ["Value" ]
107
+ # Check that the dicts are not empty
108
+ if bool (dataDict ) and bool (totDataDict ):
109
+ # Return the efficiency in dataDict
110
+ effDict = self ._calculateEfficiencyDict (totDataDict , dataDict )
111
+ return S_OK ({"data" : effDict , "granularity" : granularity })
101
112
102
113
def _plotQuality (self , reportRequest , plotInfo , filename ):
114
+ """
115
+ Make 2 dimensional pilotSubmission efficiency plot
116
+
117
+ :param dict reportRequest: Condition to select data
118
+ :param dict plotInfo: Data for plot.
119
+ :param str filename: File name
120
+ """
121
+
103
122
metadata = {
104
123
"title" : "Transfer quality by %s" % reportRequest ["grouping" ],
105
124
"starttime" : reportRequest ["startTime" ],
@@ -111,6 +130,11 @@ def _plotQuality(self, reportRequest, plotInfo, filename):
111
130
_reportTransferedDataName = "Cumulative transferred data"
112
131
113
132
def _reportTransferedData (self , reportRequest ):
133
+ """It is used to retrieve the data from the database.
134
+
135
+ :param dict reportRequest: contains attributes used to create the plot.
136
+ :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length
137
+ """
114
138
retVal = self ._getTimedData (
115
139
reportRequest ["startTime" ],
116
140
reportRequest ["endTime" ],
@@ -131,6 +155,13 @@ def _reportTransferedData(self, reportRequest):
131
155
)
132
156
133
157
def _plotTransferedData (self , reportRequest , plotInfo , filename ):
158
+ """It creates the plot.
159
+
160
+ :param dict reportRequest: plot attributes
161
+ :param dict plotInfo: contains all the data which are used to create the plot
162
+ :param str filename:
163
+ :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE
164
+ """
134
165
metadata = {
135
166
"title" : "Transfered data by %s" % reportRequest ["grouping" ],
136
167
"starttime" : reportRequest ["startTime" ],
@@ -142,6 +173,11 @@ def _plotTransferedData(self, reportRequest, plotInfo, filename):
142
173
return self ._generateCumulativePlot (filename , plotInfo ["graphDataDict" ], metadata )
143
174
144
175
def _reportThroughput (self , reportRequest ):
176
+ """It is used to retrieve the data from the database.
177
+
178
+ :param dict reportRequest: contains attributes used to create the plot.
179
+ :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length
180
+ """
145
181
retVal = self ._getTimedData (
146
182
reportRequest ["startTime" ],
147
183
reportRequest ["endTime" ],
@@ -162,6 +198,13 @@ def _reportThroughput(self, reportRequest):
162
198
)
163
199
164
200
def _plotThroughput (self , reportRequest , plotInfo , filename ):
201
+ """It creates the plot.
202
+
203
+ :param dict reportRequest: plot attributes
204
+ :param dict plotInfo: contains all the data which are used to create the plot
205
+ :param str filename:
206
+ :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE
207
+ """
165
208
metadata = {
166
209
"title" : "Throughput by %s" % reportRequest ["grouping" ],
167
210
"ylabel" : plotInfo ["unit" ],
@@ -174,21 +217,34 @@ def _plotThroughput(self, reportRequest, plotInfo, filename):
174
217
_reportDataTransferedName = "Pie chart of transferred data"
175
218
176
219
def _reportDataTransfered (self , reportRequest ):
177
- retVal = self ._getSummaryData (
220
+ """It is used to retrieve the data from the database.
221
+
222
+ :param dict reportRequest: contains attributes used to create the plot.
223
+ :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length
224
+ """
225
+ retVal = self ._getTimedData (
178
226
reportRequest ["startTime" ],
179
227
reportRequest ["endTime" ],
180
- "Transfersize " ,
228
+ "TransferSize " ,
181
229
preCondDict = reportRequest ["condDict" ],
182
230
metadataDict = None ,
183
231
)
184
232
if not retVal ["OK" ]:
185
233
return retVal
186
- dataDict = retVal ["Value" ]
234
+ dataDict , granularity = retVal ["Value" ]
235
+ dataDict = self ._sumDictValues (dataDict )
187
236
for key in dataDict :
188
237
dataDict [key ] = int (dataDict [key ])
189
238
return S_OK ({"data" : dataDict })
190
239
191
240
def _plotDataTransfered (self , reportRequest , plotInfo , filename ):
241
+ """It creates the plot.
242
+
243
+ :param dict reportRequest: plot attributes
244
+ :param dict plotInfo: contains all the data which are used to create the plot
245
+ :param str filename:
246
+ :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE
247
+ """
192
248
metadata = {
193
249
"title" : "Total data transfered by %s" % reportRequest ["grouping" ],
194
250
"ylabel" : "bytes" ,
0 commit comments