@@ -8,6 +8,7 @@ import { useState, useEffect } from 'react';
8
8
import { CodeCell , MarkdownCell } from '@jupyterlab/cells' ;
9
9
import { Box } from '@primer/react' ;
10
10
import { useJupyter } from './../../jupyter' ;
11
+ import Kernel from '../../jupyter/kernel/Kernel' ;
11
12
import { newUuid } from '../../utils' ;
12
13
import { Lumino } from '../lumino' ;
13
14
import { CellAdapter } from './CellAdapter' ;
@@ -38,6 +39,10 @@ export type ICellProps = {
38
39
* Cell type
39
40
*/
40
41
type : 'code' | 'markdown' | 'raw' ;
42
+ /**
43
+ * Custom kernel for the cell. Falls back to the defaultKernel if not provided.
44
+ */
45
+ kernel ?: Kernel ;
41
46
} ;
42
47
43
48
export const Cell = ( props : ICellProps ) => {
@@ -47,6 +52,7 @@ export const Cell = (props: ICellProps) => {
47
52
source = '' ,
48
53
startDefaultKernel,
49
54
type,
55
+ kernel : customKernel ,
50
56
} = props ;
51
57
const { defaultKernel, serverSettings } = useJupyter ( {
52
58
startDefaultKernel,
@@ -81,14 +87,15 @@ export const Cell = (props: ICellProps) => {
81
87
} ) ;
82
88
}
83
89
useEffect ( ( ) => {
84
- if ( id && defaultKernel && serverSettings ) {
85
- defaultKernel . ready . then ( ( ) => {
90
+ const kernelToUse = customKernel || defaultKernel ;
91
+ if ( id && serverSettings && kernelToUse ) {
92
+ kernelToUse . ready . then ( ( ) => {
86
93
const adapter = new CellAdapter ( {
87
94
id,
88
95
type,
89
96
source,
90
97
serverSettings,
91
- kernel : defaultKernel ,
98
+ kernel : kernelToUse ,
92
99
boxOptions : { showToolbar}
93
100
} ) ;
94
101
cellsStore . setAdapter ( id , adapter ) ;
@@ -115,7 +122,7 @@ export const Cell = (props: ICellProps) => {
115
122
} ;
116
123
} ) ;
117
124
}
118
- } , [ source , defaultKernel , serverSettings ] ) ;
125
+ } , [ source , defaultKernel , customKernel , serverSettings ] ) ;
119
126
return adapter ? (
120
127
< Box
121
128
sx = { {
0 commit comments