Skip to content

Commit

Permalink
Fix keeping ci artifacts (#1389)
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnov-alexey authored Oct 18, 2023
1 parent 4a34ea1 commit 55d9755
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .ci/validate_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def parse_arguments():
parser.add_argument('--test_list', required=False, nargs='+')
parser.add_argument('--early_stop', action='store_true')
parser.add_argument('--report_dir', default='report')
parser.add_argument('--clean_artifacts', required=False, default=True)
parser.add_argument('--keep_artifacts', action='store_true')
parser.add_argument('--collect_reports', action='store_true')
parser.add_argument("--move_notebooks_dir")
parser.add_argument("--timeout", type=int, default=7200, help="Timeout for running single notebook in seconds")
Expand Down Expand Up @@ -86,7 +86,7 @@ def clean_test_artifacts(before_test_files, after_test_files):
shutil.rmtree(file_path, ignore_errors=True)


def run_test(notebook_path, root, timeout=7200, clean_artifacts=True):
def run_test(notebook_path, root, timeout=7200, keep_artifacts=False):
os.environ["HUGGINGFACE_HUB_CACHE"] = str(notebook_path)
print(f'RUN {notebook_path.relative_to(root)}', flush=True)

Expand All @@ -107,7 +107,7 @@ def run_test(notebook_path, root, timeout=7200, clean_artifacts=True):
except subprocess.TimeoutExpired:
retcode = -42

if clean_artifacts:
if not keep_artifacts:
clean_test_artifacts(existing_files, sorted(Path('.').iterdir()))
return retcode

Expand Down Expand Up @@ -157,11 +157,15 @@ def main():
root = notebooks_moving_dir.parent
move_notebooks(notebooks_moving_dir)

keep_artifacts = False
if args.keep_artifacts:
keep_artifacts = True

test_plan = prepare_test_plan(args.test_list, args.ignore_list, notebooks_moving_dir)
for notebook, report in test_plan.items():
if report['status'] == "SKIPPED":
continue
status = run_test(report['path'], root, args.timeout, args.clean_artifacts)
status = run_test(report['path'], root, args.timeout, keep_artifacts)
if status:
report['status'] = "TIMEOUT" if status == -42 else "FAILED"
else:
Expand Down

0 comments on commit 55d9755

Please sign in to comment.