Spaces:
GIZ
/
Running on CPU Upgrade

SDSN-demo / utils /streamlitcheck.py
prashant
lexcial update
f9949bb
raw
history blame
511 Bytes
def check_streamlit():
"""
Function to check whether python code is run within streamlit
Returns
-------
use_streamlit : boolean
True if code is run within streamlit, else False
"""
try:
from streamlit.scriptrunner.script_run_context import get_script_run_ctx
if not get_script_run_ctx():
use_streamlit = False
else:
use_streamlit = True
except ModuleNotFoundError:
use_streamlit = False
return use_streamlit