(kernelConnection?: KernelConnectionMetadata)
| 365 | } |
| 366 | |
| 367 | export function getKernelDisplayPathFromKernelConnection(kernelConnection?: KernelConnectionMetadata): Uri | undefined { |
| 368 | if (!kernelConnection) { |
| 369 | return; |
| 370 | } |
| 371 | const model = kernelConnectionMetadataHasKernelModel(kernelConnection) ? kernelConnection.kernelModel : undefined; |
| 372 | const kernelSpec = kernelConnectionMetadataHasKernelSpec(kernelConnection) |
| 373 | ? kernelConnection.kernelSpec |
| 374 | : undefined; |
| 375 | if ( |
| 376 | kernelConnection.kind === 'startUsingPythonInterpreter' || |
| 377 | ((kernelConnection.kind === 'startUsingRemoteKernelSpec' || |
| 378 | kernelConnection.kind === 'startUsingLocalKernelSpec') && |
| 379 | kernelConnection.kernelSpec.language === PYTHON_LANGUAGE) |
| 380 | ) { |
| 381 | const pathValue = |
| 382 | kernelSpec?.metadata?.interpreter?.path || kernelSpec?.interpreterPath || kernelSpec?.executable; |
| 383 | if (pathValue === '/python' || pathValue === 'python') { |
| 384 | const env = getCachedEnvironment(kernelConnection.interpreter); |
| 385 | return env?.environment?.folderUri || (env ? Uri.file(env.path) : undefined); |
| 386 | } |
| 387 | return pathValue ? Uri.file(pathValue) : undefined; |
| 388 | } else { |
| 389 | // For non python kernels, give preference to the executable path in the kernelspec |
| 390 | // E.g. if we have a rust kernel, we should show the path to the rust executable not the interpreter (such as conda env that owns the rust runtime). |
| 391 | const pathValue = |
| 392 | model?.executable || |
| 393 | kernelSpec?.executable || |
| 394 | kernelSpec?.metadata?.interpreter?.path || |
| 395 | kernelSpec?.interpreterPath; |
| 396 | return pathValue ? Uri.file(pathValue) : undefined; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | export function getRemoteKernelSessionInformation( |
| 401 | kernelConnection: KernelConnectionMetadata | undefined, |
no test coverage detected