-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrun_all_notebooks.py
60 lines (51 loc) · 2.09 KB
/
run_all_notebooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import papermill as pm
from pathlib import Path
import os
import click
@click.command()
@click.option(
"--root_dir",
"-d",
default="./",
help="Root directory to run all Jupyter notebooks.",
)
def main(root_dir):
"""Run all Jupyter notebooks in the root directory"""
print("-----------------------------------------------------------------")
print(f"Executing all Jupyter notebooks in root directory: {root_dir}")
print("-----------------------------------------------------------------")
# list of notebook folders to ignore
ignore_folders = [
# ignoring checkpoints, git folders and v1 notebooks
".ipynb_checkpoints",
".git",
"contrib",
# insert notebooks to ignore below
"fasttext_amazon_reviews", # takes very long to run
"multiannotator_cifar10", # requires GPU
"llm_evals_w_crowdlab", # Requires OpenAI key
"outlier_detection_cifar10", # requires GPU
"multilabel_classification", # requires GPU
"entity_recognition", # requires GPU, does not use cleanlab
"cnn_coteaching_cifar10", # no ipynb, only a py file
"active_learning_multiannotator", # requires external utils files that dont work with papermill
"active_learning_single_annotator", # slow repeated training of image classifier
"active_learning_transformers", # slow repeated training of transformer network
"fine_tune_LLM", # requires OpenAI key
]
folders = [
f for f in filter(os.path.isdir, os.listdir("./")) if f not in ignore_folders
]
for folder in folders:
for file in os.listdir(folder):
if file.endswith(".ipynb"):
notebook_path = os.path.join(root_dir, folder, file)
# execute notebook with papermill
print(f"Executing Jupyter notebook: {notebook_path}")
pm.execute_notebook(
input_path=notebook_path,
output_path=notebook_path,
kernel_name="cleanlab-examples",
)
if __name__ == "__main__":
main()