forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to apply automatic dataframe truncation (streamlit#8002)
* Add prototype for auto dataframe truncation * Update solution * Fix nbytes * Clean up dimensions * Refactor data dimensions * Update warning message * Removed unused import * Add comment * Fix test * Add unit test * Update tests * Finalize e2e tests * Rename to arrow truncation * Add license header * Rename * Update decorator usage * Double the rows * Temp: try with dataframe only * Change count * Fix test * Finalize e2e test * Fix tests * Add some prints * Add more prints * Fix copy paste error * Some refactoring * Fix type util test * Use higher pyarrow version * Fix type util * Update pyarrow min constraint * Fix warning * Apply more updates * Remove comment * Fix issue * Remove print * Apply comment
- Loading branch information
1 parent
f4684e2
commit 2a29dab
Showing
10 changed files
with
285 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
import streamlit as st | ||
|
||
np.random.seed(0) | ||
|
||
df = pd.DataFrame(np.random.randn(50000, 20), columns=("col %d" % i for i in range(20))) | ||
|
||
st.dataframe(df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
|
||
import pytest | ||
from playwright.sync_api import Page, expect | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
@pytest.mark.early | ||
def configure_arrow_truncation(): | ||
"""Configure arrow truncation and max message size.""" | ||
os.environ["STREAMLIT_SERVER_ENABLE_ARROW_TRUNCATION"] = "True" | ||
os.environ["STREAMLIT_SERVER_MAX_MESSAGE_SIZE"] = "3" | ||
yield | ||
del os.environ["STREAMLIT_SERVER_ENABLE_ARROW_TRUNCATION"] | ||
del os.environ["STREAMLIT_SERVER_MAX_MESSAGE_SIZE"] | ||
|
||
|
||
def test_shows_limitation_message(app: Page, configure_arrow_truncation): | ||
caption_elements = app.get_by_test_id("stCaptionContainer") | ||
expect(caption_elements).to_have_count(1) | ||
expect(caption_elements.nth(0)).to_have_text( | ||
"⚠️ Showing 12k out of 50k rows due to data size limitations. " | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.