mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
710 stars 53 forks source link

download table using buttons feature errors out #251

Open Dekermanjian opened 3 months ago

Dekermanjian commented 3 months ago

I have a table that is relatively small ~16,000 rows and 17 columns. When I try downloading the table I get the following error:

Uncaught RangeError: Maximum call stack size exceeded

Playing around with the table looks like the maximum number of rows I can download is ~7000, but also I can download all the rows if I exclude a bunch of columns.

Any ideas on what is going on here?

mwouts commented 3 months ago

Hey @Dekermanjian , thanks for reaching out. Which browser are you using? Can you share an example?

I did a quick google search and I found this: https://datatables.net/forums/discussion/68594/error-uncaught-rangeerror-maximum-call-stack-size-exceed-in-new-version-of-chrome-91-0-4472-77, which is probably related (but not very conclusive, an MRE would be required to further investigate).

Dekermanjian commented 3 months ago

Hey @mwouts thank you for the quick response. I was using Google Chrome I also tried Microsoft Edge. Let me see if I can generate a reproducible example because my actual dataset has patient sensitive data.

mwouts commented 3 months ago

Yes sure! By the way you can generate a sample df with generate_random_df if that helps. Thanks!

Dekermanjian commented 3 months ago

Hey here is a quick reproducible example I put together. I also tried it using Safari on a MacOS and I have the same issue. This is being inserted into a quarto Reveal.js presentation by the way.

I am having a hard time pasting the code without the markdown and cells being altered by GitHub. I hope this is clear:

---
title: "Test"
author: "TestAuthor"
date: last-modified
format:
  revealjs:
    controls: true
    scrollable: true
    smaller: false
    embed-resources: true
    height: 950
    width: 2000
execute:
  echo: false
jupyter: python3
---

```{python Imports}
#| include: false
import pandas as pd
import numpy as np
from itables import init_notebook_mode
from itables import JavascriptFunction
from itables import show
import itables.options as opt
opt.style = "table-layout:auto;width:100%"
opt.css = """
.itables table td {font-size: 20px;}
.itables table th {font-size: 20px;}
"""
opt.maxBytes = 0
opt.dom = "frtip"
# pio.renderers.default = "notebook"
df = pd.DataFrame(np.random.rand(16000, 20))

Slide title

#| include: true
init_notebook_mode(all_interactive=True, connected=False)
opt.dom = "Bfrtip"
show(
  df,
  lengthMenu=[17]
)
mwouts commented 3 months ago

Thanks for the example! In Ubuntu/Firefox I can download the test data without any issue: image

But then when I open the same document in Chromium the download never happens.

@AllanJard I am attaching the HTML document if you wanted to give a quick look? Thanks! download_csv_excel_slow_or_fails_in_chrome.zip

Dekermanjian commented 3 months ago

Hmm okay let me try Firefox.

Dekermanjian commented 3 months ago

I can confirm that is working on Firefox on MacOS. Any idea why Chrome fails?

mwouts commented 3 months ago

No sorry - ITables is just a wrapper to DataTables, authored and maintained by Allan and his team, but at least now we have an example, so let's see what he finds!

Dekermanjian commented 3 months ago

Okay, thank you very much for the quick response!

AllanJard commented 3 months ago

Chrome is showing me Maximum call stack sizer exceeded. I can reproduce that with a manual call to .cells().render() in that example. The 16000 rows * 20 cells, must be just enough to trigger this behaviour in Chrome (Firefox must have a higher threshold).

I'll need to find some way of changing how the API operates to make things faster, which I already knew, I just hadn't seen it quite like this. I can't say when I'll get a chance to do that as I think it will be quite a major piece of work.

mwouts commented 3 months ago

Thanks @AllanJard for looking into this! No worry, at least we have identified a workaround so far (show less rows / use Firefox).

What is the best way to get an update for these kind of fixes? I registered to watch the releases of https://github.com/DataTables/DataTables but maybe there is another way?

AllanJard commented 2 months ago

Sorry for the delay replying here! The DataTables/DataTables repo is legacy and no longer updated. All the action happens in [DataTables/DataTablesSrc](/DataTables/DataTablesSrc]. I've got an RSS feed for releases, or a JSON API if you prefer. I've also been experimenting with posting on BlueSky.