You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/README.md
+21-18Lines changed: 21 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# test_notebooks.py
2
2
3
-
This script is designed to automatically execute Jupyter notebooks in the `notebooks/` directory (or a specified directory) and report their execution status. It is useful for validating that all notebooks in the repository run successfully from start to finish, which is especially helpful for CI/CD pipelines or for contributors to verify their changes.
3
+
This script is designed for **testing and validating** that all Jupyter notebooks in the `notebooks/` directory (or a specified directory) execute successfully from start to finish. It is especially useful for pre-merge checks and for contributors to verify that their changes do not break any notebook workflows.
4
4
5
5
## Features
6
6
-**Automatic Discovery:** Recursively scans a directory for `.ipynb` files (excluding hidden files).
7
-
-**Selective Skipping:** Supports a skip list to exclude specific notebooks from execution (e.g., those requiring manual input).
7
+
-**Selective Skipping:** Supports a skip list to exclude specific notebooks from execution (e.g., those requiring manual input or special setup).
8
8
-**Execution Reporting:** Prints a summary of successful and failed notebooks, including error messages for failures.
9
9
-**Command Line Usage:** Can run all notebooks in a directory or a specified list of notebook files.
Some notebooks require access to Azure Storage or other resources. You may need to set environment variables in the [.env](../notebooks/.env) file before running the tests. For example, to test notebooks that use training data or reference documents, follow these steps:
29
+
30
+
1.**Prepare Azure Storage:**
31
+
- Create an Azure Storage Account and a Blob Container (can follow the guide to [create an Azure Storage Account](https://aka.ms/create-a-storage-account)).
32
+
- Use Azure Storage Explorer to generate a Shared Access Signature (SAS) URL with `Read`, `Write`, and `List` permissions for the container.
33
+
2.**Set Environment Variables:**
34
+
- Add the following variables to the [.env](../notebooks/.env) file in your project root:
35
+
36
+
```env
37
+
TRAINING_DATA_SAS_URL=<Blob container SAS URL>
38
+
TRAINING_DATA_PATH=<Designated folder path under the blob container>
39
+
REFERENCE_DOC_SAS_URL=<Blob container SAS URL>
40
+
REFERENCE_DOC_PATH=<Designated folder path under the blob container>
41
+
```
42
+
- These variables will be used by notebooks that require access to training/reference data.
43
+
- You can refer to [Set env for training data and reference doc](../docs/set_env_for_training_data_and_reference_doc.md) for setting up these variables.
44
+
27
45
## Skip List
28
46
You can modify the `skip_list` variable in the script to add or remove notebooks that should be skipped during execution. The skip list can contain full paths or substrings.
- Returns `1` if any notebook fails or if no notebooks are found.
43
61
44
-
## Example Output
45
-
```
46
-
🔍 Scanning for notebooks in: /path/to/notebooks
47
-
▶️ Running: /path/to/notebooks/example.ipynb
48
-
✅ Success: /path/to/notebooks/example.ipynb
49
-
...
50
-
🧾 Notebook Execution Summary
51
-
✅ 3 succeeded
52
-
❌ 1 failed
53
-
🚨 Failed notebooks:
54
-
- /path/to/notebooks/failing.ipynb
55
-
↳ Traceback (most recent call last): ...
56
-
```
57
-
58
62
## Notes
59
-
- Notebooks that require manual input or special setup should be added to the skip list.
60
-
- The script is intended for use in development, CI, or pre-merge validation workflows.
63
+
- Notebooks that require manual input, special setup, or specific environment variables could be added to the skip list or set up the requirements accordingly.
0 commit comments