Skip to content

Commit 68d9792

Browse files
committed
Tests: Add nsightful is_interactive_notebook test notebook for accelerated-python.
1 parent d4ed654 commit 68d9792

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"from nsightful.notebook import is_interactive_notebook\n",
10+
"\n",
11+
"assert is_interactive_notebook() == False, \"nsightful interactive notebook check failed\""
12+
]
13+
}
14+
],
15+
"metadata": {
16+
"accelerator": "GPU",
17+
"colab": {
18+
"gpuType": "T4",
19+
"provenance": []
20+
},
21+
"kernelspec": {
22+
"display_name": "Python 3 (ipykernel)",
23+
"language": "python",
24+
"name": "python3"
25+
}
26+
},
27+
"nbformat": 4,
28+
"nbformat_minor": 5
29+
}

tutorials/accelerated-python/test/test_notebooks.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,25 @@
1111

1212
# Define the path to the notebooks directory
1313
NOTEBOOKS_DIR = Path(__file__).resolve().parent.parent / 'notebooks'
14+
TEST_DIR = Path(__file__).resolve().parent
1415

1516
# Discover all solution notebooks (excluding checkpoint files)
1617
solution_notebooks = sorted([
1718
nb for nb in NOTEBOOKS_DIR.rglob('*SOLUTION*.ipynb')
1819
if '.ipynb_checkpoints' not in str(nb)
1920
])
2021

22+
# Discover test notebooks in the test directory
23+
test_notebooks = sorted([
24+
nb for nb in TEST_DIR.glob('*.ipynb')
25+
if '.ipynb_checkpoints' not in str(nb)
26+
])
27+
28+
all_notebooks = solution_notebooks + test_notebooks
29+
2130
# Create test IDs from notebook paths for better test output
22-
notebook_ids = [nb.relative_to(NOTEBOOKS_DIR).as_posix() for nb in solution_notebooks]
31+
notebook_ids = [nb.relative_to(NOTEBOOKS_DIR).as_posix() for nb in solution_notebooks] + \
32+
[nb.name for nb in test_notebooks]
2333

2434

2535
def extract_cell_outputs(nb, cell_times=None):
@@ -66,7 +76,7 @@ def check_gpu_state():
6676
print(f" GPU State check failed: {e}")
6777

6878

69-
@pytest.mark.parametrize('notebook_path', solution_notebooks, ids=notebook_ids)
79+
@pytest.mark.parametrize('notebook_path', all_notebooks, ids=notebook_ids)
7080
def test_solution_notebook_executes(notebook_path):
7181
"""
7282
Test that a solution notebook executes without errors.

0 commit comments

Comments
 (0)