Skip to content

Commit 9e044e3

Browse files
committed
anomaly report generation
1 parent 0dcf1b8 commit 9e044e3

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

ads/opctl/operator/lowcode/anomaly/model/base_model.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ def generate_report(self):
8282
rc.DataTable(df, label=col, index=True)
8383
for col, df in self.datasets.full_data_dict.items()
8484
]
85-
data_table = (
86-
rc.Select(blocks=table_blocks) if len(table_blocks) > 1 else table_blocks[0]
87-
)
85+
data_table = rc.Select(blocks=table_blocks)
8886
date_column = self.spec.datetime_column.name
8987

9088
blocks = []
@@ -106,9 +104,9 @@ def generate_report(self):
106104
plt.xlabel(date_column)
107105
plt.ylabel(col)
108106
plt.title(f"`{col}` with reference to anomalies")
109-
figure_blocks.append(ax)
110-
blocks.append(rc.Group(figure_blocks, label=target))
111-
plots = rc.Select(blocks=blocks) if len(blocks) > 1 else blocks[0]
107+
figure_blocks.append(rc.Widget(ax))
108+
blocks.append(rc.Group(*figure_blocks, label=target))
109+
plots = rc.Select(blocks)
112110

113111
report_sections = []
114112
title_text = rc.Heading("Anomaly Detection Report", level=1)
@@ -122,7 +120,7 @@ def generate_report(self):
122120
"Based on your dataset, you could have also selected "
123121
f"any of the models: `{'`, `'.join(SupportedModels.keys())}`."
124122
),
125-
rc.BigNumber(
123+
rc.Metric(
126124
heading="Analysis was completed in ",
127125
value=human_time_friendly(elapsed_time),
128126
),
@@ -259,7 +257,8 @@ def _save_report(
259257
with tempfile.TemporaryDirectory() as temp_dir:
260258
report_local_path = os.path.join(temp_dir, "___report.html")
261259
disable_print()
262-
rc.save_report(report_sections, report_local_path)
260+
with rc.ReportCreator("My Report") as report:
261+
report.save(rc.Block(*report_sections), report_local_path)
263262
enable_print()
264263
with open(report_local_path) as f1:
265264
with fsspec.open(

ads/opctl/operator/lowcode/forecast/model/base_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ def _save_report(
421421
if self.spec.generate_report:
422422
with tempfile.TemporaryDirectory() as temp_dir:
423423
report_local_path = os.path.join(temp_dir, "___report.html")
424-
# disable_print()
424+
disable_print()
425425
with rc.ReportCreator("My Report") as report:
426426
report.save(rc.Block(*report_sections), report_local_path)
427-
# enable_print()
427+
enable_print()
428428

429429
report_path = os.path.join(unique_output_dir, self.spec.report_filename)
430430
with open(report_local_path) as f1:

ads/opctl/operator/lowcode/pii/model/report.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def build_report(self) -> rc.Group:
238238
def _make_stats_card(self):
239239
stats = [
240240
rc.Heading("Row Summary Statistics", level=2),
241-
rc.BigNumber(
241+
rc.Metric(
242242
heading="Total No. Of Entites Proceed",
243243
value=self.spec.total_tokens or 0,
244244
),
@@ -297,7 +297,7 @@ def make_view(self):
297297
title_text = rc.Heading(
298298
"Personally Identifiable Information Operator Report", level=1
299299
)
300-
time_proceed = rc.BigNumber(
300+
time_proceed = rc.Metric(
301301
heading="Ran at",
302302
value=self.report_spec.run_summary.timestamp or "today",
303303
)
@@ -325,11 +325,10 @@ def save_report(self, report_sections=None, report_uri=None, storage_options={})
325325
with tempfile.TemporaryDirectory() as temp_dir:
326326
report_local_path = os.path.join(temp_dir, "___report.html")
327327
disable_print()
328-
rc.save_report(
329-
report_sections or self.report_sections,
330-
path=report_local_path,
331-
open=False,
332-
)
328+
with rc.ReportCreator("My Report") as report:
329+
report.save(
330+
rc.Block(report_sections or self.report_sections), report_local_path
331+
)
333332
enable_print()
334333

335334
report_uri = report_uri or self.report_uri
@@ -393,19 +392,19 @@ def _make_summary_stats_card(self) -> rc.Group:
393392
summary_stats = [
394393
rc.Heading("Summary Statistics", level=2),
395394
rc.Group(
396-
rc.BigNumber(
395+
rc.Metric(
397396
heading="Total No. Of Rows",
398397
value=self.report_spec.run_summary.total_rows or "unknown",
399398
),
400-
rc.BigNumber(
399+
rc.Metric(
401400
heading="Total No. Of Entites Proceed",
402401
value=self.report_spec.run_summary.total_tokens,
403402
),
404-
rc.BigNumber(
403+
rc.Metric(
405404
heading="Rows per second processed",
406405
value=process_rate,
407406
),
408-
rc.BigNumber(
407+
rc.Metric(
409408
heading="Total Time Spent",
410409
value=human_time_friendly(
411410
self.report_spec.run_summary.elapsed_time

0 commit comments

Comments
 (0)