-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: improve proof-of-concept app #116
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
base: main
Are you sure you want to change the base?
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
b32158d
to
31a45b5
Compare
271fa52
to
394f3da
Compare
<h2>Map</h2> | ||
<div class="row" style="min-height: 450px;"> | ||
<div class="col-lg-12 border"> | ||
<iframe class="streamlit-app" src="{{ streamlit_host }}/stations--stations?embed=true&district_number={{ current_district.number }}"> |
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.
rename class to streamlit-service
Realized that the custom streamlit-app
class was not necessary since it can be replaced by Bootstrap's w-100 h-100
.
pems/core/context_processors.py
Outdated
def streamlit_host(request): | ||
"""Context processor to add the Streamlit host URL part to the context.""" | ||
|
||
return {"streamlit_host": settings.STREAMLIT_HOST} |
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.
consider top-level streamlit
context
pems/settings.py
Outdated
|
||
# Streamlit settings | ||
STREAMLIT_LOCAL_PORT = os.environ.get("STREAMLIT_LOCAL_PORT", "") | ||
STREAMLIT_HOST = os.environ.get("STREAMLIT_HOST", f"http://localhost:{STREAMLIT_LOCAL_PORT}") |
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.
collapse these 2 variables to 1
pems/static/css/styles.css
Outdated
@@ -10,3 +10,8 @@ header { | |||
} | |||
} | |||
} | |||
|
|||
.streamlit-app { |
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.
is there a class in Bootstrap already that already sets these 2 properties? if so, use that one
@@ -35,6 +35,8 @@ EXPOSE 8501 | |||
|
|||
COPY streamlit_app streamlit_app | |||
|
|||
COPY .streamlit .streamlit |
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.
move this to before COPY streamlit_app streamlit_app
to take advantage of layer caching
the District Stations Streamlit app is a simple proof-of-concept that displays the traffic data collection stations in a district.
the django and streamlit apps are now wired up in a way that works both for a local dev environment as well as a Cloud deployment.
since the web and streamlit services run on the same load balancer in AWS, the http path defined in the manifest of each service must be different from each other. the http path of the streamlit service (streamlit_service) is also passed to the streamlit run command in the entrypoint.sh script. also, the healthcheck path must be defined in the manifest so that the service does not continually restart.
this setup was causing an error when deploying to AWS since the Django pems app resides in a different container. when running a local debugger though, this error was not present since the local dev container does have the pems app. since at this moment we are not using Django models in the streamlit app, we are removing this ability.
copy the .streamlit directory into the streamlit service's image so that the streamlit configuration is available to the container. before, the configuration was only available to the local dev container.
d2549eb
to
56f7ed2
Compare
WIP
Adds the
stations
app to the repo (before it was only a local branch) and wires up django and streamlit in an environment-dependent way so that the proof-of-conceptdistricts
app can run both locally and in the Cloud.Currently this branch is on top ofci/cloud-infra
but it will be rebased onmain
once PR #111 is merged.Notes
Originally, the
streamlit
service was defined as a copilotBackend Service
. For an initial proof-of-concept this is not a convenient service type since the service is unreachable from the internet (recall that theweb
service embedsstreamlit
in an iframe, sostreamlit
needs to be reachable from the internet). For this PR, we will changestreamlit
to aLoad Balanced Web Service
. As we get closer to production, the architecture will likely change to:web
to act as a reverse proxyiframe
s inweb
will point to a path inweb
but this path will be set up in thengingx
configuration to forward any requests tostreamlit
over the private networkstreamlit
in a private network (back toBackend Service
) and configure it to deny all incoming traffic except for requests from the private IP address ofweb
.