@@ -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
@@ -139,7 +142,8 @@ interface ReplForJupyter {
139
142
140
143
suspend fun serializeVariables (cellId : Int , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
141
144
142
- suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit )
145
+ suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String > = emptyList(),
146
+ callback : (SerializationReply ) -> Unit )
143
147
144
148
val homeDir: File ?
145
149
@@ -212,7 +216,7 @@ class ReplForJupyterImpl(
212
216
213
217
override val variablesSerializer = VariablesSerializer ()
214
218
215
- private val librariesScanner = LibrariesScanner (notebook)
219
+ val librariesScanner = LibrariesScanner (notebook)
216
220
private val resourcesProcessor = LibraryResourcesProcessorImpl ()
217
221
218
222
override var outputConfig
@@ -459,8 +463,10 @@ class ReplForJupyterImpl(
459
463
// printUsagesInfo(jupyterId, cellVariables[jupyterId - 1])
460
464
val serializedData = variablesSerializer.serializeVariables(jupyterId - 1 , notebook.variablesState, notebook.unchangedVariables())
461
465
466
+ GlobalScope .launch(Dispatchers .Default ) {
467
+ variablesSerializer.tryValidateCache(jupyterId - 1 , notebook.cellVariables)
468
+ }
462
469
463
- val variablesStateUpdate = notebook.variablesState.mapValues { " " }
464
470
EvalResultEx (
465
471
result.result.value,
466
472
rendered,
@@ -567,8 +573,9 @@ class ReplForJupyterImpl(
567
573
doWithLock(SerializationArgs (descriptorsState, cellId = cellId, callback = callback), serializationQueue, SerializationReply (cellId, descriptorsState), ::doSerializeVariables)
568
574
}
569
575
570
- override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, callback : (SerializationReply ) -> Unit ) {
571
- doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback), serializationQueue, SerializationReply (), ::doSerializeVariables)
576
+ override suspend fun serializeVariables (topLevelVarName : String , descriptorsState : Map <String , SerializedVariablesState >, pathToDescriptor : List <String >,
577
+ callback : (SerializationReply ) -> Unit ) {
578
+ doWithLock(SerializationArgs (descriptorsState, topLevelVarName = topLevelVarName, callback = callback, pathToDescriptor = pathToDescriptor), serializationQueue, SerializationReply (), ::doSerializeVariables)
572
579
}
573
580
574
581
private fun doSerializeVariables (args : SerializationArgs ): SerializationReply {
@@ -579,7 +586,7 @@ class ReplForJupyterImpl(
579
586
finalAns
580
587
}
581
588
args.descriptorsState.forEach { (name, state) ->
582
- resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state)
589
+ resultMap[name] = variablesSerializer.doIncrementalSerialization(cellId - 1 , name, state, args.pathToDescriptor )
583
590
}
584
591
log.debug(" Serialization cellID: $cellId " )
585
592
log.debug(" Serialization answer: ${resultMap.entries.first().value.fieldDescriptor} " )
@@ -623,6 +630,7 @@ class ReplForJupyterImpl(
623
630
val descriptorsState : Map <String , SerializedVariablesState >,
624
631
var cellId : Int = -1 ,
625
632
val topLevelVarName : String = " " ,
633
+ val pathToDescriptor : List <String > = emptyList(),
626
634
override val callback : (SerializationReply ) -> Unit
627
635
) : LockQueueArgs<SerializationReply>
628
636
0 commit comments