@@ -5,6 +5,9 @@ import jupyter.kotlin.DependsOn
5
5
import jupyter.kotlin.KotlinContext
6
6
import jupyter.kotlin.KotlinKernelHostProvider
7
7
import jupyter.kotlin.Repository
8
+ import kotlinx.coroutines.Dispatchers
9
+ import kotlinx.coroutines.GlobalScope
10
+ import kotlinx.coroutines.launch
8
11
import org.jetbrains.annotations.TestOnly
9
12
import org.jetbrains.kotlin.config.KotlinCompilerVersion
10
13
import org.jetbrains.kotlinx.jupyter.api.Code
@@ -131,7 +134,8 @@ interface ReplForJupyter {
131
134
132
135
suspend fun serializeVariables (cellId : Int , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
133
136
134
- suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
137
+ suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String > = emptyList(),
138
+ callback : (SerializationReply ) -> Unit )
135
139
136
140
val homeDir: File ?
137
141
@@ -202,7 +206,7 @@ class ReplForJupyterImpl(
202
206
203
207
override val variablesSerializer = VariablesSerializer ()
204
208
205
- private val librariesScanner = LibrariesScanner (notebook)
209
+ val librariesScanner = LibrariesScanner (notebook)
206
210
private val resourcesProcessor = LibraryResourcesProcessorImpl ()
207
211
208
212
override var outputConfig
@@ -439,8 +443,10 @@ class ReplForJupyterImpl(
439
443
// printUsagesInfo(jupyterId, cellVariables[jupyterId - 1])
440
444
val serializedData = variablesSerializer.serializeVariables(jupyterId - 1 , notebook.variablesState, notebook.unchangedVariables())
441
445
446
+ GlobalScope .launch(Dispatchers .Default ) {
447
+ variablesSerializer.tryValidateCache(jupyterId - 1 , notebook.cellVariables)
448
+ }
442
449
443
- val variablesStateUpdate = notebook.variablesState.mapValues { " " }
444
450
EvalResultEx (
445
451
result.result.value,
446
452
rendered,
@@ -543,8 +549,9 @@ class ReplForJupyterImpl(
543
549
doWithLock(SerializationArgs (descriptorsState, cellId = cellId, callback = callback), serializationQueue, SerializationReply (cellId, descriptorsState), ::doSerializeVariables)
544
550
}
545
551
546
- override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit ) {
547
- doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback), serializationQueue, SerializationReply (), ::doSerializeVariables)
552
+ override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String >,
553
+ callback : (SerializationReply ) -> Unit ) {
554
+ doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback, pathToDescriptor = pathToDescriptor), serializationQueue, SerializationReply (), ::doSerializeVariables)
548
555
}
549
556
550
557
private fun doSerializeVariables (args : SerializationArgs ): SerializationReply {
@@ -555,7 +562,7 @@ class ReplForJupyterImpl(
555
562
finalAns
556
563
}
557
564
args.descriptorsState.forEach { (name, state) ->
558
- resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state)
565
+ resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state, args.pathToDescriptor )
559
566
}
560
567
log.debug(" Serialization cellID: $cellId " )
561
568
log.debug(" Serialization answer: ${resultMap.entries.first().value.fieldDescriptor} " )
@@ -599,6 +606,7 @@ class ReplForJupyterImpl(
599
606
val descriptorsState : Map <String , SerializedVariablesState >,
600
607
var cellId : Int = -1 ,
601
608
val topLevelVarName : String = " " ,
609
+ val pathToDescriptor : List <String > = emptyList(),
602
610
override val callback : (SerializationReply ) -> Unit
603
611
) : LockQueueArgs<SerializationReply>
604
612
0 commit comments