Skip to content

Commit

Permalink
Use cache_resource if available to avoid deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
blackary committed Feb 23, 2023
1 parent d62d6f4 commit 35c7006
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Releases](https://img.shields.io/pypi/v/st-pages)](https://pypi.org/project/st-pages/)
[![Build Status](https://img.shields.io/github/actions/workflow/status/blackary/st_pages/testing.yml?branch=main)](https://github.com/blackary/st_pages/actions?query=workflow%3A%22testing%22+branch%3Amain)
![Python Versions](https://img.shields.io/pypi/pyversions/st_pages.svg)
![Streamlit versions](https://img.shields.io/badge/streamlit-1.10.0--1.15.0-white.svg)
![Streamlit versions](https://img.shields.io/badge/streamlit-1.15.0--1.18.0-white.svg)
![License](https://img.shields.io/github/license/blackary/st_pages)
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

Expand Down
7 changes: 6 additions & 1 deletion src/st_pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def page_icon_and_name(script_path: Path) -> tuple[str, str]:
return name, icon


try:
from streamlit import cache_resource
except ImportError:
from streamlit import experimental_singleton as cache_resource

from streamlit.util import calc_md5


Expand Down Expand Up @@ -80,7 +85,7 @@ def _add_page_title(add_icon: bool = True, also_indent: bool = True):
add_page_title = _gather_metrics("st_pages.add_page_title", _add_page_title)


@st.experimental_singleton
@cache_resource
def get_icons() -> dict[str, str]:
url = "https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json"
return requests.get(url).json()
Expand Down
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
[tox]
envlist = py{38,39,310}-streamlit{12,13,14,15,16,17}
envlist = py{38,39,310}-streamlit{15,16,17,18}
isolated_build = True

[testenv]
deps =
pytest
pytest-playwright
protobuf==3.20.3
streamlit12: streamlit==1.12.0
streamlit13: streamlit==1.13.0
streamlit14: streamlit==1.14.0
streamlit15: streamlit==1.15.0
streamlit16: streamlit==1.16.0
streamlit17: streamlit==1.17.0
streamlit18: streamlit==1.18.0
commands:
playwright install
pytest --browser chromium

[tox:.package]
Expand Down

0 comments on commit 35c7006

Please sign in to comment.