18
18
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
19
20
20
21
+ from datetime import datetime
21
22
from typing import Optional
22
23
23
24
import numpy as np
28
29
from ..config import Report
29
30
from ..resources import templates_env
30
31
from ..utils import filter_metrics
31
- from ..visualization .utils import _prune
32
+ from ..version import version as __version__
33
+ from ..visualization .utils import _prune , get_reproduction_table , get_summary_table
32
34
33
35
34
36
class OverviewSectionGenerator (Module ):
@@ -37,14 +39,17 @@ class OverviewSectionGenerator(Module):
37
39
which later will be used for the report generation.
38
40
"""
39
41
40
- _input_keys = ("read_key" , "dynamic_bounds" , "store_key" )
42
+ _input_keys = ("read_key" , "dynamic_bounds" , "store_key" , "start_time" , "end_time" )
41
43
_output_keys = ("store_key" ,)
42
44
43
45
def __init__ (
44
46
self ,
45
47
read_key ,
46
48
store_key ,
47
49
settings : Report ,
50
+ reference_type ,
51
+ time_axis ,
52
+ bin_specs ,
48
53
features = None ,
49
54
ignore_features = None ,
50
55
static_bounds = None ,
@@ -68,6 +73,8 @@ def __init__(
68
73
super ().__init__ ()
69
74
self .read_key = read_key
70
75
self .store_key = store_key
76
+ self .start_time = "start_time"
77
+ self .end_time = "end_time"
71
78
self .dynamic_bounds = dynamic_bounds
72
79
self .static_bounds = static_bounds
73
80
@@ -76,6 +83,9 @@ def __init__(
76
83
self .prefix = prefix
77
84
self .suffices = suffices
78
85
self .ignore_stat_endswith = ignore_stat_endswith or []
86
+ self .reference_type = reference_type
87
+ self .time_axis = time_axis
88
+ self .bin_specs = bin_specs
79
89
80
90
self .last_n = settings .last_n
81
91
self .skip_first_n = settings .skip_first_n
@@ -92,6 +102,8 @@ def transform(
92
102
data_obj : dict ,
93
103
dynamic_bounds : Optional [dict ] = None ,
94
104
sections : Optional [list ] = None ,
105
+ start_time : Optional [datetime ] = None ,
106
+ end_time : Optional [datetime ] = None ,
95
107
):
96
108
assert isinstance (data_obj , dict )
97
109
if dynamic_bounds is None :
@@ -104,12 +116,17 @@ def transform(
104
116
features = self .get_features (list (data_obj .keys ()))
105
117
106
118
self .logger .info (f'Generating section "{ self .section_name } "' )
107
-
119
+ time_windows = 0
108
120
values = {}
121
+ offset = ""
122
+ max_timestamp = ""
109
123
for feature in tqdm (features , ncols = 100 ):
110
124
df = data_obj .get (feature , pd .DataFrame ())
111
- fdbounds = dynamic_bounds .get (feature , pd .DataFrame (index = df .index ))
125
+ time_windows = len (df .index )
126
+ offset = df .index .min ()
127
+ max_timestamp = df .index .max ()
112
128
129
+ fdbounds = dynamic_bounds .get (feature , pd .DataFrame (index = df .index ))
113
130
assert all (df .index == fdbounds .index )
114
131
115
132
# prepare date labels
@@ -131,11 +148,43 @@ def transform(
131
148
self .skip_last_n ,
132
149
)
133
150
151
+ # Dataset summary table and Analysis Details table
152
+ tables = []
153
+ bin_width = (
154
+ self .bin_specs [self .time_axis ]["bin_width" ]
155
+ if self .time_axis in self .bin_specs .keys ()
156
+ else 0
157
+ )
158
+
159
+ if (
160
+ self .time_axis in self .bin_specs .keys ()
161
+ and self .bin_specs [self .time_axis ]["bin_offset" ] > 0
162
+ ):
163
+ offset = datetime .utcfromtimestamp (
164
+ self .bin_specs [self .time_axis ]["bin_offset" ] // 1e9
165
+ )
166
+ tables .append (
167
+ get_summary_table (
168
+ len (features ),
169
+ time_windows ,
170
+ self .time_axis ,
171
+ self .reference_type ,
172
+ bin_width ,
173
+ offset ,
174
+ max_timestamp ,
175
+ )
176
+ )
177
+
178
+ tables .append (get_reproduction_table (start_time , end_time , __version__ ))
179
+
180
+ # overview plots
134
181
plots = [_plot_metrics (values )]
135
182
# filter out potential empty plots (from skip empty plots)
136
183
plots = [e for e in plots if len (e ["plot" ])]
137
184
plots = sorted (plots , key = lambda plot : plot ["name" ])
138
185
186
+ plots = tables + plots
187
+
139
188
sections .append (
140
189
{
141
190
"section_title" : self .section_name ,
@@ -169,10 +218,11 @@ def _plot_metrics(
169
218
)
170
219
171
220
return {
172
- "name" : "Alert frequency per Feature " ,
221
+ "name" : "Alerts " ,
173
222
"type" : "alert" ,
174
223
"description" : "" ,
175
224
"plot" : plot ,
225
+ "layout" : "" ,
176
226
"full_width" : True ,
177
227
}
178
228
0 commit comments