Canstralian commited on
Commit
ab9047c
1 Parent(s): db2f810

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -99
app.py CHANGED
@@ -1,101 +1,9 @@
1
- import os
2
- import streamlit as st
3
- import pandas as pd
4
- import matplotlib.pyplot as plt
5
- import dask.dataframe as dd
6
- from dotenv import load_dotenv
7
- from itertools import combinations
8
- from collections import defaultdict
9
 
10
- # Load environment variables
11
- load_dotenv()
12
 
13
- # Configuration from environment variables
14
- FILE_UPLOAD_LIMIT = int(os.getenv('FILE_UPLOAD_LIMIT', 200))
15
- EXECUTION_TIME_LIMIT = int(os.getenv('EXECUTION_TIME_LIMIT', 300))
16
- RESOURCE_LIMIT = int(os.getenv('RESOURCE_LIMIT', 1024)) # in MB
17
- DATA_DIR = os.getenv('DATA_DIR', './data')
18
- CONFIG_FLAG = os.getenv('CONFIG_FLAG', 'default')
19
-
20
- # Main application logic
21
- def main():
22
- st.title("CyberOps Dashboard")
23
-
24
- # Sidebar for user inputs
25
- st.sidebar.header("Options")
26
-
27
- # Option to select a CSV file
28
- uploaded_file = st.sidebar.file_uploader("Select a CSV file:", type=["csv"])
29
-
30
- # Main frame for introduction and navigation
31
- with st.container():
32
- st.subheader("Welcome to CyberOps Dashboard")
33
- st.write("""
34
- The CyberOps Dashboard is designed to assist cybersecurity professionals in analyzing and visualizing data efficiently.
35
- With this tool, you can upload CSV files, visualize data trends, and perform advanced data analysis.
36
- """)
37
-
38
- # Navigation section
39
- st.subheader("Navigation")
40
- st.write("Use the buttons below to navigate to different sections:")
41
- col1, col2, col3 = st.columns(3)
42
-
43
- with col1:
44
- if st.button("Data Upload"):
45
- st.sidebar.file_uploader("Select a CSV file:", type=["csv"])
46
-
47
- with col2:
48
- if st.button("Data Visualization"):
49
- st.sidebar.selectbox('Select X-axis:', [])
50
- st.sidebar.selectbox('Select Y-axis:', [])
51
-
52
- with col3:
53
- if st.button("Analysis Tools"):
54
- st.sidebar.multiselect('Select columns for combinations:', [])
55
-
56
- if uploaded_file:
57
- @st.cache_data
58
- def load_csv(file):
59
- return pd.read_csv(file)
60
-
61
- @st.cache_data
62
- def load_dask_csv(file):
63
- return dd.read_csv(file)
64
-
65
- if os.path.getsize(uploaded_file) < RESOURCE_LIMIT * 1024 * 1024:
66
- df = load_csv(uploaded_file)
67
- else:
68
- df = load_dask_csv(uploaded_file)
69
-
70
- if not df.empty:
71
- st.write("Data Preview:")
72
- st.dataframe(df.compute() if isinstance(df, dd.DataFrame) else df)
73
-
74
- # Select columns for plotting
75
- x_column = st.sidebar.selectbox('Select X-axis:', df.columns)
76
- y_column = st.sidebar.selectbox('Select Y-axis:', df.columns)
77
-
78
- # Plotting
79
- fig, ax = plt.subplots()
80
- ax.plot(df[x_column], df[y_column], marker='o')
81
- ax.set_xlabel(x_column)
82
- ax.set_ylabel(y_column)
83
- ax.set_title(f"{y_column} vs {x_column}")
84
- st.pyplot(fig)
85
-
86
- # Combinatorial analysis
87
- col_combinations = st.sidebar.multiselect('Select columns for combinations:', df.columns)
88
- if col_combinations:
89
- st.write("Column Combinations:")
90
- comb = list(combinations(col_combinations, 2))
91
- st.write(comb)
92
-
93
- # Grouping and aggregation
94
- group_by_column = st.sidebar.selectbox('Select column to group by:', df.columns)
95
- if group_by_column:
96
- grouped_df = df.groupby(group_by_column).agg(list)
97
- st.write("Grouped Data:")
98
- st.dataframe(grouped_df.compute() if isinstance(grouped_df, dd.DataFrame) else grouped_df)
99
-
100
- if __name__ == "__main__":
101
- main()
 
1
+ StreamlitDuplicateElementId: There are multiple file_uploader elements with the same auto-generated ID. When this element is created, it is assigned an internal ID based on the element type and provided parameters. Multiple elements with the same type and parameters will cause this error.
 
 
 
 
 
 
 
2
 
3
+ To fix this error, please pass a unique key argument to the file_uploader element.
 
4
 
5
+ Traceback:
6
+ File "/home/user/app/app.py", line 101, in <module>
7
+ main()
8
+ File "/home/user/app/app.py", line 45, in main
9
+ st.sidebar.file_uploader("Select a CSV file:", type=["csv"])