Skip to content

Commit

Permalink
add saving report for each notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Apr 26, 2024
1 parent a4c7cb5 commit acfb357
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .ci/validate_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import subprocess # nosec - disable B404:import-subprocess check
import csv
import json
import shutil
import platform
from pathlib import Path
Expand Down Expand Up @@ -206,6 +207,13 @@ def __exit__(self, etype, value, traceback):
os.chdir(self.saved_path)


def write_single_notebook_report(notebook_name, status, saving_dir):
report_file = saving_dir / notebook_name.replace(".ipynb", ".json")
report = {"notebook_name": notebook_name.replace("test_", ""), "status": status}
with report_file.open("w") as f:
json.dump(report, f)


def main():
failed_notebooks = []
timeout_notebooks = []
Expand All @@ -232,15 +240,20 @@ def main():
print(f"{str(notebook)}: No testing notebooks found")
report["status"] = "EMPTY"
for subnotebook, status in statuses:

if status:
report["status"] = "TIMEOUT" if status == -42 else "FAILED"
status_code = "TIMEOUT" if status == -42 else "FAILED"
report["status"] = status_code
else:
status_code = "SUCCESS"
report["status"] = "SUCCESS" if not report["status"] in ["TIMEOUT", "FAILED"] else report["status"]
if status:
if status == -42:
timeout_notebooks.append(str(subnotebook))
else:
failed_notebooks.append(str(subnotebook))
if args.collect_reports:
write_single_notebook_report(subnotebook, status, reports_dir)
if args.early_stop:
break
exit_status = finalize_status(failed_notebooks, timeout_notebooks, test_plan, reports_dir, root)
Expand Down

0 comments on commit acfb357

Please sign in to comment.