Skip to content

Commit

Permalink
Vendor pympler.asizeof (streamlit#7193)
Browse files Browse the repository at this point in the history
* Vendor pympler.asizeof module

* Remove pympler from min constraints

* Explain differences from original asizeof module

* include

* Ignore mypy errors within asizeof.py

* Fix asizeof usage in cache_resource_api

* Have CodeQL ignore vendored Python code

---------

Co-authored-by: SimonBiggs <simon@anthropic.com>
Co-authored-by: Vincent Donato <vincent@streamlit.io>
  • Loading branch information
3 people authored and zyxue committed Apr 16, 2024
1 parent c9bb821 commit c2e466f
Show file tree
Hide file tree
Showing 9 changed files with 2,875 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/codeql-config.yml
Expand Up @@ -5,3 +5,4 @@ paths:
paths-ignore:
- "frontend/lib/src/vendor/**"
- "frontend/app/src/vendor/**"
- "lib/streamlit/vendor/**"
1 change: 0 additions & 1 deletion lib/min-constraints-gen.txt
Expand Up @@ -11,7 +11,6 @@ pillow==7.1.0
protobuf==3.20
pyarrow==6.0
pydeck==0.8.0b4
pympler==0.9
python-dateutil==2.7.3
requests==2.18
rich==10.14.0
Expand Down
1 change: 0 additions & 1 deletion lib/setup.py
Expand Up @@ -51,7 +51,6 @@
# doesn't tend to break the API on major version upgrades, so we don't put an
# upper bound on it.
"pyarrow>=6.0",
"pympler>=0.9, <2",
"python-dateutil>=2.7.3, <3",
"requests>=2.18, <3",
"rich>=10.14.0, <14",
Expand Down
4 changes: 2 additions & 2 deletions lib/streamlit/runtime/caching/cache_resource_api.py
Expand Up @@ -23,7 +23,6 @@
from typing import Any, Callable, TypeVar, cast, overload

from cachetools import TTLCache
from pympler import asizeof
from typing_extensions import TypeAlias

import streamlit as st
Expand All @@ -49,6 +48,7 @@
from streamlit.runtime.metrics_util import gather_metrics
from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx
from streamlit.runtime.stats import CacheStat, CacheStatsProvider
from streamlit.vendor.pympler.asizeof import asizeof

_LOGGER = get_logger(__name__)

Expand Down Expand Up @@ -567,7 +567,7 @@ def get_stats(self) -> list[CacheStat]:
CacheStat(
category_name="st_cache_resource",
cache_name=self.display_name,
byte_length=asizeof.asizeof(entry),
byte_length=asizeof(entry),
)
for entry in cache_entries
]
2 changes: 1 addition & 1 deletion lib/streamlit/runtime/legacy_caching/caching.py
Expand Up @@ -40,7 +40,6 @@
)

from cachetools import TTLCache
from pympler.asizeof import asizeof

import streamlit as st
from streamlit import config, file_util, util
Expand All @@ -58,6 +57,7 @@
)
from streamlit.runtime.metrics_util import gather_metrics
from streamlit.runtime.stats import CacheStat, CacheStatsProvider
from streamlit.vendor.pympler.asizeof import asizeof

_LOGGER = get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion lib/streamlit/runtime/state/session_state.py
Expand Up @@ -28,7 +28,6 @@
cast,
)

from pympler.asizeof import asizeof
from typing_extensions import Final, TypeAlias

import streamlit as st
Expand All @@ -45,6 +44,7 @@
)
from streamlit.runtime.stats import CacheStat, CacheStatsProvider
from streamlit.type_util import ValueFieldName, is_array_value_field_name
from streamlit.vendor.pympler.asizeof import asizeof

if TYPE_CHECKING:
from streamlit.runtime.session_manager import SessionManager
Expand Down
Empty file.

0 comments on commit c2e466f

Please sign in to comment.