-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Enable editing to mime renderer in JupyterLab #1353
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
Conversation
|
Also - this is a really cool feature! |
e07d6da to
9e1b052
Compare
5bb5885 to
032c843
Compare
|
@texodus redid this on top of your fixes and its working fine, ready for review |
texodus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Looks good -
- Does the arrow output work? On first sight it looks suspect, I will test this.
- It may be prohibitively expensive to save on every cell edit, the mime renderer may benefit form a small control panel with "update/reset" and "save/submit" buttons?
| } else if (this._type === "arrow") { | ||
| view.to_arrow().then((result: ArrayBuffer) => { | ||
| const resultAsB64 = btoa(new Uint8Array(result).reduce((acc, i) => (acc += String.fromCharCode.apply(null, [i])), "")); | ||
| this.context.model.fromString(resultAsB64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do - this creates an arrow and not a base64 encoded string in a text file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep the key is in a different code block where we tell jupyter to open arrow files as binary which means they're exposed in the model as b64 encoded strings and the underlying conversion to/from binary is managed for us https://github.com/finos/perspective/blob/master/packages/perspective-jupyterlab/src/ts/renderer.ts#L168
07caff0 to
eb0b955
Compare

This is a simple modification that turns on editing for our JupyterLab mime renderer plugin (the thing that lets you right click on a
csv,json, orarrowand visualize in perspective). As a result, we now have a pivotable, sortable, filterable, editable csv/json/arrow viewer.