Added compare mode multi file uploader
Browse files
app.py
CHANGED
@@ -118,37 +118,56 @@ def single_main(uploaded_file):
|
|
118 |
st.write("### No scenarios with status 'failed' found.")
|
119 |
pass
|
120 |
|
121 |
-
def main():
|
122 |
|
|
|
|
|
123 |
add_app_description()
|
124 |
|
125 |
-
# Initially we are in multi file processing mode
|
126 |
if "mode" not in st.session_state:
|
127 |
st.session_state["mode"] = "multi"
|
128 |
|
129 |
-
# Add a dropdown for mode selection
|
130 |
selected_mode = st.sidebar.selectbox("Select Mode", ["Multi", "Compare", "Weekly", "Multi-Env Compare"])
|
131 |
|
132 |
-
# Update the mode based on the selection
|
133 |
st.session_state["mode"] = selected_mode.lower()
|
134 |
|
135 |
-
# Display the selected mode
|
136 |
mode_display = f'## Current mode: {st.session_state["mode"].title()} mode'
|
137 |
st.sidebar.markdown(mode_display)
|
138 |
|
139 |
-
# Only show the second file uploader in compare mode
|
140 |
if st.session_state["mode"] == "multi":
|
141 |
multiple_main()
|
142 |
elif st.session_state["mode"] == "compare":
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
elif st.session_state["mode"] == "weekly":
|
148 |
uploaded_files = st.sidebar.file_uploader("Upload CSV files for Weekly Report", type="csv", accept_multiple_files=True)
|
149 |
if uploaded_files:
|
150 |
generate_weekly_report(uploaded_files)
|
151 |
-
elif st.session_state["mode"] == "multi-env compare":
|
152 |
multi_env_compare_main()
|
153 |
|
154 |
if __name__ == "__main__":
|
|
|
118 |
st.write("### No scenarios with status 'failed' found.")
|
119 |
pass
|
120 |
|
|
|
121 |
|
122 |
+
|
123 |
+
def main():
|
124 |
add_app_description()
|
125 |
|
|
|
126 |
if "mode" not in st.session_state:
|
127 |
st.session_state["mode"] = "multi"
|
128 |
|
|
|
129 |
selected_mode = st.sidebar.selectbox("Select Mode", ["Multi", "Compare", "Weekly", "Multi-Env Compare"])
|
130 |
|
|
|
131 |
st.session_state["mode"] = selected_mode.lower()
|
132 |
|
|
|
133 |
mode_display = f'## Current mode: {st.session_state["mode"].title()} mode'
|
134 |
st.sidebar.markdown(mode_display)
|
135 |
|
|
|
136 |
if st.session_state["mode"] == "multi":
|
137 |
multiple_main()
|
138 |
elif st.session_state["mode"] == "compare":
|
139 |
+
st.sidebar.markdown("### Upload CSV Files for Comparison")
|
140 |
+
upload_option = st.sidebar.radio("Upload method", ["Single uploader", "Two separate uploaders"])
|
141 |
+
|
142 |
+
if upload_option == "Single uploader":
|
143 |
+
uploaded_files = st.sidebar.file_uploader("Upload CSV files for comparison", type="csv", accept_multiple_files=True)
|
144 |
+
if uploaded_files:
|
145 |
+
if len(uploaded_files) < 2:
|
146 |
+
st.warning("Please upload at least two CSV files for comparison.")
|
147 |
+
elif len(uploaded_files) > 2:
|
148 |
+
st.warning("More than two files uploaded. Only the first two will be used for comparison.")
|
149 |
+
else:
|
150 |
+
with st.spinner('Processing...'):
|
151 |
+
double_main(uploaded_files[0], uploaded_files[1])
|
152 |
+
st.success('Comparison Complete!')
|
153 |
+
else:
|
154 |
+
col1, col2 = st.sidebar.columns(2)
|
155 |
+
with col1:
|
156 |
+
uploaded_file1 = st.file_uploader("Upload older CSV file", type="csv", key="file1")
|
157 |
+
with col2:
|
158 |
+
uploaded_file2 = st.file_uploader("Upload newer CSV file", type="csv", key="file2")
|
159 |
+
|
160 |
+
if uploaded_file1 is not None and uploaded_file2 is not None:
|
161 |
+
with st.spinner('Processing...'):
|
162 |
+
double_main(uploaded_file1, uploaded_file2)
|
163 |
+
st.success('Comparison Complete!')
|
164 |
+
elif uploaded_file1 is not None or uploaded_file2 is not None:
|
165 |
+
st.warning("Please upload both CSV files for comparison.")
|
166 |
elif st.session_state["mode"] == "weekly":
|
167 |
uploaded_files = st.sidebar.file_uploader("Upload CSV files for Weekly Report", type="csv", accept_multiple_files=True)
|
168 |
if uploaded_files:
|
169 |
generate_weekly_report(uploaded_files)
|
170 |
+
elif st.session_state["mode"] == "multi-env compare":
|
171 |
multi_env_compare_main()
|
172 |
|
173 |
if __name__ == "__main__":
|