-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: local Streamlit setup #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
transitioning to streamlit for viz
d2f7664
to
418d9d8
Compare
but ignore streamlit_app/apps directory, with user-submitted code
and tests with a folder of test apps
walk through the streamlit_ap/apps/ directory and any subdirectory(ies) looking for app_*.py files, which are assumed to contain a streamlit app each construct a multipage streamlit site from all the discovered apps - page titles like Directory | subdirectory | app_name - page URLs like http://localhost:8501/directory--subdirectory--name update the launch config for with and without the sidebar
so e.g. Django models can be queried from Streamlit apps
418d9d8
to
1febecc
Compare
show the bikeshare sample in an iframe in a Django template served by a Django route/view
1febecc
to
4e4d606
Compare
lalver1
approved these changes
Apr 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I was able to run the 3 scenarios without a problem 👍
Using streamlit_app/utils.py
and
Line 35 in 4e4d606
site = st.navigation(apps, position=nav_position) |
streamlit_app/apps
) is the key feature that will allow Traffic Ops to easily add new visualizations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #71
What this PR does
streamlit
service to Compose file, which builds and runsstreamlit_app/Dockerfile
pems
app imagestreamlit
Compose service launchesstreamlit_app/main.py
upon startupstreamlit_app/main.py
discovers Streamlit apps under thestreamlit_app/apps/
directory and creates and runs a single large Multipage appstreamlit_app/apps/
or its subdirectories, that have a filename starting withapp_
streamlit
and additional dependencies in the devcontainer to allow running and debugging the apps locallypygwalker
config previously created by Traffic OpsReviewing this PR
Checkout this branch locally (not in a devcontainer)
Create an
.env
from the sample if you don't have one already.Build and run the
streamlit
servicebin/build.sh
to build all 3 services (app
,dev
,streamlit
)docker compose up streamlit
to start the service and connect to its terminallocalhost
URL👋 Welcome to Streamlit!
message in the terminal asking for your email, just hit enterlocalhost
URL, to open the Streamlit app in your browser/sample--bikeshare
and see the bikeshare sample Streamlit app loadLoad the devcontainer
streamlit_app/main.py
file and swap to theRun & Debug
tabStreamlit, yes sidebar
from the dropdown, and hit the play button (orF5
)Local URL
from the terminal by Ctrl/Cmd-click or copy/paste (should behttp://localhost:8501
)Test the Django integration
Run & Debug
tab, choose theStreamlit, no sidebar
and start it upRun & Debug
tab, chooseDjango: PeMS Client
and start it up/
route)/streamlit
to see a page that embeds the Streamlit sample via<iframe>