You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is a trivial question or not, but i've been trying to load in a ydoc binary from a file on disk to no success. So far I've tried:
local_doc = YDoc()
def get_fbytes(fpath):
with open(fpath, 'rb') as f:
return f.read()
sv = get_fbytes(FNAME)
apply_update(local_doc, sv)
and then getting elements out of local_doc. However, this is not working.
How can I load in and work with a ydoc from a file? Also, what is the recommended way of going through the elements of a ydoc? I saw another issue that suggests there's no good interface for this via ypy yet. If this is the case, how can we check if a key exists? Since all the get_{text, array, ...} methods will create the element if it doesn't already exist.
If someone can point me in the right direction for where to make these changes to support this in the library, i'd be happy to make a PR.
Thanks!
The text was updated successfully, but these errors were encountered:
ihasdapie
changed the title
read in ydoc binary
How to read in ydoc binary from file?
Mar 25, 2024
@ihasdapie, assuming your file was created with contents generated by y_py.encode_state_as_update(y_doc), here's how our project settled on reading data from file into YDoc:
y_doc=y_py.YDoc()
# file is getting its contents from google cloud storage blob is a google cloud storage blob, so you need to adjust this section to your circumstancesephemeral_file=io.BytesIO()
blob.download_to_file(ephemeral_file)
ephemeral_file.seek(0)
current_serialized_state: y_py.YDocUpdate=ephemeral_file.read()
y_py.apply_update(y_doc, current_serialized_state)
Not sure if this is a trivial question or not, but i've been trying to load in a ydoc binary from a file on disk to no success. So far I've tried:
and then getting elements out of
local_doc
. However, this is not working.How can I load in and work with a ydoc from a file? Also, what is the recommended way of going through the elements of a ydoc? I saw another issue that suggests there's no good interface for this via ypy yet. If this is the case, how can we check if a key exists? Since all the
get_{text, array, ...}
methods will create the element if it doesn't already exist.If someone can point me in the right direction for where to make these changes to support this in the library, i'd be happy to make a PR.
Thanks!
The text was updated successfully, but these errors were encountered: