Spaces:
Sleeping
Sleeping
Timo
commited on
Commit
·
14e821b
1
Parent(s):
e643383
OK
Browse files- src/streamlit_app.py +17 -16
src/streamlit_app.py
CHANGED
|
@@ -12,10 +12,25 @@ for Hugging Face Spaces deployment.
|
|
| 12 |
with real logic later.
|
| 13 |
"""
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
from __future__ import annotations
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
import random, os
|
| 18 |
-
from pathlib import Path
|
| 19 |
from typing import Dict, List
|
| 20 |
|
| 21 |
import requests
|
|
@@ -23,20 +38,6 @@ import streamlit as st
|
|
| 23 |
|
| 24 |
from draft_model import DraftModel
|
| 25 |
|
| 26 |
-
|
| 27 |
-
# 1) choose writable locations ( /tmp is always safe in Spaces )
|
| 28 |
-
os.environ.setdefault("HOME", "/tmp") # fixes expanduser
|
| 29 |
-
os.environ.setdefault("STREAMLIT_HOME", "/tmp/.streamlit") # telemetry etc.
|
| 30 |
-
os.environ.setdefault("HF_HOME", "/tmp/hf_cache") # model files
|
| 31 |
-
|
| 32 |
-
# 2) create them so the next write succeeds
|
| 33 |
-
for _dir in (os.environ["STREAMLIT_HOME"], os.environ["HF_HOME"]):
|
| 34 |
-
Path(_dir).mkdir(parents=True, exist_ok=True)
|
| 35 |
-
|
| 36 |
-
# 3) silence the “Collecting usage statistics…” banner completely
|
| 37 |
-
os.environ["STREAMLIT_BROWSER_GATHERUSAGESTATS"] = "false"
|
| 38 |
-
|
| 39 |
-
|
| 40 |
SUPPORTED_SETS_PATH = Path("supported_sets.txt")
|
| 41 |
st.write("Running Streamlit", st.__version__)
|
| 42 |
|
|
|
|
| 12 |
with real logic later.
|
| 13 |
"""
|
| 14 |
|
| 15 |
+
import os, pathlib
|
| 16 |
+
# Writable locations --------------------------------------------------
|
| 17 |
+
os.environ.setdefault("HOME", "/tmp") # fixes expanduser("~")
|
| 18 |
+
os.environ.setdefault("STREAMLIT_HOME", "/tmp/.st_home") # Streamlit telemetry
|
| 19 |
+
os.environ.setdefault("HF_HOME", "/tmp/hf_cache") # Hub model cache
|
| 20 |
+
# --------------------------------------------------------------------
|
| 21 |
+
|
| 22 |
+
# create the dirs once
|
| 23 |
+
for _dir in (os.environ["STREAMLIT_HOME"], os.environ["HF_HOME"]):
|
| 24 |
+
pathlib.Path(_dir).mkdir(parents=True, exist_ok=True)
|
| 25 |
+
|
| 26 |
+
# disable usage-stats banner *before* importing streamlit
|
| 27 |
+
os.environ["STREAMLIT_BROWSER_GATHERUSAGESTATS"] = "false"
|
| 28 |
+
|
| 29 |
+
|
| 30 |
from __future__ import annotations
|
| 31 |
+
import random
|
| 32 |
+
from pathlib import Path
|
| 33 |
|
|
|
|
|
|
|
| 34 |
from typing import Dict, List
|
| 35 |
|
| 36 |
import requests
|
|
|
|
| 38 |
|
| 39 |
from draft_model import DraftModel
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
SUPPORTED_SETS_PATH = Path("supported_sets.txt")
|
| 42 |
st.write("Running Streamlit", st.__version__)
|
| 43 |
|