Skip to content
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

Add Serializable Vars State with nested fields descriptors #314

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

nikolay-egorov
Copy link
Contributor

No description provided.

@nikolay-egorov nikolay-egorov requested a review from ileasile July 22, 2021 14:04
@nikolay-egorov nikolay-egorov self-assigned this Jul 22, 2021
@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch 2 times, most recently from 434f8e4 to 54cc8ed Compare July 24, 2021 21:00
@nikolay-egorov nikolay-egorov linked an issue Jul 26, 2021 that may be closed by this pull request
Copy link
Contributor

@ileasile ileasile left a 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)

@nikolay-egorov
Copy link
Contributor Author

nikolay-egorov commented Jul 27, 2021

empty map should be sent in metadata

Maybe not empty, but just one-depth stringed values as it was before?

@ileasile
Copy link
Contributor

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.

@nikolay-egorov
Copy link
Contributor Author

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

@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch 4 times, most recently from 90c8b39 to e050cb6 Compare July 28, 2021 14:31
Copy link
Contributor

@ileasile ileasile left a 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

@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch from 1a5a0c4 to 8cfc15e Compare August 3, 2021 10:02
@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch 3 times, most recently from c14a522 to 961a320 Compare August 12, 2021 08:22
@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch 6 times, most recently from 5820ba6 to 39aa087 Compare August 20, 2021 16:01
@ileasile ileasile force-pushed the serializable-vars-state branch from bd39684 to 001534c Compare September 13, 2021 18:00
@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch 4 times, most recently from f16ffa0 to f347d0f Compare September 14, 2021 18:06
}
}

class ReplVarsSerializationTest : AbstractSingleReplTest() {
Copy link
Contributor

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?
Copy link
Contributor

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
Copy link
Contributor

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),
Copy link
Contributor

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
Copy link
Contributor

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
@@ -12,6 +12,8 @@ plugins {

val deploy: Configuration by configurations.creating

val serializationFlagProperty = "jupyter.serialization.enabled"
Copy link
Contributor

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

@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch 2 times, most recently from 17ffdfd to d0d5a1d Compare November 25, 2021 15:17
…iptors right away, not through 'size' and 'data' fields
@nikolay-egorov nikolay-egorov force-pushed the serializable-vars-state branch from d0d5a1d to ef7df1e Compare December 6, 2021 08:19
Copy link
Contributor

@ileasile ileasile left a 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")
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично (unused)

Comment on lines +33 to +37
val isPrimitive = !(
if (fullType != "Entry") (isContainer ?: false)
else true
)

Copy link
Contributor

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)
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Капсом лучше писать

@@ -149,6 +152,11 @@ class NotebookImpl(
override val jreInfo: JREInfoProvider
get() = JavaRuntime

fun updateVariablesState(evaluator: InternalEvaluator) {
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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

@@ -318,4 +321,121 @@ class ReplVarsTest : AbstractSingleReplTest() {
varState.getStringValue("x") shouldBe "25.0"
varState.getValue("x") shouldBe 25.0
}

@Test
fun testAnonymousObjectRendering() {
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variables descriptors
2 participants