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

No display for DT::datatable in Google Colab. No error either. #720

Open
3 of 4 tasks
rohitfarmer opened this issue Oct 14, 2022 · 8 comments
Open
3 of 4 tasks

No display for DT::datatable in Google Colab. No error either. #720

rohitfarmer opened this issue Oct 14, 2022 · 8 comments

Comments

@rohitfarmer
Copy link

rohitfarmer commented Oct 14, 2022

Hi, I am working with an R runtime on Google Colab, and I am trying display DT::datatable the way it works in a Jupyter notebook. My code executes without an error, and even though the execution pushes the next cell to make space for the table, there is no table display. I am unsure if it's an issue with Google Colab, IRkernel, DT::datable, or a combination.

The code below works in a Jupyter notebook but not on Google Colab.

library(DT)
DT::datatable(iris, options = list(pageLength = 5))

Any suggestions would be helpful. Thanks!

@flying-sheep
Copy link
Member

flying-sheep commented Oct 17, 2022

I can’t reproduce that, and since you deleted the issue template I have no way to know if you’re using the newest version or not.

Please don’t delete issue templates and fill them out instead. They’re there for a reason.

grafik

@flying-sheep flying-sheep added the needs info The reported information is incomplete label Oct 17, 2022
@rohitfarmer
Copy link
Author

I can’t reproduce that, and since you deleted the issue template I have no way to know if you’re using the newest version or not.

Please don’t delete issue templates and fill them out instead. They’re there for a reason.

grafik

Thank you, I have updated the post and included the issue template. I think. As I mentioned, the code works in a Jupyter notebook on my local computer, but it doesn't work on Google Colab notebook.

@flying-sheep flying-sheep removed the needs info The reported information is incomplete label Oct 18, 2022
@flying-sheep
Copy link
Member

They seem to be stripping out <script> tags from HTML output. Probably has to do with their security.

DT currently renders as a htmlwidget. This bug might be possble to fix by adding an official jupyterlab extension for htmlwidgets and have colab support that.

@rohitfarmer
Copy link
Author

They seem to be stripping out <script> tags from HTML output. Probably has to do with their security.

DT currently renders as a htmlwidget. This bug might be possble to fix by adding an official jupyterlab extension for htmlwidgets and have colab support that.

Okay, that makes sense. However, Google Colab has from google.colab import data_table for Python, which works similarly to DT::datatable. I think it uses the same datatable library under the hood. Somehow, they made it work for their library but not the R package.

@flying-sheep
Copy link
Member

Well, they’re doing things a bit differently, but our approach here works. E.g. we use the "isolated": true cell metadata. Maybe colab can’t handle that, or something else.

Did you file this issue in their bug tracker?

@rohitfarmer
Copy link
Author

I have not filed this issue in the Colab bug tracker yet. However, I did it at rstudio/DT#1025. So I will now do that in Colab also and link this thread. Thank you for thinking about this for me.

@flying-sheep
Copy link
Member

No problem! I spend quite some time learning the ins and outs of Jupyter Lab’s display machinery, but I’d prefer if the colab people would weigh in on how things are different over there.

@blois
Copy link

blois commented Nov 11, 2022

I'm looking into this issue from the Colab side- the scripts are being evaluated but one thing I see is that because of the timing this code:
https://github.com/ramnathv/htmlwidgets/blob/cb052ac613ffe13bd6a3f4b6e9333002e72b59d8/inst/www/htmlwidgets.js#L706

Is being executed after DOMContentLoaded has triggered. In this case a check for document.readyState == 'complete' gets a bit further, but still doesn't complete.

Comparing to JupyterLab, I'm also seeing that the table doesn't render on notebook reload. All of the scripts look like they should be in place to render there. Possibly related?

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

3 participants