(kernelspec: IJupyterKernelSpec)
| 144 | } |
| 145 | |
| 146 | export function isDefaultKernelSpec(kernelspec: IJupyterKernelSpec) { |
| 147 | // // When we create kernlespecs, we change the name to include a unique id. |
| 148 | // // We need to look at the name of the original kernelspec that was created on disc. |
| 149 | // // E.g. assume we're loading a kernlespec for a default Python kernel, the name would be `python3` |
| 150 | // // However we give this a completely different name, and at that point its not possible to determine |
| 151 | // // whether this is a default kernel or not. |
| 152 | // // Hence determine the original name based on the original kernelspec file. |
| 153 | const originalSpecFile = kernelspec.metadata?.vscode?.originalSpecFile || kernelspec.metadata?.originalSpecFile; |
| 154 | const name = originalSpecFile ? path.basename(path.dirname(originalSpecFile)) : kernelspec.name || ''; |
| 155 | const displayName = kernelspec.metadata?.vscode?.originalDisplayName || kernelspec.display_name || ''; |
| 156 | |
| 157 | // If the user creates a kernelspec with a name `python4` or changes the display |
| 158 | // name of kernel `python3` to `Hello World`, then we'd still treat them as default kernelspecs, |
| 159 | // The expectation is for users to use unique names & display names for their kernelspecs. |
| 160 | if ( |
| 161 | name.toLowerCase().match(isDefaultPythonKernelSpecName) || |
| 162 | displayName.toLowerCase() === 'python 3 (ipykernel)' || |
| 163 | displayName.toLowerCase() === 'python 3' |
| 164 | ) { |
| 165 | return true; |
| 166 | } |
| 167 | return false; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * When creating remote sessions, we generate bogus names for the notebook. |
no test coverage detected