File size: 1,253 Bytes
21ffb3d
 
 
 
 
 
 
 
0ac914c
21ffb3d
 
afee34c
21ffb3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82a7fde
21ffb3d
 
 
 
 
 
 
82a7fde
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
41
42
import os
from pathlib import Path
from git import Repo
import sys 

# ---- 1. pick a writable base dir (we'll stop using /app)
BASE_DIR = Path("/tmp/gl_runtime")
STREAMLIT_DIR = BASE_DIR / ".streamlit"
REPO_TARGET = BASE_DIR / "gl"  

# ensure the base dir exists 
BASE_DIR.mkdir(parents=True, exist_ok=True) 
STREAMLIT_DIR.mkdir(parents=True, exist_ok=True)

# ---- 2. tell Streamlit to treat /tmp/... as "home"
os.environ.setdefault("HOME", str(BASE_DIR))
os.environ.setdefault("XDG_CONFIG_HOME", str(BASE_DIR))
os.environ.setdefault("STREAMLIT_CONFIG_DIR", str(STREAMLIT_DIR))
os.environ.setdefault("STREAMLIT_HOME", str(BASE_DIR))
os.environ.setdefault("STREAMLIT_BROWSER_GATHERUSAGESTATS", "false")

# ---- 3. clone private repo into /tmp/gl_runtime/gl if not already there
if not REPO_TARGET.exists():
    git_url = os.environ.get("GIT_URL")
    if not git_url:
        raise RuntimeError("GIT_URL env var is not set")
    Repo.clone_from(git_url, REPO_TARGET)

# make that repo importable
sys.path.append(str(REPO_TARGET))

# ---- 4. now safe to import streamlit and run the app
import streamlit as st
import gl
#st.write("repo loaded from", str(REPO_TARGET))
#st.image("huniutoo.png")
#st.image("gwecon.png")
gl.gl() 

# ...rest of your UI...