Skip to content

Commit d79ca92

Browse files
authored
Extend process_notebooks for testing (microsoft#1789)
* Extend process_notebooks for testing * add command * spelling and lint * update docs * Update contributing.md * add shebang * Update contributing.md * lint
1 parent 612e6eb commit d79ca92

File tree

7 files changed

+345
-68
lines changed

7 files changed

+345
-68
lines changed

.github/workflows/deploy-website.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
quarto render .
5353
- name: Process notebooks
5454
run: |
55-
python process_notebooks.py
55+
python process_notebooks.py render
5656
- name: Test Build
5757
run: |
5858
if [ -e yarn.lock ]; then
@@ -98,7 +98,7 @@ jobs:
9898
quarto render .
9999
- name: Process notebooks
100100
run: |
101-
python process_notebooks.py
101+
python process_notebooks.py render
102102
- name: Build website
103103
run: |
104104
if [ -e yarn.lock ]; then

notebook/agentchat_RetrieveChat.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -3036,7 +3036,8 @@
30363036
"nbconvert_exporter": "python",
30373037
"pygments_lexer": "ipython3",
30383038
"version": "3.10.12"
3039-
}
3039+
},
3040+
"test_skip": "Requires interactive usage"
30403041
},
30413042
"nbformat": 4,
30423043
"nbformat_minor": 4

notebook/contributing.md

+34
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,37 @@ Learn more about configuring LLMs for agents [here](/docs/llm_configuration).
7474
:::
7575
````
7676
``````
77+
78+
## Testing
79+
80+
Notebooks can be tested by running:
81+
82+
```sh
83+
python website/process_notebooks.py test
84+
```
85+
86+
This will automatically scan for all notebooks in the notebook/ and website/ dirs.
87+
88+
To test a specific notebook pass its path:
89+
90+
```sh
91+
python website/process_notebooks.py test notebook/agentchat_logging.ipynb
92+
```
93+
94+
Options:
95+
- `--timeout` - timeout for a single notebook
96+
- `--exit-on-first-fail` - stop executing further notebooks after the first one fails
97+
98+
### Skip tests
99+
100+
If a notebook needs to be skipped then add to the notebook metadata:
101+
```json
102+
{
103+
"...": "...",
104+
"metadata": {
105+
"test_skip": "REASON"
106+
}
107+
}
108+
```
109+
110+
Note: Notebook metadata can be edited by opening the notebook in a text editor (Or "Open With..." -> "Text Editor" in VSCode)

website/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ Navigate to the `website` folder and run:
3333

3434
```console
3535
pydoc-markdown
36-
quarto render ./docs
37-
python ./process_notebooks.py
36+
python ./process_notebooks.py render
3837
yarn start
3938
```
4039

website/build_website.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ fi
2828
# Generate documentation using pydoc-markdown
2929
pydoc-markdown
3030

31-
# Render the website using Quarto
32-
quarto render ./docs
33-
3431
# Process notebooks using a Python script
35-
python ./process_notebooks.py
32+
python ./process_notebooks.py render
3633

3734
# Start the website using yarn
3835
yarn start

website/docs/Contribute.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ Tests for the `autogen.agentchat.contrib` module may be skipped automatically if
175175
required dependencies are not installed. Please consult the documentation for
176176
each contrib module to see what dependencies are required.
177177

178+
See [here](https://github.com/microsoft/autogen/blob/main/notebook/contributing.md#testing) for how to run notebook tests.
179+
178180
#### Skip flags for tests
179181

180182
- `--skip-openai` for skipping tests that require access to OpenAI services.
@@ -216,11 +218,11 @@ Then:
216218

217219
```console
218220
npm install --global yarn # skip if you use the dev container we provided
219-
pip install pydoc-markdown # skip if you use the dev container we provided
221+
pip install pydoc-markdown pyyaml termcolor # skip if you use the dev container we provided
220222
cd website
221223
yarn install --frozen-lockfile --ignore-engines
222224
pydoc-markdown
223-
quarto render ./docs
225+
python process_notebooks.py render
224226
yarn start
225227
```
226228

@@ -245,7 +247,7 @@ Once at the CLI in Docker run the following commands:
245247
cd website
246248
yarn install --frozen-lockfile --ignore-engines
247249
pydoc-markdown
248-
quarto render ./docs
250+
python process_notebooks.py render
249251
yarn start --host 0.0.0.0 --port 3000
250252
```
251253

0 commit comments

Comments
 (0)