@@ -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
@@ -122,7 +125,8 @@ interface ReplForJupyter {
122
125
123
126
suspend fun serializeVariables (cellId : Int , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
124
127
125
- suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
128
+ suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String > = emptyList(),
129
+ callback : (SerializationReply ) -> Unit )
126
130
127
131
val homeDir: File ?
128
132
@@ -193,7 +197,7 @@ class ReplForJupyterImpl(
193
197
194
198
override val variablesSerializer = VariablesSerializer ()
195
199
196
- private val librariesScanner = LibrariesScanner (notebook)
200
+ val librariesScanner = LibrariesScanner (notebook)
197
201
private val resourcesProcessor = LibraryResourcesProcessorImpl ()
198
202
199
203
override var outputConfig
@@ -428,8 +432,10 @@ class ReplForJupyterImpl(
428
432
// printUsagesInfo(jupyterId, cellVariables[jupyterId - 1])
429
433
val serializedData = variablesSerializer.serializeVariables(jupyterId - 1 , notebook.variablesState, notebook.unchangedVariables())
430
434
435
+ GlobalScope .launch(Dispatchers .Default ) {
436
+ variablesSerializer.tryValidateCache(jupyterId - 1 , notebook.cellVariables)
437
+ }
431
438
432
- val variablesStateUpdate = notebook.variablesState.mapValues { " " }
433
439
EvalResultEx (
434
440
result.result.value,
435
441
rendered,
@@ -532,8 +538,9 @@ class ReplForJupyterImpl(
532
538
doWithLock(SerializationArgs (descriptorsState, cellId = cellId, callback = callback), serializationQueue, SerializationReply (cellId, descriptorsState), ::doSerializeVariables)
533
539
}
534
540
535
- override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit ) {
536
- doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback), serializationQueue, SerializationReply (), ::doSerializeVariables)
541
+ override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String >,
542
+ callback : (SerializationReply ) -> Unit ) {
543
+ doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback, pathToDescriptor = pathToDescriptor), serializationQueue, SerializationReply (), ::doSerializeVariables)
537
544
}
538
545
539
546
private fun doSerializeVariables (args : SerializationArgs ): SerializationReply {
@@ -544,7 +551,7 @@ class ReplForJupyterImpl(
544
551
finalAns
545
552
}
546
553
args.descriptorsState.forEach { (name, state) ->
547
- resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state)
554
+ resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state, args.pathToDescriptor )
548
555
}
549
556
log.debug(" Serialization cellID: $cellId " )
550
557
log.debug(" Serialization answer: ${resultMap.entries.first().value.fieldDescriptor} " )
@@ -588,6 +595,7 @@ class ReplForJupyterImpl(
588
595
val descriptorsState : Map <String , SerializedVariablesState >,
589
596
var cellId : Int = -1 ,
590
597
val topLevelVarName : String = " " ,
598
+ val pathToDescriptor : List <String > = emptyList(),
591
599
override val callback : (SerializationReply ) -> Unit
592
600
) : LockQueueArgs<SerializationReply>
593
601
0 commit comments