Spaces:
Sleeping
Sleeping
Create run_app.py
Browse files- run_app.py +40 -0
run_app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Custom Streamlit runner that completely disables metrics and configuration system
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import sys
|
| 8 |
+
import types
|
| 9 |
+
|
| 10 |
+
# Create fake modules to prevent Streamlit from loading its metrics system
|
| 11 |
+
class FakeModule(types.ModuleType):
|
| 12 |
+
def __init__(self, name):
|
| 13 |
+
super().__init__(name)
|
| 14 |
+
self.__path__ = []
|
| 15 |
+
|
| 16 |
+
def __getattr__(self, name):
|
| 17 |
+
return None
|
| 18 |
+
|
| 19 |
+
# Replace critical Streamlit modules with dummies
|
| 20 |
+
sys.modules['streamlit.runtime.metrics_util'] = FakeModule('metrics_util')
|
| 21 |
+
sys.modules['streamlit.runtime.installation'] = FakeModule('installation')
|
| 22 |
+
sys.modules['streamlit.config'] = FakeModule('config')
|
| 23 |
+
|
| 24 |
+
# Set environment variables to prevent any file writes
|
| 25 |
+
os.environ['STREAMLIT_GLOBAL_METRICS'] = '0'
|
| 26 |
+
os.environ['STREAMLIT_SERVER_ENABLE_STATIC_SERVE'] = '1'
|
| 27 |
+
os.environ['STREAMLIT_GLOBAL_DEVELOPMENT_MODE'] = '0'
|
| 28 |
+
os.environ['HOME'] = '/tmp'
|
| 29 |
+
|
| 30 |
+
# Import and run Streamlit with our app
|
| 31 |
+
from streamlit.web.cli import main
|
| 32 |
+
|
| 33 |
+
if __name__ == '__main__':
|
| 34 |
+
sys.argv = [
|
| 35 |
+
"streamlit", "run", "app.py",
|
| 36 |
+
"--global.developmentMode=false",
|
| 37 |
+
"--logger.level=error",
|
| 38 |
+
"--browser.gatherUsageStats=false"
|
| 39 |
+
]
|
| 40 |
+
sys.exit(main())
|