Skip to content

Commit 465878e

Browse files
Rabah Abdul KhalekRabah Abdul Khalek
authored andcommitted
Added to_html method
1 parent 9ceecc9 commit 465878e

File tree

1 file changed

+18
-1
lines changed
  • giskard_vision/landmark_detection/tests

1 file changed

+18
-1
lines changed

‎giskard_vision/landmark_detection/tests/report.py‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def to_dataframe(self, summary: Optional[bool] = False):
123123

124124
return df.sort_values(["criteria", "model"], ignore_index=True).drop(["group"], axis=1, errors="ignore")
125125

126-
def to_markdown(self, summary: Optional[bool] = False, filename: Optional[str] = None):
126+
def to_markdown(self, filename: Optional[str] = None, summary: Optional[bool] = False):
127127
"""
128128
Writes the test results to a markdown file.
129129
@@ -167,6 +167,23 @@ def to_json(self, filename: Optional[str] = None):
167167
for result in self.results:
168168
jsonl_file.write(json.dumps(result) + "\n")
169169

170+
def to_html(self, filename: Optional[str] = None, summary: Optional[bool] = False):
171+
"""
172+
Writes the test results to an html file.
173+
174+
Args:
175+
filename (Optional[str]): Name of the html file (default is generated with a unique identifier).
176+
177+
"""
178+
from datetime import datetime
179+
180+
current_time = str(datetime.now()).replace(" ", "-")
181+
filename = f"report_{'summary' if summary else 'full'}_{current_time}.html"
182+
183+
df = self.to_dataframe(summary=summary)
184+
185+
df.to_html(filename)
186+
170187
def adjust_thresholds(self, thresholds: Union[List[float], Dict[int, float]]):
171188
"""
172189
Adjusts the thresholds for the tests.

0 commit comments

Comments
 (0)