* feat: run-first argument

* feat: run-first code
This commit is contained in:
Andrew Ferlitsch
2023-10-24 13:57:46 +00:00
committed by GitHub
parent e7b8238615
commit a5a003b831
+26 -1
View File
@@ -37,7 +37,7 @@ parser = argparse.ArgumentParser(description="Run changed notebooks.")
parser.add_argument(
"--test_paths_file",
type=pathlib.Path,
help="The path to the file that has newline-limited folders of notebooks that should be tested.",
help="The path to the file that has newline-delimited folders of notebooks that should be tested.",
required=True,
)
parser.add_argument(
@@ -128,6 +128,13 @@ parser.add_argument(
default=10,
required=False,
)
parser.add_argument(
"--run_first_file",
type=pathlib.Path,
help="The path to the file that has newline-delimited of notebooks to run in the first batch",
default=None,
required=False,
)
parser.add_argument(
"--dry_run",
type=str2bool,
@@ -158,6 +165,24 @@ else:
notebooks = [changed_notebook for changed_notebook in changed_notebooks if execute_changed_notebooks_helper.select_notebook(changed_notebook, accumulative_results, args.test_percent)]
run_first = []
if args.run_first_file:
if not os.path.isfile(args.run_first_file):
print("Error: file does not exist", args.run_first_file)
else:
with open(args.run_first_file, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
notebook = row[0]
run_first.append(notebook)
for notebook in run_first:
if notebook in notebooks:
# remove from existing list
notebooks.remove(notebook)
# add back to the front of the list
notebooks.insert(0, notebook)
if args.dry_run:
print("Dry run ...\n")
for notebook in notebooks: