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 YNotebook get_cell, set_cell, append_cell #35

Merged
merged 1 commit into from
Jul 27, 2022
Merged

Conversation

davidbrochart
Copy link
Collaborator

Fixes #34.

def _put_cell(self, index: int, ycell: Y.YMap, txn):
if len(self._ycells) >= index + 1:
self._ycells.delete(txn, index)
self._ycells.insert(txn, index, ycell)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Waidhoferj I'm not sure to understand the error message:

y_py.MultipleIntegrationError: Cannot integrate a nested Ypy object because is already integrated into a YDoc: {'source': YText(print('Hello, World!')), 'execution_count': None, 'metadata': YMap({}), 'outputs': YArray([]), 'id': None, 'cell_type': 'code'}

The YMap I'm trying to insert into a YArray is not part of a YDoc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My bad, I think it was on my side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually I think there is a bug in ypy. It doesn't happen in the CI, but locally I have the error above at this line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Waidhoferj ypy HEAD doesn't seem to fix this one.

Choose a reason for hiding this comment

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

Working on it

Choose a reason for hiding this comment

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

@davidbrochart Having trouble reproducing the issue. I've run a couple tests pushing preliminary Y elements into an array.

def test_multiple_integration():
    d = Y.YDoc()
    wrapper = d.get_array("wrapper")
    inner = Y.YMap({"foo": "bar"})
    with d.begin_transaction() as txn:
        wrapper.append(txn, inner) # I'd expect an error here

Tried to set up the repository, but I'm having dependency issues related to ypy-websockets.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I cannot reproduce the issue either.
Do you want to release ypy?

Choose a reason for hiding this comment

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

Definitely, just release 0.5.3

@davidbrochart davidbrochart changed the title Add YNotebook get_cell and set_cell Add YNotebook get_cell, set_cell, append_cell Jul 10, 2022
@davidbrochart davidbrochart force-pushed the get_set_cell branch 2 times, most recently from 1ade0ee to e0409a1 Compare July 10, 2022 16:29
@davidbrochart davidbrochart force-pushed the get_set_cell branch 2 times, most recently from 9256927 to f9fe1c6 Compare July 27, 2022 07:38
@davidbrochart davidbrochart merged commit 41a1ad1 into main Jul 27, 2022
@davidbrochart davidbrochart deleted the get_set_cell branch July 27, 2022 07:58
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.

Get/set notebook cell
2 participants