-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Labels
Milestone
Description
Here below is a short example that hangs my browser.
I've two panels, with a large dataset (20cols, 5000 rows).
- Switching between the panels -> no problem
- Editing cells in one panel -> no problem
- Editing cells in one panel, then switching to the other panel -> Browser Hangs, CPU usage to the roof.
I'm attaching the code to create the fake dataset and the code that creates the problem.
I tried running in Shiny Live, sometimes it hangs and sometimes it takes a long time to switch the tab. I can't share the Shiny Live link as it is too long. (and can't use the faker
library on Shiny Live).
I'm using shiny==0.10.2
Please try by
- create the large fake dataset, then
- run the app.py
Large Fake dataset creation
The dataset is fake. It is created using the Faker library.
from faker import Faker
import pandas as pd
#penguins = load_penguins()
def fakeDS():
fake = Faker()
df1 = pd.DataFrame([{
'Name': fake.name(),
'Email': fake.email(),
'Address': fake.address(),
'Job': fake.job(),
'Company': fake.company(),
'Phone Number': fake.phone_number(),
'City': fake.city(),
'Country': fake.country(),
'Text': fake.text(),
'Date': fake.date(),
'Latitude': fake.latitude(),
'Longitude': fake.longitude(),
'CreditCardNumber': fake.credit_card_number(),
'CreditCardProvider': fake.credit_card_provider(),
'CreditCardExpire': fake.credit_card_expire(),
'Currency': fake.currency_code(),
'Price': fake.pydecimal(left_digits=3, right_digits=2, positive=True),
'Password': fake.password(),
'URL': fake.url(),
}
for _ in range(5000)
])
df1.to_json('fakeds.json')
df2 = pd.read_json('fakeds.json')
App.py that shows the issue
from pathlib import Path
from palmerpenguins import load_penguins
from shiny import App, render, ui, reactive, Outputs
import pandas as pd
infile = Path(__file__).parent / 'fakeds.json'
print("reading")
df1=pd.read_json(infile)
df2=df1.copy()
print("done reading")
app_ui = ui.page_fluid(
ui.page_navbar(
ui.nav_panel(
"A",
ui.h2("Fake data 1"),
ui.input_action_button('click1','click1'),
ui.div(
ui.output_data_frame("table_df1"),
style="width:100%; font-size: small; padding: 0"
)
),
ui.nav_panel("B",
ui.h2("Fake data 2"),
ui.input_action_button('click2','click'),
ui.div(
ui.output_data_frame("table_df2"),
style="width:100%; font-size: small; padding: 0"
)
),
)
)
def server(input, output, session):
@render.data_frame
def table_df1():
return render.DataTable(df1, editable=True,height='1000px')
@render.data_frame
def table_df2():
return render.DataTable(df2, editable=True,height='1000px')
app = App(app_ui, server)