Spaces:
Sleeping
Sleeping
| #!/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()) | |