Skip to content

Commit

Permalink
Merge pull request #201 from Shubha-accenture/notebook-kernel-status
Browse files Browse the repository at this point in the history
Getting kernel status from sessionContext
  • Loading branch information
ojarjur authored Dec 18, 2024
2 parents 69e0595 + ac4d956 commit 7b17aed
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions src/controls/NotebookButtonExtension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,8 @@ class NotebookButtonExtensionPoint implements IDisposable {
* Fetch and update kernel status from the KernelAPI.
*/
private async fetchAndUpdateKernelStatus() {
try {
const currentKernelId = this.context.sessionContext.session?.kernel?.id;
if (!currentKernelId) {
this.setKernelStatus('Initializing', '#455A64');
return;
}

const runningKernels = await KernelAPI.listRunning();
const currentKernel = runningKernels.find(
kernel => kernel.id === currentKernelId
);

if (currentKernel) {
const kernelStatus = currentKernel?.execution_state ?? 'Unknown';
this.setKernelStatus(kernelStatus, this.getStatusColor(kernelStatus));
} else {
this.setKernelStatus('Failed', '#D93025');
}
} catch (error) {
console.error('Error fetching kernel status:', error);
this.setKernelStatus('Failed', '#D93025');
}
const kernelStatus = this.context.sessionContext.kernelDisplayStatus;
this.setKernelStatus(kernelStatus, this.getStatusColor(kernelStatus));
}

/**
Expand Down Expand Up @@ -241,7 +221,7 @@ class NotebookButtonExtensionPoint implements IDisposable {
return ' #455A64';
case 'restarting':
return '#9747FF';
case 'Unknown':
case 'unknown':
return '#C9C9C9';
default:
return '#FF9800';
Expand Down

0 comments on commit 7b17aed

Please sign in to comment.