- 
                Notifications
    You must be signed in to change notification settings 
- Fork 113
Add Serializable Vars State with nested fields descriptors #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
434f8e4    to
    54cc8ed      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look through all the code, but I have some meta-comments.
Also, it seems that serialization may be performance-expensive, so let's introduce a flag (with the value from a system property and defaulting to true) that turns off the serialization (empty map should be sent in metadata)
        
          
                ...iler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/compiler/util/serializedCompiledScript.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/main/kotlin/org/jetbrains/kotlinx/jupyter/serializationUtils.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
 Maybe not empty, but just one-depth stringed values as it was before? | 
| I think that empty is better. If the client does not support this functionality, it will not benefit from any data we'll send in this map. | 
| Wandering through the park, I came across this. We could completely go for jvm fields instead of KProperties since there are some cases when we need jvms | 
90c8b39    to
    e050cb6      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some more comments. Still not finished the review
        
          
                src/main/kotlin/org/jetbrains/kotlinx/jupyter/serializationUtils.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/main/kotlin/org/jetbrains/kotlinx/jupyter/serializationUtils.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/main/kotlin/org/jetbrains/kotlinx/jupyter/serializationUtils.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/main/kotlin/org/jetbrains/kotlinx/jupyter/serializationUtils.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/main/kotlin/org/jetbrains/kotlinx/jupyter/serializationUtils.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
      1a5a0c4    to
    8cfc15e      
    Compare
  
    c14a522    to
    961a320      
    Compare
  
    5820ba6    to
    39aa087      
    Compare
  
    bd39684    to
    001534c      
    Compare
  
    f16ffa0    to
    f347d0f      
    Compare
  
    | } | ||
| } | ||
|  | ||
| class ReplVarsSerializationTest : AbstractSingleReplTest() { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move it to another file... And maybe refactor it somehow to make less lines of code?
| private val unchangedVariables: MutableSet<V> = mutableSetOf() | ||
|  | ||
| fun removeOldDeclarations(address: K, newDeclarations: Set<V>) { | ||
| // removeIf? | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review all comments in the code. If they don't have an explaining function, let's remove them
| variablesDeclarationInfo.remove(it) | ||
| unchangedVariables.remove(it) | ||
| } | ||
| // predicate | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing about comments
| LIST_ERRORS_REPLY(ListErrorsReply::class); | ||
| LIST_ERRORS_REPLY(ListErrorsReply::class), | ||
|  | ||
| SERIALIZATION_REQUEST(SerializationRequest::class), | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it's a bad name for this type of request. Maybe VARIABLES_VIEW_REQUEST? Serialization is implementation detail
| return cellSet.key | ||
| } | ||
| } | ||
| return -1 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should return null here instead of -1?
        
          
                build.gradle.kts
              
                Outdated
          
        
      |  | ||
| val deploy: Configuration by configurations.creating | ||
|  | ||
| val serializationFlagProperty = "jupyter.serialization.enabled" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just inline this property
17ffdfd    to
    d0d5a1d      
    Compare
  
    …riptor name, not cellID
…iptors right away, not through 'size' and 'data' fields
…es from cache; some improvements
d0d5a1d    to
    ef7df1e      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be more attentive when fix issues. Most of them are global, and should be fixed not only in one place but all across the code
| @Serializable | ||
| data class SerializableTypeInfo(val type: Type = Type.Custom, val isPrimitive: Boolean = false, val fullType: String = "") { | ||
| companion object { | ||
| val ignoreSet = setOf("int", "double", "boolean", "char", "float", "byte", "string", "entry") | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это поле не используется нигде. Если что-то используется только в плагине, надо написать тесты на то, как это там используется. Если не используется нигде, удалить
| companion object { | ||
| val ignoreSet = setOf("int", "double", "boolean", "char", "float", "byte", "string", "entry") | ||
|  | ||
| val propertyNamesForNullFilter = setOf("data", "size") | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Аналогично (unused)
| val isPrimitive = !( | ||
| if (fullType != "Entry") (isContainer ?: false) | ||
| else true | ||
| ) | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullType != "Entry"     isContainer  Result
true                            true               false
true                            false or null   true
false                           true               false
false                           false or null   false
Это таблица для AND, значит всё это выражение можно упростить до isPrimitive = fullType!="Entry" && isContainer != true
| else true | ||
| ) | ||
|  | ||
| return SerializableTypeInfo(enumType, isPrimitive, fullType) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем нам тип передавать в двух видах? Честно говоря, выглядит стрёмно
|  | ||
| @Serializable | ||
| enum class Type { | ||
| Map, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Капсом лучше писать
| override val jreInfo: JREInfoProvider | ||
| get() = JavaRuntime | ||
|  | ||
| fun updateVariablesState(evaluator: InternalEvaluator) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a very internal method. We most likely don't want to expose it to user
| jupyterId = 3 | ||
| ) | ||
| state = repl.notebook.unchangedVariables | ||
| // tmp disable to further investigation (locally tests pass on java8) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also passes for me locally. I think ignoring is a bad solution
| jupyterId = 1 | ||
| ) | ||
| var state = repl.notebook.unchangedVariables | ||
| state.size.shouldBe(3) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, what do you test here? What variables should be contained in this list? What if this test fail, how will you understand what variables have changed without debugging?
| """.trimIndent(), | ||
| jupyterId = 1 | ||
| ) | ||
| var state = repl.notebook.unchangedVariables | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why do you need this variable? It's useless
| } | ||
|  | ||
| @Test | ||
| fun testAnonymousObjectRendering() { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the test from other file that was deleted
No description provided.