Skip to content

Commit 133b25d

Browse files
authored
improve logging and continue work if timeout (openvinotoolkit#1276)
1 parent fc45824 commit 133b25d

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

.ci/validate_notebooks.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,22 @@ def run_test(notebook_path, root, timeout=7200):
100100
return 0
101101

102102
main_command = [sys.executable, '-m', 'treon', notebook_name]
103-
retcode = subprocess.run(main_command, shell=(platform.system() == "Windows"), timeout=timeout).returncode
103+
try:
104+
retcode = subprocess.run(main_command, shell=(platform.system() == "Windows"), timeout=timeout).returncode
105+
except subprocess.TimeoutExpired:
106+
retcode = -42
104107

105108
clean_test_artifacts(existing_files, sorted(Path('.').iterdir()))
106109
return retcode
107110

108111

109-
def finalize_status(failed_notebooks, test_plan, report_dir, root):
112+
def finalize_status(failed_notebooks, timeout_notebooks, test_plan, report_dir, root):
110113
return_status = 0
111114
if failed_notebooks:
112115
return_status = 1
113116
print("FAILED: \n{}".format('\n'.join(failed_notebooks)))
117+
if timeout_notebooks:
118+
print("FAILED BY TIMEOUT: \n{}".format('\n'.join(timeout_notebooks)))
114119
test_report = []
115120
for notebook, status in test_plan.items():
116121
test_status = status['status'] or 'NOT_RUN'
@@ -138,6 +143,7 @@ def __exit__(self, etype, value, traceback):
138143

139144
def main():
140145
failed_notebooks = []
146+
timeout_notebooks = []
141147
args = parse_arguments()
142148
reports_dir = Path(args.report_dir)
143149
reports_dir.mkdir(exist_ok=True, parents=True)
@@ -153,12 +159,18 @@ def main():
153159
if report['status'] == "SKIPPED":
154160
continue
155161
status = run_test(report['path'], root, args.timeout)
156-
report['status'] = 'SUCCESS' if not status else "FAILED"
157162
if status:
158-
failed_notebooks.append(str(notebook))
163+
report['status'] = "TIMEOUT" if status == -42 else "FAILED"
164+
else:
165+
report["status"] = 'SUCCESS'
166+
if status:
167+
if status == -42:
168+
timeout_notebooks.append(str(notebook))
169+
else:
170+
failed_notebooks.append(str(notebook))
159171
if args.early_stop:
160172
break
161-
exit_status = finalize_status(failed_notebooks, test_plan, reports_dir, root)
173+
exit_status = finalize_status(failed_notebooks, timeout_notebooks, test_plan, reports_dir, root)
162174
return exit_status
163175

164176

0 commit comments

Comments
 (0)