Spaces:
GIZ
/
Running on CPU Upgrade

prashant commited on
Commit
e836bc5
1 Parent(s): 123fa2b

decorator test

Browse files
appStore/sdg_analysis.py CHANGED
@@ -44,40 +44,37 @@ def app():
44
 
45
 
46
  with st.container():
47
- if check_streamlit():
48
- st.write(True)
49
- else:
50
- st.write(False)
51
 
52
- # if 'filepath' in st.session_state:
53
- # paraList = runSDGPreprocessingPipeline()
54
- # if len(paraList) > 150:
55
- # warning_msg = ": This might take sometime, please sit back and relax."
56
- # else:
57
- # warning_msg = ""
58
-
59
- # with st.spinner("Running SDG Classification{}".format(warning_msg)):
60
-
61
- # df, x = sdg_classification(paraList)
62
-
63
- # plt.rcParams['font.size'] = 25
64
- # colors = plt.get_cmap('Blues')(np.linspace(0.2, 0.7, len(x)))
65
- # # plot
66
- # fig, ax = plt.subplots()
67
- # ax.pie(x, colors=colors, radius=2, center=(4, 4),
68
- # wedgeprops={"linewidth": 1, "edgecolor": "white"},
69
- # frame=False,labels =list(x.index))
70
- # # fig.savefig('temp.png', bbox_inches='tight',dpi= 100)
71
- # st.markdown("#### Anything related to SDGs? ####")
72
-
73
- # c4, c5, c6 = st.columns([2, 2, 2])
74
-
75
- # with c5:
76
- # st.pyplot(fig)
77
 
78
- # c7, c8, c9 = st.columns([1, 10, 1])
79
- # with c8:
80
- # st.table(df)
81
 
82
 
83
  # 1. Keyword heatmap \n
 
44
 
45
 
46
  with st.container():
47
+
 
 
 
48
 
49
+ if 'filepath' in st.session_state:
50
+ paraList = runSDGPreprocessingPipeline()
51
+ if len(paraList) > 150:
52
+ warning_msg = ": This might take sometime, please sit back and relax."
53
+ else:
54
+ warning_msg = ""
55
+
56
+ with st.spinner("Running SDG Classification{}".format(warning_msg)):
57
+
58
+ df, x = sdg_classification(paraList)
59
+
60
+ plt.rcParams['font.size'] = 25
61
+ colors = plt.get_cmap('Blues')(np.linspace(0.2, 0.7, len(x)))
62
+ # plot
63
+ fig, ax = plt.subplots()
64
+ ax.pie(x, colors=colors, radius=2, center=(4, 4),
65
+ wedgeprops={"linewidth": 1, "edgecolor": "white"},
66
+ frame=False,labels =list(x.index))
67
+ # fig.savefig('temp.png', bbox_inches='tight',dpi= 100)
68
+ st.markdown("#### Anything related to SDGs? ####")
69
+
70
+ c4, c5, c6 = st.columns([2, 2, 2])
71
+
72
+ with c5:
73
+ st.pyplot(fig)
74
 
75
+ c7, c8, c9 = st.columns([1, 10, 1])
76
+ with c8:
77
+ st.table(df)
78
 
79
 
80
  # 1. Keyword heatmap \n
utils/sdg_classifier.py CHANGED
@@ -27,24 +27,6 @@ def load_sdgClassifier():
27
  task="text-classification")
28
  return doc_classifier
29
 
30
- def check_streamlit():
31
- """
32
- Function to check whether python code is run within streamlit
33
-
34
- Returns
35
- -------
36
- use_streamlit : boolean
37
- True if code is run within streamlit, else False
38
- """
39
- try:
40
- from streamlit.scriptrunner.script_run_context import get_script_run_ctx
41
- if not get_script_run_ctx():
42
- use_streamlit = False
43
- else:
44
- use_streamlit = True
45
- except ModuleNotFoundError:
46
- use_streamlit = False
47
- return use_streamlit
48
 
49
  def sdg_classification(haystackdoc:List[Document])->Tuple[DataFrame,Series]:
50
  """
 
27
  task="text-classification")
28
  return doc_classifier
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  def sdg_classification(haystackdoc:List[Document])->Tuple[DataFrame,Series]:
32
  """
utils/streamlitcheck.py CHANGED
@@ -1,2 +1,19 @@
 
 
 
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
 
1
+ def check_streamlit():
2
+ """
3
+ Function to check whether python code is run within streamlit
4
 
5
+ Returns
6
+ -------
7
+ use_streamlit : boolean
8
+ True if code is run within streamlit, else False
9
+ """
10
+ try:
11
+ from streamlit.scriptrunner.script_run_context import get_script_run_ctx
12
+ if not get_script_run_ctx():
13
+ use_streamlit = False
14
+ else:
15
+ use_streamlit = True
16
+ except ModuleNotFoundError:
17
+ use_streamlit = False
18
+ return use_streamlit
19