Skip to content

Commit

Permalink
make .streamlit/secrets.toml optional (users dont need it), other p…
Browse files Browse the repository at this point in the history
…edantry and remove `stream_wars` component in docs (cannot build nor run frontend server in streamlit cloud
  • Loading branch information
murilo-cunha committed Nov 27, 2022
1 parent c231952 commit e47d43e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
- name: Bump package version
run: |
poetry version ${{ needs.get-new-tag.outputs.tag-id }}
echo '__version__ = "${{ needs.get-new-tag.outputs.tag-id }}"' > stream_wars/_version.py
- name: Build frontend
run: |
cd stream_wars/frontend &&
Expand Down
11 changes: 7 additions & 4 deletions stream_wars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import streamlit.components.v1 as components
from streamlit.components.v1.components import CustomComponent

_RELEASE = st.secrets.get("STREAMLIT_RELEASE", True)
if Path(".streamlit/secrets.toml").is_file():
_RELEASE = st.secrets.get("STREAMLIT_RELEASE", True)
else:
_RELEASE = True

project = Path(__file__).parent
__version__ = version(project.stem)
_project = Path(__file__).parent
__version__ = version(_project.stem)

if _RELEASE:
build_dir = project / "frontend" / "build"
build_dir = _project / "frontend" / "build"
_stream_wars = components.declare_component("stream_wars", path=build_dir)
else:
_stream_wars = components.declare_component(
Expand Down
2 changes: 0 additions & 2 deletions stream_wars/_version.py

This file was deleted.

49 changes: 25 additions & 24 deletions stream_wars/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,32 @@
import streamlit as st
from docstring_parser import parse

from stream_wars import project, stream_wars
from stream_wars import _project, stream_wars

st.markdown((project.parent / "README.md").read_text(), unsafe_allow_html=True)
st.header("Demo")
(txt_input,) = (
st.text_input(
"Tell a story",
value=(
"Once upon a time, there was a boy that really liked Streamlit and Star"
" Wars, but couldn't use a Star Wars 'crawl' of his own. He decided to"
" take matters into his own hands and create a new component. Legend says"
" our hero still looks for contributions, and that bugs still lurk in the"
" dark..."
),
),
)
stream_wars(
"Magic 🪄",
intro="Not that long ago, in an office not so far, far away...",
title="Stream Wars",
episode_number="Episode 0",
episode_title="A NEW COMPONENT",
content=txt_input,
key=None,
)
st.markdown((_project.parent / "README.md").read_text(), unsafe_allow_html=True)

# st.header("Demo")
# (txt_input,) = (
# st.text_input(
# "Tell a story",
# value=(
# "Once upon a time, there was a boy that really liked Streamlit and Star"
# " Wars, but couldn't use a Star Wars 'crawl' of his own. He decided to"
# " take matters into his own hands and create a new component. Legend says"
# " our hero still looks for contributions, and that bugs still lurk in the"
# " dark..."
# ),
# ),
# )
# stream_wars(
# "Magic 🪄",
# intro="Not that long ago, in an office not so far, far away...",
# title="Stream Wars",
# episode_number="Episode 0",
# episode_title="A NEW COMPONENT",
# content=txt_input,
# key=None,
# )

# Docs

Expand Down

0 comments on commit e47d43e

Please sign in to comment.