File size: 626 Bytes
ff2cd8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python3
"""
Wrapper script to fix HuggingFace Spaces environment issues before starting Streamlit
"""
import os
import sys

# Fix OMP_NUM_THREADS before ANY imports that might use it
if 'OMP_NUM_THREADS' in os.environ:
    omp_value = os.environ['OMP_NUM_THREADS']
    if 'm' in str(omp_value).lower() or not str(omp_value).isdigit():
        os.environ['OMP_NUM_THREADS'] = '4'
        print(f"Fixed OMP_NUM_THREADS from '{omp_value}' to '4'")

# Now start Streamlit
if __name__ == '__main__':
    from streamlit.web import cli as stcli
    sys.argv = ["streamlit", "run", "app.py"]
    sys.exit(stcli.main())