mtyrrell commited on
Commit
b64cff5
1 Parent(s): 395f3fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -1
app.py CHANGED
@@ -1,3 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import appStore.target as target_extraction
2
  import appStore.netzero as netzero
3
  import appStore.sector as sector
@@ -9,7 +46,7 @@ import appStore.indicator as indicator
9
  import appStore.doc_processing as processing
10
  from utils.uploadAndExample import add_upload
11
  from PIL import Image
12
- import streamlit as st
13
 
14
  st.set_page_config(page_title = 'Climate Policy Intelligence',
15
  initial_sidebar_state='expanded', layout="wide")
 
1
+ import streamlit as st
2
+ import os
3
+ import pkg_resources
4
+
5
+ # streamlit page needs to go here as it must be the first st call
6
+ st.set_page_config(page_title = 'Vulnerability Analysis',
7
+ initial_sidebar_state='expanded', layout="wide")
8
+
9
+ # Using this wacky hack to get around the massively ridicolous managed env loading order
10
+ def is_installed(package_name, version):
11
+ try:
12
+ pkg = pkg_resources.get_distribution(package_name)
13
+ return pkg.version == version
14
+ except pkg_resources.DistributionNotFound:
15
+ return False
16
+
17
+ @st.cache_resource
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
+
37
+
38
  import appStore.target as target_extraction
39
  import appStore.netzero as netzero
40
  import appStore.sector as sector
 
46
  import appStore.doc_processing as processing
47
  from utils.uploadAndExample import add_upload
48
  from PIL import Image
49
+ # import streamlit as st
50
 
51
  st.set_page_config(page_title = 'Climate Policy Intelligence',
52
  initial_sidebar_state='expanded', layout="wide")