https://github.com/link89/streamlit-hotfix
A command line tool to provide advanced features (CDN, etc) for streamlit by apply patch to the installed packages.
https://github.com/link89/streamlit-hotfix
Last synced: 10 months ago
JSON representation
A command line tool to provide advanced features (CDN, etc) for streamlit by apply patch to the installed packages.
- Host: GitHub
- URL: https://github.com/link89/streamlit-hotfix
- Owner: link89
- License: apache-2.0
- Created: 2024-07-31T16:46:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-08T03:46:32.000Z (almost 2 years ago)
- Last Synced: 2025-02-02T00:47:34.462Z (over 1 year ago)
- Language: Python
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# streamlit-hotfix
[](https://badge.fury.io/py/streamlit-hotfix)
[](https://pypi.org/project/streamlit-hotfix/)
[](https://pypi.org/project/streamlit-hotfix/)
A command line tool to provide advanced features (CDN, etc) for streamlit by apply patch to the installed packages.
## Get started
```bash
pip install streamlit-hotfix
st-hotfix --help
```
For developer,
```
cd streamlit-hotfix
poetry install
python -m st_hotfix --help
```
Note that you have to install this tool in the same environment as streamlit and streamlit components you want to patch.
Otherwise, the patch may not work as expected.
## Examples
### Load streamlit assets from CDN
```bash
# dump assets to a folder
st-hotfix cdn dump streamit ./path/to/streamlit-assets
# now you can distribut streamlit-assets with CDN, for example jsDelivr
# e.g: https://cdn.jsdelivr.net/gh/link89/assets@0.1.0/cdn/streamlit/
# then you can patch streamlit to load assets from CDN
st-hotfix cdn patch streamlit --cdn_url https://cdn.jsdelivr.net/gh/link89/assets@0.1.0/cdn/streamlit/
```
Now when you run your streamlit app, it will load assets from the CDN.
Note that the CDN tool makes use of the on-the-fly mode of webpack publicPath.
Since `streamlit` 1.36.0, the publicPath of streamlit frontend can be override in runtime by setting `window.____WEBPACK_PUBLIC_PATH_OVERRIDE`.
If the components are not allow to change the publicPath on-the-fly,
you have to patch them first by yourself before using this tool to patch it with CDN URL.
For example: https://github.com/mik-laj/streamlit-ketcher/pull/120/files
You can always revert the patch by running
```bash
st-hotfix cdn restore streamlit
```