Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add score to report #998

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions bin/sequencer_report
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ STAGES = ["stable", "beta", "preview", "alpha"]
# stages to consider for a pass

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


@dataclass(unsafe_hash=True, eq=True, order=True)
def sanitize(string: str):
"""Sanitize string for safe displaying"""
sanitized = string.replace("\n", ";")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually I'd be replacing with a "; " (space after semicolon... not sure that works here, tho)

return sanitized


@dataclass(kw_only=True,unsafe_hash=True, eq=True, order=True)
class TestResult:
"""Container for test result."""

Expand All @@ -51,7 +56,8 @@ class TestResult:
result: str = ""
stage: str = ""
message: str = ""
score: int = DEFAULT_SCORE
score: int = 0
total: int = 0

def passed(self):
if self.result == "pass":
Expand Down Expand Up @@ -394,6 +400,10 @@ class SequencerReport:
self.site_path, "cloud_iot_config.json"
)

self.gateway = (
self.metadata.get("gateway", {}).get("gateway_id")
)

def has_stage(self, stage: str):
"""Checks if sequencer report has any tests at given stage."""
all_features = [x[stage] for x in self.features.values()]
Expand All @@ -408,14 +418,16 @@ class SequencerReport:
features[feature] = copy.deepcopy(stages_template)
for name, result in sequences["sequences"].items():
results[name] = TestResult(
feature,
name,
result.get("summary", ""),
result["result"],
result["stage"],
self.sanitize(result["status"]["message"]),
bucket=feature,
name=name,
description=result.get("summary", ""),
result=result["result"],
stage=result["stage"],
message=sanitize(result["status"]["message"]),
score=result["scoring"]["value"],
total=result["scoring"]["total"],
)
features[feature][result["stage"]].add(result["result"], DEFAULT_SCORE)
features[feature][result["stage"]].add(result["result"], result["scoring"]["value"])
features[feature][result["stage"]].tests.append(result)

self.results = {
Expand Down Expand Up @@ -444,11 +456,6 @@ class SequencerReport:
for f in self.features
}

def sanitize(self, string: str):
"""Sanitize string for safe displaying"""
sanitized = string.replace("\n", ";")
return sanitized

def __repr__(self):
return str(self.results)

Expand Down
8 changes: 4 additions & 4 deletions etc/sequencer_report.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

| Device | {{report.device_id}} |
|---|---|
| Site | |
| Make | {{report.device_make}} |
| Model | {{report.device_model}} |
| Software | {{report.device_software|pretty_dict}} |
{% if report.gateway is not none %}| Gateway | {{report.gateway}} |{%- endif %}

## Summary

Expand All @@ -23,10 +23,10 @@

## Results

| Bucket | Feature | Stage | Result | Description |
| --- | --- | --- | --- | --- |
| Bucket | Feature | Stage | Score | Result | Description |
| --- | --- | --- | --- | --- | --- |
{% for test in report.results.values() -%}
| {{test.bucket}} | {{test.name}} | {{test.stage}} | {{test.result}} | {{test.message}} |
| {{test.bucket}} | {{test.name}} | {{test.stage}} | {{test.score}} | {{test.result}} | {{test.message}} |
{% endfor %}

## Schema
Expand Down
Loading