Skip to content

Commit

Permalink
new Dockerfiles and add gender
Browse files Browse the repository at this point in the history
  • Loading branch information
linozen committed Sep 14, 2021
1 parent ec98949 commit b5086ab
Show file tree
Hide file tree
Showing 6 changed files with 2,087 additions and 22 deletions.
38 changes: 18 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
FROM python:3.9-slim-buster
FROM bitnami/python:3.9 as base
WORKDIR /app

RUN apt-get update \
&& apt-get install build-essential make gcc -y \
&& apt-get install dpkg-dev -y \
&& apt-get install libjpeg-dev -y \
&& apt-get upgrade -y
# Install some build dependencies
RUN install_packages build-essential make gcc dpkg-dev libjpeg-dev sudo dbus-tests

RUN useradd --create-home --uid 9000 nonroot
USER nonroot
WORKDIR /home/nonroot/app
COPY --chown=nonroot:nonroot . .
ENV PATH="/home/nonroot/.local/bin:${PATH}"
RUN python3 -m pip install --user pipenv
RUN pipenv install
# Set path and install poetry in it
ENV PATH /root/.local/bin:$PATH
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -

USER root
RUN apt-get remove -y --purge make gcc build-essential \
&& apt-get auto-remove -y \
&& rm -rf /var/lib/apt/lists/* \
&& find /usr/local/lib/python3.9 -name "*.pyc" -type f -delete
# We don't need poetry to create virtual environments; global site is just fine
RUN poetry config virtualenvs.create false

USER nonroot
# Install project dependencies
COPY pyproject.toml poetry.lock /app/
RUN poetry install

# Copy files
COPY . .

# Expoe ports and provide entrypoint
EXPOSE 8501-8503
ENTRYPOINT [ "pipenv", "run" ]
ENTRYPOINT [ "poetry", "run" ]
1 change: 1 addition & 0 deletions explorer/civsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,7 @@ def get_cs_df():
}
)

df["CSgender"] = df["CSgender"].fillna("Not specified")
df["CSgender"] = df["CSgender"].replace(
{
"AO01": "Woman",
Expand Down
18 changes: 18 additions & 0 deletions explorer/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ def get_ms_df():
}
)

df["MSgender"] = df["MSgender"].fillna("Not specified")
df["MSgender"] = df["MSgender"].replace(
{
"AO01": "Woman",
Expand Down Expand Up @@ -1119,6 +1120,23 @@ def callback():
use_container_width=True,
)

st.write("### Gender `[MSgender]`")
gender_counts = df[filter]["MSgender"].value_counts()
st.plotly_chart(
render_pie_chart(
df[filter],
values=gender_counts,
names=gender_counts.index,
color=gender_counts.index,
color_discrete_map={
"Not specified": px.colors.qualitative.Prism[10],
"Male": px.colors.qualitative.Prism[9],
"Female": px.colors.qualitative.Prism[7],
"Other": px.colors.qualitative.Prism[5],
},
),
use_container_width=True,
)
if selected_section == "Resources":
st.write("# Resources")

Expand Down
23 changes: 21 additions & 2 deletions explorer/merged.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,14 @@ def get_merged_ms_df():
}
)

df["gender"] = df["gender"].fillna("Other")
df["gender"] = df["gender"].fillna("Not specified")
df["gender"] = df["gender"].replace(
{
"AO01": "Female",
"AO02": "Non-binary",
"AO03": "Male",
"AO04": "Other",
"AO04": "I prefer not to say",
"AO05": "Other",
}
)

Expand Down Expand Up @@ -1052,6 +1053,24 @@ def callback():
use_container_width=True,
)

st.write("### Gender `[gender]`")
gender_counts = df[filter]["gender"].value_counts()
st.plotly_chart(
render_pie_chart(
df[filter],
values=gender_counts,
names=gender_counts.index,
color=gender_counts.index,
color_discrete_map={
"Not specified": px.colors.qualitative.Prism[10],
"Male": px.colors.qualitative.Prism[9],
"Female": px.colors.qualitative.Prism[7],
"Other": px.colors.qualitative.Prism[5],
},
),
use_container_width=True,
)

if selected_section == "Resources":
st.write("# Resources")

Expand Down
Loading

0 comments on commit b5086ab

Please sign in to comment.