Skip to content

Commit d64baa9

Browse files
authored
Handle "N/A" warning count data when generating summary report (#8)
When it is not possible to compile the sketch at the deltas base ref, the warning count delta is recorded as "N/A". Previously, the summary report generation code did not handle this case correctly, which resulted in failing with an error: TypeError: '>' not supported between instances of 'int' and 'str'
1 parent 76ebce6 commit d64baa9

File tree

2 files changed

+131
-2
lines changed

2 files changed

+131
-2
lines changed

compilesketches/compilesketches.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1356,14 +1356,22 @@ def get_warnings_summary_report(self, sketch_report_list):
13561356
if (
13571357
summary_report_minimum is None
13581358
or summary_report_minimum == self.not_applicable_indicator
1359-
or summary_report_minimum > sketch_report_delta
1359+
):
1360+
summary_report_minimum = sketch_report_delta
1361+
elif (
1362+
sketch_report_delta != self.not_applicable_indicator
1363+
and summary_report_minimum > sketch_report_delta
13601364
):
13611365
summary_report_minimum = sketch_report_delta
13621366

13631367
if (
13641368
summary_report_maximum is None
13651369
or summary_report_maximum == self.not_applicable_indicator
1366-
or summary_report_maximum < sketch_report_delta
1370+
):
1371+
summary_report_maximum = sketch_report_delta
1372+
elif (
1373+
sketch_report_delta != self.not_applicable_indicator
1374+
and summary_report_maximum < sketch_report_delta
13671375
):
13681376
summary_report_maximum = sketch_report_delta
13691377

compilesketches/tests/test_compilesketches.py

+121
Original file line numberDiff line numberDiff line change
@@ -2386,6 +2386,127 @@ def test_get_warnings_summary_report():
23862386
expected_warnings_summary_report
23872387
)
23882388

2389+
sketch_report_list = [
2390+
{
2391+
compilesketches.CompileSketches.ReportKeys.warnings: {
2392+
compilesketches.CompileSketches.ReportKeys.delta: {
2393+
compilesketches.CompileSketches.ReportKeys.absolute: 3
2394+
}
2395+
},
2396+
},
2397+
{
2398+
compilesketches.CompileSketches.ReportKeys.warnings: {
2399+
compilesketches.CompileSketches.ReportKeys.delta: {
2400+
compilesketches.CompileSketches.ReportKeys.absolute: 42
2401+
}
2402+
}
2403+
}
2404+
]
2405+
2406+
expected_warnings_summary_report = {
2407+
compilesketches.CompileSketches.ReportKeys.delta: {
2408+
compilesketches.CompileSketches.ReportKeys.absolute: {
2409+
compilesketches.CompileSketches.ReportKeys.minimum: 3,
2410+
compilesketches.CompileSketches.ReportKeys.maximum: 42
2411+
}
2412+
}
2413+
}
2414+
2415+
assert compile_sketches.get_warnings_summary_report(sketch_report_list=sketch_report_list) == (
2416+
expected_warnings_summary_report
2417+
)
2418+
2419+
# N/As
2420+
sketch_report_list = [
2421+
{
2422+
compilesketches.CompileSketches.ReportKeys.warnings: {
2423+
compilesketches.CompileSketches.ReportKeys.delta: {
2424+
compilesketches.CompileSketches.ReportKeys.absolute: compile_sketches.not_applicable_indicator
2425+
}
2426+
},
2427+
},
2428+
{
2429+
compilesketches.CompileSketches.ReportKeys.warnings: {
2430+
compilesketches.CompileSketches.ReportKeys.delta: {
2431+
compilesketches.CompileSketches.ReportKeys.absolute: 3
2432+
}
2433+
}
2434+
}
2435+
]
2436+
2437+
expected_warnings_summary_report = {
2438+
compilesketches.CompileSketches.ReportKeys.delta: {
2439+
compilesketches.CompileSketches.ReportKeys.absolute: {
2440+
compilesketches.CompileSketches.ReportKeys.minimum: 3,
2441+
compilesketches.CompileSketches.ReportKeys.maximum: 3
2442+
}
2443+
}
2444+
}
2445+
2446+
assert compile_sketches.get_warnings_summary_report(sketch_report_list=sketch_report_list) == (
2447+
expected_warnings_summary_report
2448+
)
2449+
2450+
sketch_report_list = [
2451+
{
2452+
compilesketches.CompileSketches.ReportKeys.warnings: {
2453+
compilesketches.CompileSketches.ReportKeys.delta: {
2454+
compilesketches.CompileSketches.ReportKeys.absolute: 42
2455+
}
2456+
},
2457+
},
2458+
{
2459+
compilesketches.CompileSketches.ReportKeys.warnings: {
2460+
compilesketches.CompileSketches.ReportKeys.delta: {
2461+
compilesketches.CompileSketches.ReportKeys.absolute: compile_sketches.not_applicable_indicator
2462+
}
2463+
}
2464+
}
2465+
]
2466+
2467+
expected_warnings_summary_report = {
2468+
compilesketches.CompileSketches.ReportKeys.delta: {
2469+
compilesketches.CompileSketches.ReportKeys.absolute: {
2470+
compilesketches.CompileSketches.ReportKeys.minimum: 42,
2471+
compilesketches.CompileSketches.ReportKeys.maximum: 42
2472+
}
2473+
}
2474+
}
2475+
2476+
assert compile_sketches.get_warnings_summary_report(sketch_report_list=sketch_report_list) == (
2477+
expected_warnings_summary_report
2478+
)
2479+
2480+
sketch_report_list = [
2481+
{
2482+
compilesketches.CompileSketches.ReportKeys.warnings: {
2483+
compilesketches.CompileSketches.ReportKeys.delta: {
2484+
compilesketches.CompileSketches.ReportKeys.absolute: compile_sketches.not_applicable_indicator
2485+
}
2486+
},
2487+
},
2488+
{
2489+
compilesketches.CompileSketches.ReportKeys.warnings: {
2490+
compilesketches.CompileSketches.ReportKeys.delta: {
2491+
compilesketches.CompileSketches.ReportKeys.absolute: compile_sketches.not_applicable_indicator
2492+
}
2493+
}
2494+
}
2495+
]
2496+
2497+
expected_warnings_summary_report = {
2498+
compilesketches.CompileSketches.ReportKeys.delta: {
2499+
compilesketches.CompileSketches.ReportKeys.absolute: {
2500+
compilesketches.CompileSketches.ReportKeys.minimum: compile_sketches.not_applicable_indicator,
2501+
compilesketches.CompileSketches.ReportKeys.maximum: compile_sketches.not_applicable_indicator
2502+
}
2503+
}
2504+
}
2505+
2506+
assert compile_sketches.get_warnings_summary_report(sketch_report_list=sketch_report_list) == (
2507+
expected_warnings_summary_report
2508+
)
2509+
23892510
# Test with deltas disabled
23902511
sketch_report_list = [
23912512
{

0 commit comments

Comments
 (0)