@@ -8,6 +8,7 @@ import { useState, useEffect } from 'react';
88import { CodeCell , MarkdownCell } from '@jupyterlab/cells' ;
99import { Box } from '@primer/react' ;
1010import { useJupyter } from './../../jupyter' ;
11+ import Kernel from '../../jupyter/kernel/Kernel' ;
1112import { newUuid } from '../../utils' ;
1213import { Lumino } from '../lumino' ;
1314import { CellAdapter } from './CellAdapter' ;
@@ -38,6 +39,10 @@ export type ICellProps = {
3839 * Cell type
3940 */
4041 type : 'code' | 'markdown' | 'raw' ;
42+ /**
43+ * Custom kernel for the cell. Falls back to the defaultKernel if not provided.
44+ */
45+ kernel ?: Kernel ;
4146} ;
4247
4348export const Cell = ( props : ICellProps ) => {
@@ -47,6 +52,7 @@ export const Cell = (props: ICellProps) => {
4752 source = '' ,
4853 startDefaultKernel,
4954 type,
55+ kernel : customKernel ,
5056 } = props ;
5157 const { defaultKernel, serverSettings } = useJupyter ( {
5258 startDefaultKernel,
@@ -81,14 +87,15 @@ export const Cell = (props: ICellProps) => {
8187 } ) ;
8288 }
8389 useEffect ( ( ) => {
84- if ( id && defaultKernel && serverSettings ) {
85- defaultKernel . ready . then ( ( ) => {
90+ const kernelToUse = customKernel || defaultKernel ;
91+ if ( id && serverSettings && kernelToUse ) {
92+ kernelToUse . ready . then ( ( ) => {
8693 const adapter = new CellAdapter ( {
8794 id,
8895 type,
8996 source,
9097 serverSettings,
91- kernel : defaultKernel ,
98+ kernel : kernelToUse ,
9299 boxOptions : { showToolbar}
93100 } ) ;
94101 cellsStore . setAdapter ( id , adapter ) ;
@@ -115,7 +122,7 @@ export const Cell = (props: ICellProps) => {
115122 } ;
116123 } ) ;
117124 }
118- } , [ source , defaultKernel , serverSettings ] ) ;
125+ } , [ source , defaultKernel , customKernel , serverSettings ] ) ;
119126 return adapter ? (
120127 < Box
121128 sx = { {
0 commit comments