forked from Labelbox/labelbox-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_notebooks.py
More file actions
74 lines (59 loc) · 2.22 KB
/
test_notebooks.py
File metadata and controls
74 lines (59 loc) · 2.22 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
Runs example notebooks to ensure that they are not throwing an error.
"""
import pathlib
import pytest
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
examples_path = pathlib.Path(__file__).parent
notebook_paths = examples_path.glob('**/*.ipynb')
filtered_notebook_paths = [
path for path in notebook_paths if '.ipynb_checkpoints' not in str(path)
]
relative_notebook_paths = [
str(p.relative_to(examples_path)) for p in filtered_notebook_paths
]
def run_notebook(filename):
with open(filename) as ff:
nb_in = nbformat.read(ff, nbformat.NO_CONVERT)
ep = ExecutePreprocessor(timeout=1200, kernel_name='python3')
ep.preprocess(nb_in)
SKIP_LIST = [
'extras/classification-confusion-matrix.ipynb',
'label_export/images.ipynb',
'label_export/text.ipynb',
'label_export/video.ipynb',
'annotation_types/converters.ipynb',
'integrations/detectron2/coco_panoptic.ipynb',
'integrations/tlt/detectnet_v2_bounding_box.ipynb',
'basics/datasets.ipynb',
'basics/data_rows.ipynb',
'basics/labels.ipynb',
'basics/data_row_metadata.ipynb',
'model_diagnostics/custom_metrics_basics.ipynb',
'basics/user_management.ipynb',
'integrations/tlt/labelbox_upload.ipynb',
'model_diagnostics/custom_metrics_demo.ipynb',
'model_diagnostics/model_diagnostics_demo.ipynb',
'integrations/databricks/',
'integrations/detectron2/coco_object.ipynb',
'project_configuration/webhooks.ipynb',
'basics/projects.ipynb',
'model_diagnostics/model_diagnostics_guide.ipynb',
]
def skip_notebook(notebook_path):
for skip_path in SKIP_LIST:
if notebook_path.startswith(skip_path):
return True
return False
run_notebook_paths = [
path for path in relative_notebook_paths if not skip_notebook(path)
]
@pytest.mark.skip(
'Need some more work to run reliably, e.g. figuring out how to deal with '
'max number of models per org, therefore skipping from CI. However, this '
'test can be run locally after updating notebooks to ensure notebooks '
'are working.')
@pytest.mark.parametrize("notebook_path", run_notebook_paths)
def test_notebooks_run_without_errors(notebook_path):
run_notebook(examples_path / notebook_path)