@@ -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
@@ -136,7 +139,8 @@ interface ReplForJupyter {
136
139
137
140
suspend fun serializeVariables (cellId : Int , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
138
141
139
- suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
142
+ suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String > = emptyList(),
143
+ callback : (SerializationReply ) -> Unit )
140
144
141
145
val homeDir: File ?
142
146
@@ -209,7 +213,7 @@ class ReplForJupyterImpl(
209
213
210
214
override val variablesSerializer = VariablesSerializer ()
211
215
212
- private val librariesScanner = LibrariesScanner (notebook)
216
+ val librariesScanner = LibrariesScanner (notebook)
213
217
private val resourcesProcessor = LibraryResourcesProcessorImpl ()
214
218
215
219
override var outputConfig
@@ -455,8 +459,10 @@ class ReplForJupyterImpl(
455
459
// printUsagesInfo(jupyterId, cellVariables[jupyterId - 1])
456
460
val serializedData = variablesSerializer.serializeVariables(jupyterId - 1 , notebook.variablesState, notebook.unchangedVariables())
457
461
462
+ GlobalScope .launch(Dispatchers .Default ) {
463
+ variablesSerializer.tryValidateCache(jupyterId - 1 , notebook.cellVariables)
464
+ }
458
465
459
- val variablesStateUpdate = notebook.variablesState.mapValues { " " }
460
466
EvalResultEx (
461
467
result.result.value,
462
468
rendered,
@@ -559,8 +565,9 @@ class ReplForJupyterImpl(
559
565
doWithLock(SerializationArgs (descriptorsState, cellId = cellId, callback = callback), serializationQueue, SerializationReply (cellId, descriptorsState), ::doSerializeVariables)
560
566
}
561
567
562
- override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit ) {
563
- doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback), serializationQueue, SerializationReply (), ::doSerializeVariables)
568
+ override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String >,
569
+ callback : (SerializationReply ) -> Unit ) {
570
+ doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback, pathToDescriptor = pathToDescriptor), serializationQueue, SerializationReply (), ::doSerializeVariables)
564
571
}
565
572
566
573
private fun doSerializeVariables (args : SerializationArgs ): SerializationReply {
@@ -571,7 +578,7 @@ class ReplForJupyterImpl(
571
578
finalAns
572
579
}
573
580
args.descriptorsState.forEach { (name, state) ->
574
- resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state)
581
+ resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state, args.pathToDescriptor )
575
582
}
576
583
log.debug(" Serialization cellID: $cellId " )
577
584
log.debug(" Serialization answer: ${resultMap.entries.first().value.fieldDescriptor} " )
@@ -615,6 +622,7 @@ class ReplForJupyterImpl(
615
622
val descriptorsState : Map <String , SerializedVariablesState >,
616
623
var cellId : Int = -1 ,
617
624
val topLevelVarName : String = " " ,
625
+ val pathToDescriptor : List <String > = emptyList(),
618
626
override val callback : (SerializationReply ) -> Unit
619
627
) : LockQueueArgs<SerializationReply>
620
628
0 commit comments