Skip to content

Commit ad2b7fe

Browse files
authored
add score to sequencer report (#998)
1 parent ed13b20 commit ad2b7fe

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

bin/sequencer_report

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ STAGES = ["stable", "beta", "preview", "alpha"]
2323
# stages to consider for a pass
2424

2525
STAGES_FOR_PASS = ["stable", "beta"]
26-
DEFAULT_SCORE = 1
2726
REFERENCE_SEQUENCES_DIR = "validator/sequences"
2827
CHECKMARK = "✓"
2928
CROSS = "✕"
@@ -41,7 +40,13 @@ def first_occurence(iteratable: Iterable, predicate: Callable) -> int:
4140
raise ValueError()
4241

4342

44-
@dataclass(unsafe_hash=True, eq=True, order=True)
43+
def sanitize(string: str):
44+
"""Sanitize string for safe displaying"""
45+
sanitized = string.replace("\n", "; ")
46+
return sanitized
47+
48+
49+
@dataclass(kw_only=True,unsafe_hash=True, eq=True, order=True)
4550
class TestResult:
4651
"""Container for test result."""
4752

@@ -51,7 +56,8 @@ class TestResult:
5156
result: str = ""
5257
stage: str = ""
5358
message: str = ""
54-
score: int = DEFAULT_SCORE
59+
score: int = 0
60+
total: int = 0
5561

5662
def passed(self):
5763
if self.result == "pass":
@@ -272,17 +278,23 @@ class TemplateHelper:
272278

273279
@dataclass
274280
class FeatureStage:
275-
"""Container for scored points and total points for a feature and stage."""
281+
"""Container for scored points and total points for a feature and stage.
282+
283+
Arguments:
284+
scored: Number of points scored for a given feature at a given stage.
285+
total: Total points which could possibly have attained.
286+
stage: The stage e.g. BETA, STABLE, etc.
287+
tests: List of tests for this feature at the given stage.
288+
"""
276289

277290
scored: int = 0
278291
total: int = 0
279292
stage: str = ""
280293
tests: list = field(default_factory=list)
281294

282-
def add(self, result, score):
283-
self.total += score
284-
if result == "pass":
285-
self.scored += score
295+
def add(self, *, test_score:int, test_total:int):
296+
self.total += test_total
297+
self.scored += test_score
286298

287299
def has(self):
288300
"""Did the sequencer results have this feature & stage combination?."""
@@ -394,6 +406,10 @@ class SequencerReport:
394406
self.site_path, "cloud_iot_config.json"
395407
)
396408

409+
self.gateway = (
410+
self.metadata.get("gateway", {}).get("gateway_id")
411+
)
412+
397413
def has_stage(self, stage: str):
398414
"""Checks if sequencer report has any tests at given stage."""
399415
all_features = [x[stage] for x in self.features.values()]
@@ -408,14 +424,17 @@ class SequencerReport:
408424
features[feature] = copy.deepcopy(stages_template)
409425
for name, result in sequences["sequences"].items():
410426
results[name] = TestResult(
411-
feature,
412-
name,
413-
result.get("summary", ""),
414-
result["result"],
415-
result["stage"],
416-
self.sanitize(result["status"]["message"]),
427+
bucket=feature,
428+
name=name,
429+
description=result.get("summary", ""),
430+
result=result["result"],
431+
stage=result["stage"],
432+
message=sanitize(result["status"]["message"]),
433+
score=result["scoring"]["value"],
434+
total=result["scoring"]["total"],
417435
)
418-
features[feature][result["stage"]].add(result["result"], DEFAULT_SCORE)
436+
437+
features[feature][result["stage"]].add(test_score=result["scoring"]["value"], test_total=result["scoring"]["total"])
419438
features[feature][result["stage"]].tests.append(result)
420439

421440
self.results = {
@@ -444,11 +463,6 @@ class SequencerReport:
444463
for f in self.features
445464
}
446465

447-
def sanitize(self, string: str):
448-
"""Sanitize string for safe displaying"""
449-
sanitized = string.replace("\n", ";")
450-
return sanitized
451-
452466
def __repr__(self):
453467
return str(self.results)
454468

etc/sequencer_report.md.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
| Device | {{report.device_id}} |
1010
|---|---|
11-
| Site | |
1211
| Make | {{report.device_make}} |
1312
| Model | {{report.device_model}} |
1413
| Software | {{report.device_software|pretty_dict}} |
14+
{% if report.gateway is not none %}| Gateway | {{report.gateway}} |{%- endif %}
1515

1616
## Summary
1717

@@ -23,10 +23,10 @@
2323

2424
## Results
2525

26-
| Bucket | Feature | Stage | Result | Description |
27-
| --- | --- | --- | --- | --- |
26+
| Bucket | Feature | Stage | Score | Result | Description |
27+
| --- | --- | --- | --- | --- | --- |
2828
{% for test in report.results.values() -%}
29-
| {{test.bucket}} | {{test.name}} | {{test.stage}} | {{test.result}} | {{test.message}} |
29+
| {{test.bucket}} | {{test.name}} | {{test.stage}} | {{test.score}} | {{test.result}} | {{test.message}} |
3030
{% endfor %}
3131

3232
## Schema

0 commit comments

Comments
 (0)