File size: 1,204 Bytes
0f516c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""
Custom Streamlit runner that completely disables metrics and configuration system
"""

import os
import sys
import types

# Create fake modules to prevent Streamlit from loading its metrics system
class FakeModule(types.ModuleType):
    def __init__(self, name):
        super().__init__(name)
        self.__path__ = []
    
    def __getattr__(self, name):
        return None

# Replace critical Streamlit modules with dummies
sys.modules['streamlit.runtime.metrics_util'] = FakeModule('metrics_util')
sys.modules['streamlit.runtime.installation'] = FakeModule('installation')
sys.modules['streamlit.config'] = FakeModule('config')

# Set environment variables to prevent any file writes
os.environ['STREAMLIT_GLOBAL_METRICS'] = '0'
os.environ['STREAMLIT_SERVER_ENABLE_STATIC_SERVE'] = '1'
os.environ['STREAMLIT_GLOBAL_DEVELOPMENT_MODE'] = '0'
os.environ['HOME'] = '/tmp'

# Import and run Streamlit with our app
from streamlit.web.cli import main

if __name__ == '__main__':
    sys.argv = [
        "streamlit", "run", "app.py",
        "--global.developmentMode=false",
        "--logger.level=error",
        "--browser.gatherUsageStats=false"
    ]
    sys.exit(main())