prashant
commited on
Commit
·
7a50684
1
Parent(s):
c4409b1
decorator check
Browse files- utils/sdg_classifier.py +17 -0
utils/sdg_classifier.py
CHANGED
@@ -27,7 +27,24 @@ def load_sdgClassifier():
|
|
27 |
task="text-classification")
|
28 |
return doc_classifier
|
29 |
|
|
|
|
|
|
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
def sdg_classification(haystackdoc:List[Document])->Tuple[DataFrame,Series]:
|
33 |
"""
|
|
|
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 st.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 |
"""
|