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

Use pycrdt instead of y-py #194

Merged
merged 4 commits into from
Dec 8, 2023
Merged

Conversation

davidbrochart
Copy link
Collaborator

@davidbrochart davidbrochart commented Oct 26, 2023

pycrdt is a new library providing Python bindings for Yrs. It speaks the "Y" protocol just like y-py, but has a different API.

@davidbrochart davidbrochart marked this pull request as draft October 26, 2023 13:55
@davidbrochart davidbrochart force-pushed the pycrdt branch 2 times, most recently from 37d82aa to 0404622 Compare October 26, 2023 13:57
@davidbrochart davidbrochart changed the title Use pycrdt instea of y-py Use pycrdt instead of y-py Oct 26, 2023
@davidbrochart davidbrochart force-pushed the pycrdt branch 5 times, most recently from 6ece654 to a66b51d Compare October 26, 2023 16:42
Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @davidbrochart for working on this. I was about to ask if the two libraries could be use transparently. But I'm seeing that it is definitely not possible.

I have a couple of comments.

@@ -55,7 +56,7 @@ def get(self) -> bytes:
:return: Document's content.
:rtype: bytes
"""
return base64.b64decode(self._ysource.get("base64", "").encode())
return base64.b64decode(self._ysource["base64"].encode())
Copy link
Member

Choose a reason for hiding this comment

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

does pycrdt add dynamically a requested key - what would be a bad idea. If not we cannot be sure base64 exists on _ysource.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, pycrdt doesn't create a key on read, and yes you're right I should put back the previous behavior. Thanks, I don't know why I changed it.

jupyter_ydoc/ybasedoc.py Show resolved Hide resolved
jupyter_ydoc/ynotebook.py Show resolved Hide resolved
@davidbrochart
Copy link
Collaborator Author

davidbrochart commented Oct 27, 2023

I was about to ask if the two libraries could be use transparently. But I'm seeing that it is definitely not possible.

It may be possible to create a wrapper around Ypy so that it has the same API as pycrdt, but at the same time pycrdt could evolve in a different direction in the future, so I'm not sure I should invest time in Ypy if in the end it's not possible for them to converge on the same API.

@echarles
Copy link
Member

echarles commented Nov 1, 2023

Linking here the discussion on jupyter-server/team-compass#55, I guess we first need to have an understanding and agreement on y-py/pycrdt before merging this PR.

@ericsnekbytes
Copy link

ericsnekbytes commented Nov 1, 2023

Are there any tangible user-benefits (for end users) for switching to pycrdt? It should be front of mind that there's a cost to switching libraries, and not just the initial development cycles.

  • How will build processes be affected by switching, unless there are zero impacts there?
  • What additional rust dependencies/binaries need to be added?
  • What any maintenance be expected in rust?
  • What documentation needs to be written for maintainers and contributors for the switch to pycrdt?

Adding extra languages, binaries, tools and workflows can be a burden on maintainers and increase complexity and difficulty for new contributors. We should have a COMPLETE understanding of the impacts before moving forward. The cost of increased complexity, added dependencies and workflows should not be accepted unless end users are going to see substantial benefits...

@davidbrochart
Copy link
Collaborator Author

davidbrochart commented Nov 1, 2023

I'm obviously doing this for the good of the project. Ypy is close to being unmaintained, part of the reason being its complexity. With pycrdt I want to make my life easier in order to improve collaborative editing in Jupyter.

@davidbrochart davidbrochart marked this pull request as ready for review December 8, 2023 15:02
@davidbrochart davidbrochart merged commit bd99898 into jupyter-server:main Dec 8, 2023
10 checks passed
@davidbrochart davidbrochart deleted the pycrdt branch December 8, 2023 15:13
@davidbrochart
Copy link
Collaborator Author

I'll release v2.0.0.

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

Successfully merging this pull request may close these issues.

5 participants