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

to_json() generates updates #94

Open
davidbrochart opened this issue Nov 17, 2022 · 4 comments · May be fixed by #104
Open

to_json() generates updates #94

davidbrochart opened this issue Nov 17, 2022 · 4 comments · May be fixed by #104

Comments

@davidbrochart
Copy link
Collaborator

davidbrochart commented Nov 17, 2022

The following example shows that calling to_json() actually generates an update:

import y_py as Y

ydoc = Y.YDoc()
a = ydoc.get_array("a")

def cb(event):
    print("update:", event.get_update())

ydoc.observe_after_transaction(cb)
print("a =", a.to_json())

# update: b'\x00\x00'
# a = []

For a notebook document, it can generate quite a lot of them.
I am surprised that it happens for an action that doesn't modify the document. Is it expected? What do these updates correspond to?

cc @ellisonbg

@ellisonbg
Copy link

Hmm, that is a good mystery...

@davidbrochart
Copy link
Collaborator Author

@dmonad any idea?

@davidbrochart
Copy link
Collaborator Author

@Horusiath @Waidhoferj ?

@chwzr
Copy link

chwzr commented Nov 25, 2022

Calling Y.encode_state_vector() is also producing empty updates:

import y_py as Y

ydoc = Y.YDoc()

def cb(event):
    print("update:", event.get_update())

ydoc.observe_after_transaction(cb)

state = Y.encode_state_vector(ydoc)

will print:

update: b'\x00\x00'

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 a pull request may close this issue.

3 participants