Skip to content

Commit e18e280

Browse files
Implement proper Jupyter kernel defaulting and configuration
- Replaced ineffective jupyter.kernels.filter with notebook.defaultKernel setting - Added notebook.kernelProviderAssociations to ensure APIM kernel is preferred - Updated all 14 existing notebooks with correct kernelspec metadata - Created update-notebook-kernels.py script for automated kernel metadata updates - Added apim-samples.code-workspace for consistent workspace configuration - Enhanced verification script with detailed kernel checking and validation - Improved post-start-setup.sh kernel registration with better error handling This ensures zero-configuration Jupyter experience where: - Only the APIM Samples Python 3.12 kernel is visible and auto-selected - All notebooks default to the correct venv kernel automatically - No manual kernel selection required in Codespaces or local development
1 parent 225e67f commit e18e280

File tree

20 files changed

+211
-52
lines changed

20 files changed

+211
-52
lines changed

.devcontainer/devcontainer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@
6565
"jupyter.askForKernelRestart": false,
6666
"jupyter.interactiveWindow.textEditor.executeSelection": true,
6767
"jupyter.notebookFileRoot": "${workspaceFolder}",
68+
"notebook.defaultKernel": "apim-samples",
69+
"jupyter.kernels.trusted": [
70+
"/workspaces/Apim-Samples/.venv/bin/python"
71+
],
72+
"notebook.kernelProviderAssociations": {
73+
"**/*.ipynb": [
74+
"apim-samples"
75+
]
76+
},
6877
"files.associations": {
6978
"*.bicep": "bicep"
7079
}

.devcontainer/post-start-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ if jupyter kernelspec list | grep -q "apim-samples" 2>/dev/null; then
106106
echo " APIM Samples Kernel: ✅"
107107
else
108108
echo " APIM Samples Kernel: ❌ (registering...)"
109-
python -m ipykernel install --user --name=apim-samples --display-name="APIM Samples Python 3.12" 2>/dev/null || echo " ⚠️ Failed to register kernel"
109+
python -m ipykernel install --user --name=apim-samples --display-name="APIM Samples Python 3.12" 2>/dev/null && echo " ✅ Kernel registered successfully" || echo " ⚠️ Failed to register kernel"
110110
fi
111111

112112
# Test core imports

.vscode/settings.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
"jupyter.askForKernelRestart": false,
2323
"jupyter.interactiveWindow.textEditor.executeSelection": true,
2424
"jupyter.notebookFileRoot": "${workspaceFolder}",
25-
"jupyter.kernels.filter": [
26-
"/usr/bin/python3",
27-
"/bin/python3",
28-
"/usr/local/bin/python3",
29-
"/opt/python/*/bin/python*",
30-
"*/site-packages/*"
31-
],
25+
"notebook.defaultKernel": "apim-samples",
3226
"jupyter.kernels.trusted": [
3327
"/workspaces/Apim-Samples/.venv/bin/python"
3428
],
29+
"notebook.kernelProviderAssociations": {
30+
"**/*.ipynb": [
31+
"apim-samples"
32+
]
33+
},
3534
"terminal.integrated.env.windows": {
3635
"PATH": "${env:PATH}"
3736
},

apim-samples.code-workspace

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
// Workspace configuration for APIM Samples
3+
"folders": [
4+
{
5+
"path": "."
6+
}
7+
],
8+
"settings": {
9+
// Default kernel for all notebooks in this workspace
10+
"notebook.defaultKernel": "apim-samples",
11+
12+
// Kernel associations to ensure our kernel is preferred
13+
"notebook.kernelProviderAssociations": {
14+
"**/*.ipynb": [
15+
"apim-samples"
16+
]
17+
},
18+
19+
// Trust our venv kernel
20+
"jupyter.kernels.trusted": [
21+
"/workspaces/Apim-Samples/.venv/bin/python"
22+
],
23+
24+
// Python configuration for the workspace
25+
"python.defaultInterpreterPath": "/workspaces/Apim-Samples/.venv/bin/python",
26+
"python.pythonPath": "/workspaces/Apim-Samples/.venv/bin/python",
27+
"python.terminal.activateEnvironment": true,
28+
"python.terminal.activateEnvInCurrentTerminal": true,
29+
"python.envFile": "${workspaceFolder}/.env"
30+
}
31+
}

infrastructure/afd-apim/clean-up.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
],
2828
"metadata": {
2929
"kernelspec": {
30-
"display_name": ".venv",
30+
"display_name": "APIM Samples Python 3.12",
3131
"language": "python",
32-
"name": "python3"
32+
"name": "apim-samples"
3333
},
3434
"language_info": {
3535
"codemirror_mode": {
@@ -46,4 +46,4 @@
4646
},
4747
"nbformat": 4,
4848
"nbformat_minor": 2
49-
}
49+
}

infrastructure/afd-apim/create.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@
268268
],
269269
"metadata": {
270270
"kernelspec": {
271-
"display_name": ".venv",
271+
"display_name": "APIM Samples Python 3.12",
272272
"language": "python",
273-
"name": "python3"
273+
"name": "apim-samples"
274274
},
275275
"language_info": {
276276
"codemirror_mode": {
@@ -287,4 +287,4 @@
287287
},
288288
"nbformat": 4,
289289
"nbformat_minor": 2
290-
}
290+
}

infrastructure/apim-aca/clean-up.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
],
2828
"metadata": {
2929
"kernelspec": {
30-
"display_name": ".venv",
30+
"display_name": "APIM Samples Python 3.12",
3131
"language": "python",
32-
"name": "python3"
32+
"name": "apim-samples"
3333
},
3434
"language_info": {
3535
"codemirror_mode": {
@@ -46,4 +46,4 @@
4646
},
4747
"nbformat": 4,
4848
"nbformat_minor": 2
49-
}
49+
}

infrastructure/apim-aca/create.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@
139139
],
140140
"metadata": {
141141
"kernelspec": {
142-
"display_name": ".venv",
142+
"display_name": "APIM Samples Python 3.12",
143143
"language": "python",
144-
"name": "python3"
144+
"name": "apim-samples"
145145
},
146146
"language_info": {
147147
"codemirror_mode": {
@@ -158,4 +158,4 @@
158158
},
159159
"nbformat": 4,
160160
"nbformat_minor": 2
161-
}
161+
}

infrastructure/simple-apim/clean-up.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
],
2828
"metadata": {
2929
"kernelspec": {
30-
"display_name": ".venv",
30+
"display_name": "APIM Samples Python 3.12",
3131
"language": "python",
32-
"name": "python3"
32+
"name": "apim-samples"
3333
},
3434
"language_info": {
3535
"codemirror_mode": {
@@ -46,4 +46,4 @@
4646
},
4747
"nbformat": 4,
4848
"nbformat_minor": 2
49-
}
49+
}

infrastructure/simple-apim/create.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@
119119
],
120120
"metadata": {
121121
"kernelspec": {
122-
"display_name": ".venv",
122+
"display_name": "APIM Samples Python 3.12",
123123
"language": "python",
124-
"name": "python3"
124+
"name": "apim-samples"
125125
},
126126
"language_info": {
127127
"codemirror_mode": {
@@ -138,4 +138,4 @@
138138
},
139139
"nbformat": 4,
140140
"nbformat_minor": 2
141-
}
141+
}

0 commit comments

Comments
 (0)