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

Lazy-load pandas and pyarrow to improve performance #8125

Merged
merged 5 commits into from Feb 9, 2024

Conversation

LukasMasuch
Copy link
Collaborator

@LukasMasuch LukasMasuch commented Feb 9, 2024

Describe your changes

Lazy-load pandas and pyarrow only when required (e.g. usage of st.dataframe).

This PR also includes a couple of other small refactorings related to typing and imports.

GitHub Issue Link (if applicable)

Related to #6066

Testing Plan

  • Added e2e test to ensure that pyarrow and pandas are lazy-loaded.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@LukasMasuch LukasMasuch changed the title Lazy-load pandas and pyarrow modules Lazy-load pandas and pyarrow to improve performance Feb 9, 2024
_PILLOW_RE: Final = re.compile(r"^PIL\..*")


def is_pillow_image(obj: object) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasMasuch do we need this function as part of this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, good catch. Not really, for this specific PR. But for another lazy-loading PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge with this method for now, since I anyways will wrap up the other PR that needs it today. And it our CI doesn't work right now I would do another commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasMasuch LukasMasuch merged commit 1995def into develop Feb 9, 2024
38 checks passed
@vdonato vdonato deleted the refactor/lazy-load-pandas branch February 10, 2024 02:56
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
## Describe your changes

Lazy-load `pandas` and `pyarrow` only when required (e.g. usage of
`st.dataframe`).

This PR also includes a couple of other small refactorings related to
typing and imports.

## GitHub Issue Link (if applicable)

Related to streamlit#6066

## Testing Plan

- Added e2e test to ensure that `pyarrow` and `pandas` are lazy-loaded. 
---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants