Make it possible to run the playground directly

It can now be run with:

    python -m streamlit run riffusion/streamlit/playground.py
    python riffusion/streamlit/playground.py
    python -m riffusion.streamlit.playground

Which adds a ton of flexibility.
This commit is contained in:
Hayk Martiros 2023-03-26 23:29:14 +00:00
parent a0f12d80e2
commit 754c9f8f64
2 changed files with 11 additions and 3 deletions

View File

@ -124,7 +124,7 @@ Riffusion contains a [streamlit](https://streamlit.io/) app for interactive use
Run with:
```
python -m streamlit run riffusion/streamlit/playground.py --browser.serverAddress 127.0.0.1 --browser.serverPort 8501
python -m riffusion.streamlit.playground
```
And access at http://127.0.0.1:8501/

View File

@ -1,4 +1,8 @@
import sys
import streamlit as st
import streamlit.web.cli as stcli
from streamlit import runtime
PAGES = {
"🎛️ Home": "tasks.home",
@ -12,7 +16,7 @@ PAGES = {
}
def main() -> None:
def render() -> None:
st.set_page_config(
page_title="Riffusion Playground",
page_icon="🎸",
@ -26,4 +30,8 @@ def main() -> None:
if __name__ == "__main__":
main()
if runtime.exists():
render()
else:
sys.argv = ["streamlit", "run"] + sys.argv
sys.exit(stcli.main())