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

Enable integrations with App Frameworks #35

Open
MarcSkovMadsen opened this issue Nov 26, 2024 · 2 comments
Open

Enable integrations with App Frameworks #35

MarcSkovMadsen opened this issue Nov 26, 2024 · 2 comments

Comments

@MarcSkovMadsen
Copy link

MarcSkovMadsen commented Nov 26, 2024

As you can see in #34 and #16 there is a demand for supporting non-Jupyter use cases. I believe any Data App framework looking at this package would like to support it. So for example also Streamlit, Gradio, Dash, etc. I'm here for the Panel support 😄.

There are some things that make integrations tough in general.

Dependencies

Forced import of ipyreact, IPython and more. We don't need them.

I tried installing

pip install reactable htmltools --no-deps

and then running

import htmltools
from reactable import CellInfo, Column, Reactable
from reactable.data import cars_93

to see how far I could get. I gave up at

 uv pip install reactable htmltools typing-extensions packaging databackend ipyreact traitlets ipywidgets ipython --no-deps

I.e. there is a very strong assumption that this should be used in ipy/ jupyter ecosystem. This should be removed - especially to enable minimal loading times in pyodide.

Serialization of data

You force serialize the DataFrame data, i.e. Frameworks like Panel that can transfer more efficiently than plain dict/ list/ json will have to deserialize and transfer. It slows down things.

We would like to be able to do

data = reactable.get_data() # this can be big. Should be in original, native format. Let framework serialize.
other_props = reactable.get_other_props() # this is not so big. Can be dict.

Also because not all properties might change and we would like to transfer only the changed ones for efficiency reasons.

@machow
Copy link
Owner

machow commented Nov 26, 2024

(edit: I just saw #33, which gave super helpful context. My comments below are on switching to anywidget for general app support. But the Panel example made that integration with reactable-py super clear!)

Hey @MarcSkovMadsen, thanks for looking into these things. I would love to support integration with the broader app ecosystem! The biggest challenge right now--which you noted--is that reactable currently uses (and requires) ipyreact.

From looking a bit with @schloerke, it shouldn't be too tricky to switch to using anywidget directly. Here are some high-level pieces that it sounds like might be involved in integrating with Panel. I think the one where I might need a bit more context on is what avoiding data serialization might look like (both on the back and frontend).

Removing ipyreact

Forced import of ipyreact, IPython and more. We don't need them.

ipyreact is necessary currently. ipyreact subclasses anywidget, which we should be able to use directly. However, there are two key challenges with that approach currently:

Data serialization

You force serialize the DataFrame data, i.e. Frameworks like Panel that can transfer more efficiently than plain dict/ list/ json will have to deserialize and transfer. It slows down things.

Can you say more about this? reactable is react on the frontend, so while the data is serialized to produce the initial react element, you could produce the initial table without any table cell data if you wanted.

The data does not have to be serialized. For example, if someone created new concrete functions for a class like...

from reactable._tbl_data import to_dict, column_names, col_type

class NonSerializedFrame:
    def __init__(self, d: pd.DataFrame):
        self.d = d

@to_dict.register
def _(d: NonSerializedFrame):
    # return w/e the initial state of the table should be
    # if this returned no rows of data, something on the frontend would have to be
    # responsible for updating the react component
    ...

@column_names.register
def _(d: NonSerializedFrame):
    # return column names
    ...

One hitch is that reactable enables people to do formatting via Python. In this case, it sounds like those mechanisms wouldn't work.

@MarcSkovMadsen
Copy link
Author

MarcSkovMadsen commented Nov 26, 2024

For the data serialization comment. I do believe you serialize in

self.data = process_data(self.data)
. This can be costly for larger or many dataframes if its not to be used by the App framework because they do their own serialization to arrow, Bokeh ColumnDataSource, protobuf or similar.

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

No branches or pull requests

2 participants