leavoigt commited on
Commit
0a1e238
1 Parent(s): 2abaa4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -5
app.py CHANGED
@@ -1,13 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import appStore.vulnerability_analysis as vulnerability_analysis
2
  import appStore.doc_processing as processing
3
  from utils.uploadAndExample import add_upload
4
- import streamlit as st
5
  from utils.vulnerability_classifier import label_dict
6
  import pandas as pd
7
  import plotly.express as px
8
 
9
- st.set_page_config(page_title = 'Vulnerability Analysis',
10
- initial_sidebar_state='expanded', layout="wide")
11
 
12
  with st.sidebar:
13
  # upload and example doc
@@ -19,8 +58,8 @@ with st.sidebar:
19
  add_upload(choice)
20
 
21
  with st.container():
22
- st.markdown("<h2 style='text-align: center; color: black;'> Vulnerability Analysis </h2>", unsafe_allow_html=True)
23
- st.write(' ')
24
 
25
  with st.expander("ℹ️ - About this app", expanded=False):
26
  st.write(
 
1
+ import streamlit as st
2
+ import os
3
+ import pkg_resources
4
+
5
+ # Using this wacky hack to get around the massively ridicolous managed env loading order
6
+ def is_installed(package_name, version):
7
+ try:
8
+ pkg = pkg_resources.get_distribution(package_name)
9
+ return pkg.version == version
10
+ except pkg_resources.DistributionNotFound:
11
+ return False
12
+
13
+ # shifted from below - this must be the first streamlit call; otherwise: problems
14
+ st.set_page_config(page_title = 'Vulnerability Analysis',
15
+ initial_sidebar_state='expanded', layout="wide")
16
+
17
+ @st.cache_resource # cache the function so it's not called every time app.py is triggered
18
+ def install_packages():
19
+ install_commands = []
20
+
21
+ if not is_installed("spaces", "0.12.0"):
22
+ install_commands.append("pip install spaces==0.17.0")
23
+
24
+ if not is_installed("pydantic", "1.8.2"):
25
+ install_commands.append("pip install pydantic==1.8.2")
26
+
27
+ if not is_installed("typer", "0.4.0"):
28
+ install_commands.append("pip install typer==0.4.0")
29
+
30
+ if install_commands:
31
+ os.system(" && ".join(install_commands))
32
+
33
+ # install packages if necessary
34
+ install_packages()
35
+
36
+ # everything else...
37
+
38
+ #!!!! NOTE: shift st.set_page_config up script - see notes above
39
+
40
+
41
  import appStore.vulnerability_analysis as vulnerability_analysis
42
  import appStore.doc_processing as processing
43
  from utils.uploadAndExample import add_upload
 
44
  from utils.vulnerability_classifier import label_dict
45
  import pandas as pd
46
  import plotly.express as px
47
 
48
+ #st.set_page_config(page_title = 'Vulnerability Analysis',
49
+ # initial_sidebar_state='expanded', layout="wide")
50
 
51
  with st.sidebar:
52
  # upload and example doc
 
58
  add_upload(choice)
59
 
60
  with st.container():
61
+ st.markdown("<h2 style='text-align: center; color: black;'> Vulnerability Analysis </h2>", unsafe_allow_html=True)
62
+ st.write(' ')
63
 
64
  with st.expander("ℹ️ - About this app", expanded=False):
65
  st.write(