parkkyujin commited on
Commit
9847980
ยท
verified ยท
1 Parent(s): 652d812

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +13 -7
streamlit_app.py CHANGED
@@ -14,17 +14,23 @@ from datetime import datetime
14
 
15
  # ํ™˜๊ฒฝ ์„ค์ • (๊ถŒํ•œ ๋ฌธ์ œ ํ•ด๊ฒฐ)
16
  os.environ['STREAMLIT_BROWSER_GATHER_USAGE_STATS'] = 'false'
17
- # ์บ์‹œ ๊ฒฝ๋กœ๋ฅผ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋กœ ๋ณ€๊ฒฝ ์‹œ๋„ (์“ฐ๊ธฐ ๊ถŒํ•œ ๋ฌธ์ œ ๋ฐฉ์ง€)
18
- APP_ROOT = os.path.dirname(os.path.abspath(__file__))
19
- TRANSFORMERS_CACHE_DIR = os.path.join(APP_ROOT, '.cache', 'transformers')
20
- SENTENCE_TRANSFORMERS_HOME_DIR = os.path.join(APP_ROOT, '.cache', 'sentence_transformers')
 
21
 
22
  os.environ['TRANSFORMERS_CACHE'] = TRANSFORMERS_CACHE_DIR
23
  os.environ['SENTENCE_TRANSFORMERS_HOME'] = SENTENCE_TRANSFORMERS_HOME_DIR
24
 
25
- # ์บ์‹œ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ (์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด)
26
- os.makedirs(TRANSFORMERS_CACHE_DIR, exist_ok=True)
27
- os.makedirs(SENTENCE_TRANSFORMERS_HOME_DIR, exist_ok=True)
 
 
 
 
 
28
 
29
 
30
  # ํŽ˜์ด์ง€ ์„ค์ •
 
14
 
15
  # ํ™˜๊ฒฝ ์„ค์ • (๊ถŒํ•œ ๋ฌธ์ œ ํ•ด๊ฒฐ)
16
  os.environ['STREAMLIT_BROWSER_GATHER_USAGE_STATS'] = 'false'
17
+
18
+ # ์บ์‹œ ๊ฒฝ๋กœ๋ฅผ /tmp ๋กœ ์„ค์ • (Hugging Face Spaces์—์„œ ๊ถŒ์žฅ๋˜๋Š” ์“ฐ๊ธฐ ๊ฐ€๋Šฅ ๊ฒฝ๋กœ)
19
+ TMP_DIR = "/tmp"
20
+ TRANSFORMERS_CACHE_DIR = os.path.join(TMP_DIR, '.cache', 'transformers')
21
+ SENTENCE_TRANSFORMERS_HOME_DIR = os.path.join(TMP_DIR, '.cache', 'sentence_transformers')
22
 
23
  os.environ['TRANSFORMERS_CACHE'] = TRANSFORMERS_CACHE_DIR
24
  os.environ['SENTENCE_TRANSFORMERS_HOME'] = SENTENCE_TRANSFORMERS_HOME_DIR
25
 
26
+ # ์บ์‹œ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ (์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด) - /tmp ์•„๋ž˜๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ์ƒ์„ฑ ๊ฐ€๋Šฅ
27
+ try:
28
+ os.makedirs(TRANSFORMERS_CACHE_DIR, exist_ok=True)
29
+ os.makedirs(SENTENCE_TRANSFORMERS_HOME_DIR, exist_ok=True)
30
+ except PermissionError:
31
+ st.warning(f"โš ๏ธ ์บ์‹œ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ ๊ถŒํ•œ ์—†์Œ: {TRANSFORMERS_CACHE_DIR} ๋˜๋Š” {SENTENCE_TRANSFORMERS_HOME_DIR}. ๋ชจ๋ธ ๋‹ค์šด๋กœ๋“œ๊ฐ€ ๋А๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.")
32
+ except Exception as e_mkdir:
33
+ st.warning(f"โš ๏ธ ์บ์‹œ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {e_mkdir}")
34
 
35
 
36
  # ํŽ˜์ด์ง€ ์„ค์ •