Skip to content

Commit bba3acd

Browse files
revise readme
1 parent a40ca9b commit bba3acd

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

tools/README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# test_notebooks.py
22

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.
44

55
## Features
66
- **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).
88
- **Execution Reporting:** Prints a summary of successful and failed notebooks, including error messages for failures.
99
- **Command Line Usage:** Can run all notebooks in a directory or a specified list of notebook files.
1010

@@ -24,6 +24,24 @@ python3 tools/test_notebooks.py notebooks/example1.ipynb notebooks/example2.ipyn
2424
```
2525
This will execute only the specified notebooks.
2626

27+
## Setting Up Environment Variables
28+
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+
2745
## Skip List
2846
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.
2947
@@ -41,20 +59,5 @@ pip3 install nbformat nbconvert
4159
- Returns `0` if all notebooks succeed.
4260
- Returns `1` if any notebook fails or if no notebooks are found.
4361

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-
5862
## 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

Comments
 (0)