Spaces:
Sleeping
Sleeping
fixed bugs
Browse files- .streamlit/config.toml +9 -0
- Dockerfile +22 -16
- src/app.py +24 -53
.streamlit/config.toml
CHANGED
@@ -1,2 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
[browser]
|
2 |
gatherUsageStats = false
|
|
|
1 |
+
[global]
|
2 |
+
dataSavePath = "/tmp"
|
3 |
+
|
4 |
+
[client]
|
5 |
+
showErrorDetails = true
|
6 |
+
|
7 |
+
[logger]
|
8 |
+
level = "info"
|
9 |
+
|
10 |
[browser]
|
11 |
gatherUsageStats = false
|
Dockerfile
CHANGED
@@ -1,23 +1,29 @@
|
|
1 |
-
FROM python:3.
|
2 |
|
3 |
-
# Set
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
COPY ./src /app/src
|
8 |
-
COPY ./requirements.txt /app/requirements.txt
|
9 |
|
10 |
-
#
|
11 |
-
|
|
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
|
16 |
-
#
|
17 |
-
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
EXPOSE 7860
|
21 |
|
22 |
-
|
23 |
-
CMD ["streamlit", "run", "src/app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
|
|
1 |
+
FROM python:3.9-slim-buster
|
2 |
|
3 |
+
# Set environment variables for Streamlit and Matplotlib
|
4 |
+
ENV STREAMLIT_SERVER_PORT=8501
|
5 |
+
ENV MPLCONFIGDIR=/tmp/matplotlib_cache
|
6 |
+
|
7 |
+
# Create a non-root user for security (optional but good practice)
|
8 |
+
# And set ownership of the app directory if needed
|
9 |
+
# RUN useradd -m streamlit_user
|
10 |
+
# USER streamlit_user
|
11 |
+
# WORKDIR /home/streamlit_user/app
|
12 |
|
13 |
+
WORKDIR /app
|
|
|
|
|
14 |
|
15 |
+
# Copy requirements.txt and install dependencies
|
16 |
+
COPY requirements.txt .
|
17 |
+
RUN pip install -r requirements.txt
|
18 |
|
19 |
+
# Copy your Streamlit app and configuration
|
20 |
+
COPY . .
|
21 |
|
22 |
+
# Create the matplotlib cache directory with appropriate permissions
|
23 |
+
RUN mkdir -p ${MPLCONFIGDIR} && chmod -R 777 ${MPLCONFIGDIR}
|
24 |
+
# Make sure /tmp is also writable by everyone if not already (often is by default)
|
25 |
+
RUN chmod -R 777 /tmp
|
26 |
|
27 |
+
EXPOSE 8501
|
|
|
28 |
|
29 |
+
ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]
|
|
src/app.py
CHANGED
@@ -1,65 +1,36 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
import os
|
4 |
-
import tempfile
|
5 |
-
import traceback
|
6 |
|
7 |
# Set page title
|
8 |
st.title("Student Grades Analysis")
|
9 |
|
10 |
-
# Display Streamlit config directory for debugging
|
11 |
-
st.write(f"Streamlit config directory: {os.getenv('STREAMLIT_CONFIG_DIR', 'Not set')}")
|
12 |
-
|
13 |
# File uploader for CSV
|
14 |
uploaded_file = st.file_uploader("Upload your student grades CSV file", type=["csv"])
|
15 |
|
16 |
if uploaded_file is not None:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
# Display descriptive statistics
|
42 |
-
st.subheader("Descriptive Statistics")
|
43 |
-
st.write("**Basic Statistics for Numeric Columns**")
|
44 |
-
st.dataframe(df.describe())
|
45 |
-
|
46 |
-
st.write("**Column Data Types**")
|
47 |
-
st.write(df.dtypes)
|
48 |
-
|
49 |
-
st.write("**Missing Values**")
|
50 |
-
st.write(df.isnull().sum())
|
51 |
-
|
52 |
-
st.write("**Gender Distribution**")
|
53 |
-
st.write(df['gender'].value_counts())
|
54 |
-
|
55 |
-
st.write("**Correlation between Physics and Math Grades**")
|
56 |
-
st.write(df[['physics_grade', 'math_grade']].corr())
|
57 |
-
|
58 |
-
# Clean up the temporary file
|
59 |
-
os.remove(tmp_file_path)
|
60 |
-
st.write("Temporary file deleted")
|
61 |
-
except Exception as e:
|
62 |
-
st.error(f"An error occurred while processing the file: {str(e)}")
|
63 |
-
st.error(f"Full traceback: {traceback.format_exc()}")
|
64 |
else:
|
65 |
st.info("Please upload a CSV file to see the data and statistics.")
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
|
|
|
|
3 |
|
4 |
# Set page title
|
5 |
st.title("Student Grades Analysis")
|
6 |
|
|
|
|
|
|
|
7 |
# File uploader for CSV
|
8 |
uploaded_file = st.file_uploader("Upload your student grades CSV file", type=["csv"])
|
9 |
|
10 |
if uploaded_file is not None:
|
11 |
+
# Read the CSV file
|
12 |
+
df = pd.read_csv(uploaded_file)
|
13 |
+
|
14 |
+
# Display the DataFrame
|
15 |
+
st.subheader("Uploaded DataFrame")
|
16 |
+
st.dataframe(df)
|
17 |
+
|
18 |
+
# Display descriptive statistics
|
19 |
+
st.subheader("Descriptive Statistics")
|
20 |
+
st.write("**Basic Statistics for Numeric Columns**")
|
21 |
+
st.dataframe(df.describe())
|
22 |
+
|
23 |
+
# Additional statistics
|
24 |
+
st.write("**Column Data Types**")
|
25 |
+
st.write(df.dtypes)
|
26 |
+
|
27 |
+
st.write("**Missing Values**")
|
28 |
+
st.write(df.isnull().sum())
|
29 |
+
|
30 |
+
st.write("**Gender Distribution**")
|
31 |
+
st.write(df['gender'].value_counts())
|
32 |
+
|
33 |
+
st.write("**Correlation between Physics and Math Grades**")
|
34 |
+
st.write(df[['physics_grade', 'math_grade']].corr())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
else:
|
36 |
st.info("Please upload a CSV file to see the data and statistics.")
|