Spaces:
Sleeping
Sleeping
add local test
Browse files- HF_SECRETS_์ค์ .md +0 -65
- README.md +9 -91
- app.py +9 -2
- env_example.txt +0 -10
- requirements.txt +1 -0
- start.py +47 -1
- test_api.sh +76 -0
- ๊ฒ์_๊ฒฐ๊ณผ.md +0 -237
- ๋ฐฐํฌ_์ฒดํฌ๋ฆฌ์คํธ.md +0 -191
HF_SECRETS_์ค์ .md
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
# ๐ Hugging Face Secrets ์ค์ ๊ฐ์ด๋
|
| 2 |
-
|
| 3 |
-
## ๐ ์ค์ ํ 5๊ฐ Secrets
|
| 4 |
-
|
| 5 |
-
Hugging Face Space โ Settings โ Repository secrets โ New secret
|
| 6 |
-
|
| 7 |
-
### 1๏ธโฃ DB_USER
|
| 8 |
-
```
|
| 9 |
-
Value: ADMIN
|
| 10 |
-
```
|
| 11 |
-
|
| 12 |
-
### 2๏ธโฃ DB_PASSWORD
|
| 13 |
-
```
|
| 14 |
-
Value: Oracle_DB_๋น๋ฐ๋ฒํธ
|
| 15 |
-
```
|
| 16 |
-
(Oracle Cloud Console์์ ํ์ธ ๋๋ ์ฌ์ค์ )
|
| 17 |
-
|
| 18 |
-
### 3๏ธโฃ DB_TNS_ALIAS
|
| 19 |
-
```
|
| 20 |
-
Value: musclecare_high
|
| 21 |
-
```
|
| 22 |
-
(wallet/tnsnames.ora์์ ํ์ธํ ์ด๋ฆ)
|
| 23 |
-
|
| 24 |
-
### 4๏ธโฃ WALLET_ZIP_B64 โญ ๊ฐ์ฅ ์ค์!
|
| 25 |
-
```
|
| 26 |
-
Value: (wallet_base64.txt ํ์ผ ์ ์ฒด ๋ด์ฉ)
|
| 27 |
-
```
|
| 28 |
-
|
| 29 |
-
**์์ฑ ๋ฐฉ๋ฒ:**
|
| 30 |
-
```bash
|
| 31 |
-
# Wallet zip ํ์ผ์ Base64๋ก ์ธ์ฝ๋ฉ
|
| 32 |
-
base64 -i ~/Downloads/Wallet_musclecare.zip -o wallet_base64.txt
|
| 33 |
-
|
| 34 |
-
# wallet_base64.txt ํ์ผ ์ด์ด์ ์ ์ฒด ๋ณต์ฌ
|
| 35 |
-
cat wallet_base64.txt | pbcopy # Mac
|
| 36 |
-
```
|
| 37 |
-
|
| 38 |
-
### 5๏ธโฃ WALLET_PASSWORD
|
| 39 |
-
```
|
| 40 |
-
Value: Wallet_๋ค์ด๋ก๋์_์ค์ ํ_๋น๋ฐ๋ฒํธ
|
| 41 |
-
```
|
| 42 |
-
|
| 43 |
-
---
|
| 44 |
-
|
| 45 |
-
## โ
์ค์ ์๋ฃ ํ
|
| 46 |
-
|
| 47 |
-
```bash
|
| 48 |
-
git push
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
์๋์ผ๋ก ๋ฐฐํฌ๋ฉ๋๋ค!
|
| 52 |
-
|
| 53 |
-
---
|
| 54 |
-
|
| 55 |
-
## ๐งช ๋ฐฐํฌ ํ์ธ
|
| 56 |
-
|
| 57 |
-
```bash
|
| 58 |
-
curl https://[username]-musclecare-api.hf.space/health
|
| 59 |
-
```
|
| 60 |
-
|
| 61 |
-
**์ฑ๊ณต ์๋ต:**
|
| 62 |
-
```json
|
| 63 |
-
{"ok": true, "db": 1}
|
| 64 |
-
```
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -1,93 +1,11 @@
|
|
| 1 |
-
# ๐๏ธ MuscleCare FastAPI
|
| 2 |
-
|
| 3 |
-
Oracle Autonomous Database ์ฐ๋ FastAPI ์๋ฒ (Wallet ๊ธฐ๋ฐ mTLS)
|
| 4 |
-
|
| 5 |
-
## ๐ ์ฃผ์ ๊ธฐ๋ฅ
|
| 6 |
-
|
| 7 |
-
- ๐ **Wallet ๊ธฐ๋ฐ mTLS ์ฐ๊ฒฐ** - ์ต๊ณ ๋ณด์ ์์ค
|
| 8 |
-
- ๐ค **์ฌ์ฉ์ ์ํ ์
๋ก๋/๋ค์ด๋ก๋** - baseline + user_emb
|
| 9 |
-
- ๐ **ํผ๋ก๋ ๋ก๊ทธ ์ ์ฅ** - Oracle DB์ ์์ ํ๊ฒ ์ ์ฅ
|
| 10 |
-
|
| 11 |
---
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
---
|
| 22 |
-
|
| 23 |
-
## ๐ Hugging Face Space ๋ฐฐํฌ
|
| 24 |
-
|
| 25 |
-
### 1. Wallet Base64 ์ธ์ฝ๋ฉ
|
| 26 |
-
|
| 27 |
-
```bash
|
| 28 |
-
base64 -i ~/Downloads/Wallet_musclecare.zip -o wallet_base64.txt
|
| 29 |
-
```
|
| 30 |
-
|
| 31 |
-
### 2. Hugging Face Secrets ์ค์ (5๊ฐ)
|
| 32 |
-
|
| 33 |
-
**Settings โ Repository secrets**
|
| 34 |
-
|
| 35 |
-
| Secret | Value |
|
| 36 |
-
|--------|-------|
|
| 37 |
-
| `DB_USER` | `ADMIN` |
|
| 38 |
-
| `DB_PASSWORD` | Oracle DB ๋น๋ฐ๋ฒํธ |
|
| 39 |
-
| `DB_TNS_ALIAS` | `musclecare_high` |
|
| 40 |
-
| `WALLET_ZIP_B64` | wallet_base64.txt ์ ์ฒด ๋ด์ฉ |
|
| 41 |
-
| `WALLET_PASSWORD` | Wallet ๋น๋ฐ๋ฒํธ |
|
| 42 |
-
|
| 43 |
-
### 3. Git Push
|
| 44 |
-
|
| 45 |
-
```bash
|
| 46 |
-
git push
|
| 47 |
-
```
|
| 48 |
-
|
| 49 |
-
**์๋ ๋ฐฐํฌ!** `start.py`๊ฐ Wallet์ ์๋์ผ๋ก ๋์ฝ๋ฉํ๊ณ ์๋ฒ๋ฅผ ์์ํฉ๋๋ค.
|
| 50 |
-
|
| 51 |
-
---
|
| 52 |
-
|
| 53 |
-
## ๐งช ํ
์คํธ
|
| 54 |
-
|
| 55 |
-
### ๋ฐฐํฌ ํ:
|
| 56 |
-
|
| 57 |
-
```bash
|
| 58 |
-
# ํฌ์ค ์ฒดํฌ
|
| 59 |
-
curl https://[username]-musclecare-api.hf.space/health
|
| 60 |
-
|
| 61 |
-
# API ๋ฌธ์
|
| 62 |
-
https://[username]-musclecare-api.hf.space/docs
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
### ๋ก์ปฌ ํ
์คํธ:
|
| 66 |
-
|
| 67 |
-
```bash
|
| 68 |
-
# .env ํ์ผ ์์ฑ
|
| 69 |
-
cp env_example.txt .env
|
| 70 |
-
nano .env # ์ค์ ๊ฐ ์
๋ ฅ
|
| 71 |
-
|
| 72 |
-
# ์๋ฒ ์คํ
|
| 73 |
-
python app.py
|
| 74 |
-
```
|
| 75 |
-
|
| 76 |
-
---
|
| 77 |
-
|
| 78 |
-
## ๐ ์์ธ ๊ฐ์ด๋
|
| 79 |
-
|
| 80 |
-
- **HF_SECRETS_์ค์ .md** - Secrets ์ค์ ๋ฐฉ๋ฒ
|
| 81 |
-
- **DATA_ARCHITECTURE.md** - ์ ์ฒด ์ํคํ
์ฒ
|
| 82 |
-
|
| 83 |
-
---
|
| 84 |
-
|
| 85 |
-
## ๐ ๋ณด์
|
| 86 |
-
|
| 87 |
-
- โ
`.gitignore` - .env, wallet/ ์ ์ธ
|
| 88 |
-
- โ
Wallet Base64๋ก ์์ ํ๊ฒ ๋ฐฐํฌ
|
| 89 |
-
- โ
Secrets๋ก ํ๊ฒฝ ๋ณ์ ๊ด๋ฆฌ
|
| 90 |
-
|
| 91 |
-
---
|
| 92 |
-
|
| 93 |
-
Made with โค๏ธ for MuscleCare
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: MuscleCare API
|
| 3 |
+
emoji: ๐๏ธ
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
sdk_version: "3.10"
|
| 8 |
+
app_file: start.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -2,8 +2,13 @@ import os
|
|
| 2 |
import json
|
| 3 |
from typing import List, Optional
|
| 4 |
from fastapi import FastAPI, HTTPException
|
| 5 |
-
from pydantic import BaseModel, Field,
|
|
|
|
| 6 |
import oracledb
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# ----- ํ๊ฒฝ ๋ณ์ -----
|
| 9 |
DB_USER = os.environ["DB_USER"]
|
|
@@ -33,6 +38,8 @@ app = FastAPI(title="MuscleCare Hybrid Server (mTLS)")
|
|
| 33 |
|
| 34 |
# ----- ๋ชจ๋ธ -----
|
| 35 |
class StatePayload(BaseModel):
|
|
|
|
|
|
|
| 36 |
user_id: str
|
| 37 |
rms_base: Optional[float] = None
|
| 38 |
freq_base: Optional[float] = None
|
|
@@ -50,7 +57,7 @@ class LogItem(BaseModel):
|
|
| 50 |
window_count: Optional[int] = None
|
| 51 |
|
| 52 |
class LogsPayload(BaseModel):
|
| 53 |
-
items:
|
| 54 |
|
| 55 |
# ----- ์ ํธ -----
|
| 56 |
def clob_json(obj) -> str:
|
|
|
|
| 2 |
import json
|
| 3 |
from typing import List, Optional
|
| 4 |
from fastapi import FastAPI, HTTPException
|
| 5 |
+
from pydantic import BaseModel, Field, ConfigDict
|
| 6 |
+
from typing import List
|
| 7 |
import oracledb
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
+
|
| 10 |
+
# ๋ก์ปฌ ๊ฐ๋ฐ: .env ํ์ผ ๋ก๋ (์์ผ๋ฉด)
|
| 11 |
+
load_dotenv()
|
| 12 |
|
| 13 |
# ----- ํ๊ฒฝ ๋ณ์ -----
|
| 14 |
DB_USER = os.environ["DB_USER"]
|
|
|
|
| 38 |
|
| 39 |
# ----- ๋ชจ๋ธ -----
|
| 40 |
class StatePayload(BaseModel):
|
| 41 |
+
model_config = ConfigDict(protected_namespaces=())
|
| 42 |
+
|
| 43 |
user_id: str
|
| 44 |
rms_base: Optional[float] = None
|
| 45 |
freq_base: Optional[float] = None
|
|
|
|
| 57 |
window_count: Optional[int] = None
|
| 58 |
|
| 59 |
class LogsPayload(BaseModel):
|
| 60 |
+
items: List[LogItem] = Field(..., min_length=1)
|
| 61 |
|
| 62 |
# ----- ์ ํธ -----
|
| 63 |
def clob_json(obj) -> str:
|
env_example.txt
DELETED
|
@@ -1,10 +0,0 @@
|
|
| 1 |
-
# ๋ก์ปฌ ๊ฐ๋ฐ์ฉ ํ๊ฒฝ ๋ณ์ ์์
|
| 2 |
-
# ์ด ํ์ผ์ .env๋ก ๋ณต์ฌํ๊ณ ์ค์ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํ์ธ์
|
| 3 |
-
# cp env_example.txt .env
|
| 4 |
-
|
| 5 |
-
DB_USER=ADMIN
|
| 6 |
-
DB_PASSWORD=your_db_password_here
|
| 7 |
-
DB_TNS_ALIAS=musclecare_high
|
| 8 |
-
WALLET_DIR=/Users/gimhyeon-u/workspace/MuscleCare-FastAPI/wallet
|
| 9 |
-
WALLET_PASSWORD=your_wallet_password_here
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -3,3 +3,4 @@ uvicorn
|
|
| 3 |
python-multipart
|
| 4 |
oracledb>=2.3
|
| 5 |
pydantic
|
|
|
|
|
|
| 3 |
python-multipart
|
| 4 |
oracledb>=2.3
|
| 5 |
pydantic
|
| 6 |
+
python-dotenv
|
start.py
CHANGED
|
@@ -1,23 +1,69 @@
|
|
| 1 |
import os, base64, zipfile, io, sys, tempfile, subprocess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def prepare_wallet_dir():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
b64 = os.environ["WALLET_ZIP_B64"]
|
| 5 |
wallet_password = os.environ["WALLET_PASSWORD"]
|
|
|
|
| 6 |
# wallet์ ๋ฉ๋ชจ๋ฆฌ->์์๋๋ ํ ๋ฆฌ๋ก ๋ณต์
|
| 7 |
wallet_dir = tempfile.mkdtemp(prefix="wallet_")
|
|
|
|
|
|
|
| 8 |
zip_bytes = base64.b64decode(b64)
|
| 9 |
with zipfile.ZipFile(io.BytesIO(zip_bytes)) as z:
|
| 10 |
z.extractall(wallet_dir)
|
|
|
|
| 11 |
# ์์ ์ ์ํด ๊ถํ ์ถ์
|
| 12 |
for root, _, files in os.walk(wallet_dir):
|
| 13 |
for f in files:
|
| 14 |
os.chmod(os.path.join(root, f), 0o600)
|
|
|
|
|
|
|
|
|
|
| 15 |
# ์ง๊ฐ ๋น๋ฐ๋ฒํธ๋ oracledb์์ ์ฌ์ฉ
|
| 16 |
os.environ["WALLET_DIR"] = wallet_dir
|
| 17 |
os.environ["WALLET_PASSWORD"] = wallet_password
|
|
|
|
| 18 |
return wallet_dir
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Uvicorn ๊ธฐ๋
|
|
|
|
|
|
|
| 23 |
subprocess.run([sys.executable, "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"])
|
|
|
|
| 1 |
import os, base64, zipfile, io, sys, tempfile, subprocess
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
# .env ํ์ผ ๋ก๋ (๋ก์ปฌ ๊ฐ๋ฐ์ฉ)
|
| 6 |
+
load_dotenv()
|
| 7 |
|
| 8 |
def prepare_wallet_dir():
|
| 9 |
+
"""
|
| 10 |
+
Wallet ์ค๋น:
|
| 11 |
+
- ๋ฐฐํฌ ํ๊ฒฝ: WALLET_ZIP_B64์์ ๋์ฝ๋ฉ
|
| 12 |
+
- ๋ก์ปฌ ํ๊ฒฝ: WALLET_DIR ๊ฒฝ๋ก ์ฌ์ฉ
|
| 13 |
+
"""
|
| 14 |
+
# ๋ก์ปฌ ๊ฐ๋ฐ: WALLET_DIR์ด ์ด๋ฏธ ์ค์ ๋์ด ์๋ ๊ฒฝ์ฐ
|
| 15 |
+
if "WALLET_DIR" in os.environ:
|
| 16 |
+
wallet_dir = os.environ["WALLET_DIR"]
|
| 17 |
+
if Path(wallet_dir).exists():
|
| 18 |
+
print(f"๐ ๋ก์ปฌ Wallet ์ฌ์ฉ: {wallet_dir}")
|
| 19 |
+
return wallet_dir
|
| 20 |
+
|
| 21 |
+
# ๋ฐฐํฌ ํ๊ฒฝ: WALLET_ZIP_B64์์ ๋์ฝ๋ฉ
|
| 22 |
+
if "WALLET_ZIP_B64" not in os.environ:
|
| 23 |
+
raise RuntimeError(
|
| 24 |
+
"โ WALLET_ZIP_B64 ๋๋ WALLET_DIR ํ๊ฒฝ ๋ณ์๊ฐ ํ์ํฉ๋๋ค.\n"
|
| 25 |
+
" ๋ก์ปฌ: .env ํ์ผ์ WALLET_DIR ์ค์ \n"
|
| 26 |
+
" ๋ฐฐํฌ: Hugging Face Secrets์ WALLET_ZIP_B64 ์ค์ "
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
print("๐ Wallet Base64 ๋์ฝ๋ฉ ์์...")
|
| 30 |
b64 = os.environ["WALLET_ZIP_B64"]
|
| 31 |
wallet_password = os.environ["WALLET_PASSWORD"]
|
| 32 |
+
|
| 33 |
# wallet์ ๋ฉ๋ชจ๋ฆฌ->์์๋๋ ํ ๋ฆฌ๋ก ๋ณต์
|
| 34 |
wallet_dir = tempfile.mkdtemp(prefix="wallet_")
|
| 35 |
+
print(f"๐ ์์ ๋๋ ํ ๋ฆฌ: {wallet_dir}")
|
| 36 |
+
|
| 37 |
zip_bytes = base64.b64decode(b64)
|
| 38 |
with zipfile.ZipFile(io.BytesIO(zip_bytes)) as z:
|
| 39 |
z.extractall(wallet_dir)
|
| 40 |
+
|
| 41 |
# ์์ ์ ์ํด ๊ถํ ์ถ์
|
| 42 |
for root, _, files in os.walk(wallet_dir):
|
| 43 |
for f in files:
|
| 44 |
os.chmod(os.path.join(root, f), 0o600)
|
| 45 |
+
|
| 46 |
+
print("โ
Wallet ์์ถ ํด์ ์๋ฃ")
|
| 47 |
+
|
| 48 |
# ์ง๊ฐ ๋น๋ฐ๋ฒํธ๋ oracledb์์ ์ฌ์ฉ
|
| 49 |
os.environ["WALLET_DIR"] = wallet_dir
|
| 50 |
os.environ["WALLET_PASSWORD"] = wallet_password
|
| 51 |
+
|
| 52 |
return wallet_dir
|
| 53 |
|
| 54 |
if __name__ == "__main__":
|
| 55 |
+
print("=" * 60)
|
| 56 |
+
print("๐ MuscleCare FastAPI ์๋ฒ ์์")
|
| 57 |
+
print("=" * 60)
|
| 58 |
+
|
| 59 |
+
# Wallet ์ค๋น
|
| 60 |
+
try:
|
| 61 |
+
prepare_wallet_dir()
|
| 62 |
+
except Exception as e:
|
| 63 |
+
print(f"โ Wallet ์ค๋น ์คํจ: {e}")
|
| 64 |
+
sys.exit(1)
|
| 65 |
+
|
| 66 |
# Uvicorn ๊ธฐ๋
|
| 67 |
+
print("\n๐ FastAPI ์๋ฒ ์คํ...")
|
| 68 |
+
print("=" * 60)
|
| 69 |
subprocess.run([sys.executable, "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"])
|
test_api.sh
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# MuscleCare API ํ
์คํธ ์คํฌ๋ฆฝํธ
|
| 4 |
+
|
| 5 |
+
# ์๋ฒ URL ์ค์
|
| 6 |
+
# ๋ก์ปฌ: http://localhost:7860
|
| 7 |
+
# ๋ฐฐํฌ: https://[username]-musclecare-api.hf.space
|
| 8 |
+
BASE_URL="${1:-http://localhost:7860}"
|
| 9 |
+
|
| 10 |
+
echo "======================================"
|
| 11 |
+
echo "๐งช MuscleCare API ํ
์คํธ"
|
| 12 |
+
echo "======================================"
|
| 13 |
+
echo "์๋ฒ: $BASE_URL"
|
| 14 |
+
echo ""
|
| 15 |
+
|
| 16 |
+
# 1. Health ์ฒดํฌ
|
| 17 |
+
echo "1๏ธโฃ Health ์ฒดํฌ"
|
| 18 |
+
echo "--------------------------------------"
|
| 19 |
+
curl -X GET "$BASE_URL/health" \
|
| 20 |
+
-H "accept: application/json" | jq .
|
| 21 |
+
echo ""
|
| 22 |
+
echo ""
|
| 23 |
+
|
| 24 |
+
# 2. ์ฌ์ฉ์ ์ํ ์
๋ก๋
|
| 25 |
+
echo "2๏ธโฃ ์ฌ์ฉ์ ์ํ ์
๋ก๋"
|
| 26 |
+
echo "--------------------------------------"
|
| 27 |
+
curl -X POST "$BASE_URL/upload_state" \
|
| 28 |
+
-H "Content-Type: application/json" \
|
| 29 |
+
-H "accept: application/json" \
|
| 30 |
+
-d '{
|
| 31 |
+
"user_id": "test_user_001",
|
| 32 |
+
"rms_base": 0.11,
|
| 33 |
+
"freq_base": 50.1,
|
| 34 |
+
"user_emb": [0.135, 0.012, 49.3, 0.8, 0.84, 0.02, 0.11, 0.0021, 0.35, 0.71, 0.92, 0.88],
|
| 35 |
+
"model_version": "v1.0.0"
|
| 36 |
+
}' | jq .
|
| 37 |
+
echo ""
|
| 38 |
+
echo ""
|
| 39 |
+
|
| 40 |
+
# 3. ํผ๋ก๋ ๋ก๊ทธ ์
๋ก๋
|
| 41 |
+
echo "3๏ธโฃ ํผ๋ก๋ ๋ก๊ทธ ์
๋ก๋"
|
| 42 |
+
echo "--------------------------------------"
|
| 43 |
+
curl -X POST "$BASE_URL/upload_logs" \
|
| 44 |
+
-H "Content-Type: application/json" \
|
| 45 |
+
-H "accept: application/json" \
|
| 46 |
+
-d '{
|
| 47 |
+
"items": [
|
| 48 |
+
{
|
| 49 |
+
"user_id": "test_user_001",
|
| 50 |
+
"session_id": "session_001",
|
| 51 |
+
"measure_date": "2025-10-22",
|
| 52 |
+
"rms": 0.12,
|
| 53 |
+
"freq": 49.8,
|
| 54 |
+
"fatigue": 0.83,
|
| 55 |
+
"mode": "Hybrid",
|
| 56 |
+
"window_count": 100
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"user_id": "test_user_001",
|
| 60 |
+
"session_id": "session_002",
|
| 61 |
+
"measure_date": "2025-10-22",
|
| 62 |
+
"rms": 0.15,
|
| 63 |
+
"freq": 48.5,
|
| 64 |
+
"fatigue": 0.91,
|
| 65 |
+
"mode": "E2E",
|
| 66 |
+
"window_count": 120
|
| 67 |
+
}
|
| 68 |
+
]
|
| 69 |
+
}' | jq .
|
| 70 |
+
echo ""
|
| 71 |
+
echo ""
|
| 72 |
+
|
| 73 |
+
echo "======================================"
|
| 74 |
+
echo "โ
ํ
์คํธ ์๋ฃ"
|
| 75 |
+
echo "======================================"
|
| 76 |
+
|
๊ฒ์_๊ฒฐ๊ณผ.md
DELETED
|
@@ -1,237 +0,0 @@
|
|
| 1 |
-
# โ
์ ์ฒด ๊ฒ์ ๊ฒฐ๊ณผ
|
| 2 |
-
|
| 3 |
-
## ๐ ๊ฒ์ ์๋ฃ - ๋ฐฐํฌ ์ค๋น ์๋ฃ!
|
| 4 |
-
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
## ๐ฏ ํต์ฌ ํ์ผ ๊ตฌ์กฐ
|
| 8 |
-
|
| 9 |
-
```
|
| 10 |
-
MuscleCare-FastAPI/
|
| 11 |
-
โโโ start.py โ
Wallet ๋์ฝ๋ฉ + ์๋ฒ ๋ถํ
|
| 12 |
-
โโโ app.py โ
FastAPI ์ฑ (๊ฐ์ํ๋จ)
|
| 13 |
-
โโโ Dockerfile โ
start.py ์คํ
|
| 14 |
-
โโโ requirements.txt โ
์์กด์ฑ
|
| 15 |
-
โโโ .gitignore โ
๋ณด์ ํ์ผ ์ ์ธ
|
| 16 |
-
โโโ README.md โ
ํ๋ก์ ํธ ์ค๋ช
|
| 17 |
-
โโโ env_example.txt โ
ํ๊ฒฝ ๋ณ์ ์์
|
| 18 |
-
```
|
| 19 |
-
|
| 20 |
-
---
|
| 21 |
-
|
| 22 |
-
## โ
์ฝ๋ ๊ฒ์ ๊ฒฐ๊ณผ
|
| 23 |
-
|
| 24 |
-
### 1. start.py โ
|
| 25 |
-
```python
|
| 26 |
-
โ
WALLET_ZIP_B64 ํ๊ฒฝ ๋ณ์ ์ฝ๊ธฐ
|
| 27 |
-
โ
Base64 ๋์ฝ๋ฉ
|
| 28 |
-
โ
zipfile๋ก ์์ถ ํด์
|
| 29 |
-
โ
์์ ๋๋ ํ ๋ฆฌ ์์ฑ (/tmp/wallet_)
|
| 30 |
-
โ
ํ์ผ ๊ถํ ์ค์ (0o600)
|
| 31 |
-
โ
WALLET_DIR, WALLET_PASSWORD ํ๊ฒฝ ๋ณ์ ์ค์
|
| 32 |
-
โ
uvicorn subprocess ์คํ
|
| 33 |
-
```
|
| 34 |
-
|
| 35 |
-
**์๋ ํ๋ฆ:**
|
| 36 |
-
```
|
| 37 |
-
start.py ์คํ
|
| 38 |
-
โ
|
| 39 |
-
prepare_wallet_dir()
|
| 40 |
-
โ
|
| 41 |
-
ํ๊ฒฝ ๋ณ์: WALLET_DIR, WALLET_PASSWORD ์ค์
|
| 42 |
-
โ
|
| 43 |
-
uvicorn app:app ์คํ
|
| 44 |
-
โ
|
| 45 |
-
app.py๊ฐ WALLET_DIR ์ฌ์ฉ
|
| 46 |
-
```
|
| 47 |
-
|
| 48 |
-
### 2. app.py โ
|
| 49 |
-
```python
|
| 50 |
-
โ
ํ๊ฒฝ ๋ณ์ ์ฝ๊ธฐ:
|
| 51 |
-
- DB_USER
|
| 52 |
-
- DB_PASSWORD
|
| 53 |
-
- WALLET_DIR (start.py๊ฐ ์ค์ )
|
| 54 |
-
- WALLET_PASSWORD (start.py๊ฐ ์ค์ )
|
| 55 |
-
- DB_TNS_ALIAS
|
| 56 |
-
|
| 57 |
-
โ
oracledb.create_pool():
|
| 58 |
-
- user, password
|
| 59 |
-
- dsn=TNS_ALIAS
|
| 60 |
-
- config_dir=WALLET_DIR
|
| 61 |
-
- wallet_location=WALLET_DIR
|
| 62 |
-
- wallet_password=WALLET_PASSWORD
|
| 63 |
-
|
| 64 |
-
โ
์๋ํฌ์ธํธ:
|
| 65 |
-
- GET /health โ DB ์ฐ๊ฒฐ ํ
์คํธ
|
| 66 |
-
- POST /upload_state โ user_state ํ
์ด๋ธ UPSERT
|
| 67 |
-
- POST /upload_logs โ fatigue_logs ํ
์ด๋ธ INSERT
|
| 68 |
-
```
|
| 69 |
-
|
| 70 |
-
### 3. Dockerfile โ
|
| 71 |
-
```dockerfile
|
| 72 |
-
โ
Python 3.10-slim
|
| 73 |
-
โ
requirements.txt ์ค์น
|
| 74 |
-
โ
์ฝ๋ ๋ณต์ฌ
|
| 75 |
-
โ
CMD ["python", "start.py"] โ ์ค์!
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
### 4. requirements.txt โ
|
| 79 |
-
```
|
| 80 |
-
โ
fastapi
|
| 81 |
-
โ
uvicorn
|
| 82 |
-
โ
python-multipart
|
| 83 |
-
โ
oracledb>=2.3
|
| 84 |
-
โ
pydantic
|
| 85 |
-
```
|
| 86 |
-
|
| 87 |
-
### 5. .gitignore โ
|
| 88 |
-
```
|
| 89 |
-
โ
.env
|
| 90 |
-
โ
wallet/
|
| 91 |
-
โ
*.zip
|
| 92 |
-
โ
wallet_base64.txt
|
| 93 |
-
โ
__pycache__/
|
| 94 |
-
```
|
| 95 |
-
|
| 96 |
-
---
|
| 97 |
-
|
| 98 |
-
## ๐ ๋ณด์ ๊ฒ์
|
| 99 |
-
|
| 100 |
-
### โ
Git ์ ์ธ ํ์ผ
|
| 101 |
-
```bash
|
| 102 |
-
git status | grep -E "(\.env|wallet/)"
|
| 103 |
-
```
|
| 104 |
-
**๊ฒฐ๊ณผ:** `.gitignore` ํ์ธ โ ์ ์ธ๋จ โ
|
| 105 |
-
|
| 106 |
-
### โ
ํ๊ฒฝ ๋ณ์ ์ฌ์ฉ
|
| 107 |
-
- ๋ชจ๋ ๋ฏผ๊ฐ ์ ๋ณด๋ ํ๊ฒฝ ๋ณ์๋ก ๊ด๋ฆฌ
|
| 108 |
-
- ์ฝ๋์ ํ๋์ฝ๋ฉ ์์
|
| 109 |
-
|
| 110 |
-
### โ
Wallet ๋ณดํธ
|
| 111 |
-
- Git์ ํฌํจ ์ ๋จ
|
| 112 |
-
- Base64๋ก Secrets์ ์์ ํ๊ฒ ์ ์ฅ
|
| 113 |
-
|
| 114 |
-
---
|
| 115 |
-
|
| 116 |
-
## ๐ก API ๊ฒ์
|
| 117 |
-
|
| 118 |
-
### ์๋ํฌ์ธํธ ๊ตฌ์กฐ
|
| 119 |
-
|
| 120 |
-
#### GET /health
|
| 121 |
-
```python
|
| 122 |
-
โ
pool.acquire() ์ฌ์ฉ
|
| 123 |
-
โ
SELECT 1 FROM DUAL
|
| 124 |
-
โ
์ฐ๊ฒฐ ์ํ ๋ฐํ
|
| 125 |
-
```
|
| 126 |
-
|
| 127 |
-
#### POST /upload_state
|
| 128 |
-
```python
|
| 129 |
-
โ
StatePayload ๊ฒ์ฆ
|
| 130 |
-
โ
user_emb ๊ธธ์ด ์ฒดํฌ (12)
|
| 131 |
-
โ
MERGE INTO MuscleCare.user_state
|
| 132 |
-
โ
CLOB JSON ์ ์ฅ
|
| 133 |
-
โ
ํธ๋์ญ์
commit
|
| 134 |
-
```
|
| 135 |
-
|
| 136 |
-
#### POST /upload_logs
|
| 137 |
-
```python
|
| 138 |
-
โ
LogsPayload ๊ฒ์ฆ
|
| 139 |
-
โ
executemany๋ก ๋ฐฐ์น INSERT
|
| 140 |
-
โ
MuscleCare.fatigue_logs ํ
์ด๋ธ
|
| 141 |
-
โ
ํธ๋์ญ์
commit
|
| 142 |
-
```
|
| 143 |
-
|
| 144 |
-
---
|
| 145 |
-
|
| 146 |
-
## ๐ ๋ฐฐํฌ ํ๋ก์ฐ ๊ฒ์
|
| 147 |
-
|
| 148 |
-
### Hugging Face Space ์คํ ์์:
|
| 149 |
-
|
| 150 |
-
```
|
| 151 |
-
1. Docker ๋น๋
|
| 152 |
-
โ
|
| 153 |
-
2. start.py ์คํ
|
| 154 |
-
โ
|
| 155 |
-
3. prepare_wallet_dir()
|
| 156 |
-
- WALLET_ZIP_B64 ํ๊ฒฝ ๋ณ์ ์ฝ๊ธฐ (Secrets)
|
| 157 |
-
- Base64 ๋์ฝ๋ฉ
|
| 158 |
-
- /tmp/wallet_xxxxx์ ์์ถ ํด์
|
| 159 |
-
- WALLET_DIR ํ๊ฒฝ ๋ณ์ ์ค์
|
| 160 |
-
โ
|
| 161 |
-
4. uvicorn ์คํ
|
| 162 |
-
- app:app ๋ก๋
|
| 163 |
-
โ
|
| 164 |
-
5. app.py ์ด๊ธฐํ
|
| 165 |
-
- ํ๊ฒฝ ๋ณ์ ์ฝ๊ธฐ
|
| 166 |
-
- oracledb.create_pool() (WALLET_DIR ์ฌ์ฉ)
|
| 167 |
-
โ
|
| 168 |
-
6. โ
์๋ฒ ์คํ ์๋ฃ
|
| 169 |
-
```
|
| 170 |
-
|
| 171 |
-
---
|
| 172 |
-
|
| 173 |
-
## ๐งช ํ
์คํธ ์ฒดํฌ๋ฆฌ์คํธ
|
| 174 |
-
|
| 175 |
-
### ๋ก์ปฌ ํ
์คํธ (์ ํ):
|
| 176 |
-
- [ ] wallet/ ๋๋ ํ ๋ฆฌ ์ค๋น
|
| 177 |
-
- [ ] ํ๊ฒฝ ๋ณ์ export
|
| 178 |
-
- [ ] `python app.py` ์คํ
|
| 179 |
-
- [ ] `curl http://localhost:7860/health` ์ฑ๊ณต
|
| 180 |
-
|
| 181 |
-
### ๋ฐฐํฌ ํ ํ
์คํธ (ํ์):
|
| 182 |
-
- [ ] Logs์ "โ
Wallet ์์ถ ํด์ ์๋ฃ"
|
| 183 |
-
- [ ] Logs์ "Uvicorn running"
|
| 184 |
-
- [ ] `curl https://[username]-xxx.hf.space/health`
|
| 185 |
-
- [ ] ์๋ต: `{"ok": true, "db": 1}`
|
| 186 |
-
- [ ] `/docs` ํ์ด์ง ์ ๊ทผ ๊ฐ๋ฅ
|
| 187 |
-
|
| 188 |
-
---
|
| 189 |
-
|
| 190 |
-
## โ ๋ฐ๊ฒฌ๋ ๋ฌธ์ ์
|
| 191 |
-
|
| 192 |
-
### ์์! โ
|
| 193 |
-
|
| 194 |
-
๋ชจ๋ ํ์ผ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๊ตฌ์ฑ๋์์ต๋๋ค.
|
| 195 |
-
|
| 196 |
-
---
|
| 197 |
-
|
| 198 |
-
## ๐ฏ ๋ค์ ๋จ๊ณ
|
| 199 |
-
|
| 200 |
-
### 1. Hugging Face Secrets ์ค์ (5๊ฐ)
|
| 201 |
-
|
| 202 |
-
`HF_SECRETS_์ค์ .md` ์ฐธ์กฐ
|
| 203 |
-
|
| 204 |
-
### 2. Git Push
|
| 205 |
-
|
| 206 |
-
```bash
|
| 207 |
-
git add .
|
| 208 |
-
git commit -m "Ready for deployment"
|
| 209 |
-
git push
|
| 210 |
-
```
|
| 211 |
-
|
| 212 |
-
### 3. ๋ฐฐํฌ ํ์ธ
|
| 213 |
-
|
| 214 |
-
- Logs ํ์ธ
|
| 215 |
-
- API ํ
์คํธ
|
| 216 |
-
- ๋ฌธ์ ํ์ธ
|
| 217 |
-
|
| 218 |
-
---
|
| 219 |
-
|
| 220 |
-
## ๐ ์ต์ข
์์ฝ
|
| 221 |
-
|
| 222 |
-
| ํญ๋ชฉ | ์ํ |
|
| 223 |
-
|------|------|
|
| 224 |
-
| **์ฝ๋ ๊ตฌ์กฐ** | โ
์๋ฒฝ |
|
| 225 |
-
| **๋ณด์** | โ
.gitignore ์ค์ ๋จ |
|
| 226 |
-
| **Wallet ์ฒ๋ฆฌ** | โ
start.py๋ก ์๋ํ |
|
| 227 |
-
| **Docker ์ค์ ** | โ
start.py ์คํ |
|
| 228 |
-
| **ํ๊ฒฝ ๋ณ์** | โ
Secrets๋ก ๊ด๋ฆฌ |
|
| 229 |
-
| **API ๊ตฌ์กฐ** | โ
๊ฐ๊ฒฐํ๊ณ ํจ์จ์ |
|
| 230 |
-
| **๋ฐฐํฌ ์ค๋น** | โ
์๋ฃ |
|
| 231 |
-
|
| 232 |
-
---
|
| 233 |
-
|
| 234 |
-
**๊ฒ์ ๊ฒฐ๊ณผ: ๋ฐฐํฌ ๊ฐ๋ฅ! ๐**
|
| 235 |
-
|
| 236 |
-
Git push๋ง ํ๋ฉด ๋ฉ๋๋ค!
|
| 237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
๋ฐฐํฌ_์ฒดํฌ๋ฆฌ์คํธ.md
DELETED
|
@@ -1,191 +0,0 @@
|
|
| 1 |
-
# โ
๋ฐฐํฌ ์ต์ข
์ฒดํฌ๋ฆฌ์คํธ
|
| 2 |
-
|
| 3 |
-
## ๐ ํ์ผ ๊ตฌ์กฐ ๊ฒ์
|
| 4 |
-
|
| 5 |
-
### โ
ํ์ ํ์ผ (Git์ ํฌํจ)
|
| 6 |
-
- [x] `start.py` - Wallet ๋์ฝ๋ฉ ๋ฐ ์๋ฒ ๋ถํ
|
| 7 |
-
- [x] `app.py` - FastAPI ์ ํ๋ฆฌ์ผ์ด์
|
| 8 |
-
- [x] `Dockerfile` - start.py ์คํ
|
| 9 |
-
- [x] `requirements.txt` - ์์กด์ฑ
|
| 10 |
-
- [x] `.gitignore` - ๋ณด์ ํ์ผ ์ ์ธ
|
| 11 |
-
- [x] `README.md` - ํ๋ก์ ํธ ์ค๋ช
|
| 12 |
-
- [x] `env_example.txt` - ํ๊ฒฝ ๋ณ์ ์์
|
| 13 |
-
|
| 14 |
-
### โ ์ ์ธ ํ์ผ (Git์ ํฌํจ ์ ๋จ)
|
| 15 |
-
- [ ] `.env` - ๋ก์ปฌ ํ๊ฒฝ ๋ณ์
|
| 16 |
-
- [ ] `wallet/` - Wallet ํ์ผ๋ค
|
| 17 |
-
- [ ] `wallet_base64.txt` - Base64 ์ธ์ฝ๋ฉ ํ์ผ
|
| 18 |
-
- [ ] `*.zip` - Wallet ์์ถ ํ์ผ
|
| 19 |
-
|
| 20 |
-
---
|
| 21 |
-
|
| 22 |
-
## ๐ Hugging Face Secrets (5๊ฐ)
|
| 23 |
-
|
| 24 |
-
### ํ์ Secrets:
|
| 25 |
-
|
| 26 |
-
| Secret Name | ์ค์ ๋จ? | Value ์์ |
|
| 27 |
-
|-------------|---------|-----------|
|
| 28 |
-
| `DB_USER` | [ ] | `ADMIN` |
|
| 29 |
-
| `DB_PASSWORD` | [ ] | Oracle DB ๋น๋ฐ๋ฒํธ |
|
| 30 |
-
| `DB_TNS_ALIAS` | [ ] | `musclecare_high` |
|
| 31 |
-
| `WALLET_ZIP_B64` | [ ] | Base64 ์ธ์ฝ๋ฉ๋ Wallet |
|
| 32 |
-
| `WALLET_PASSWORD` | [ ] | Wallet ๋น๋ฐ๋ฒํธ |
|
| 33 |
-
|
| 34 |
-
---
|
| 35 |
-
|
| 36 |
-
## ๐ ์ฝ๋ ๊ฒ์
|
| 37 |
-
|
| 38 |
-
### start.py
|
| 39 |
-
```python
|
| 40 |
-
โ
WALLET_ZIP_B64 ํ๊ฒฝ ๋ณ์ ์ฝ๊ธฐ
|
| 41 |
-
โ
Base64 ๋์ฝ๋ฉ
|
| 42 |
-
โ
์์ ๋๋ ํ ๋ฆฌ์ ์์ถ ํด์
|
| 43 |
-
โ
WALLET_DIR, WALLET_PASSWORD ํ๊ฒฝ ๋ณ์ ์ค์
|
| 44 |
-
โ
uvicorn์ผ๋ก FastAPI ์คํ
|
| 45 |
-
```
|
| 46 |
-
|
| 47 |
-
### app.py
|
| 48 |
-
```python
|
| 49 |
-
โ
ํ๊ฒฝ ๋ณ์๋ก DB ์ค์ ์ฝ๊ธฐ
|
| 50 |
-
โ
Wallet ๊ฒฝ๋ก ์ฌ์ฉ
|
| 51 |
-
โ
์ฐ๊ฒฐ ํ ์์ฑ (Thin mode + mTLS)
|
| 52 |
-
โ
/health ์๋ํฌ์ธํธ
|
| 53 |
-
โ
/upload_state ์๋ํฌ์ธํธ (MERGE INTO)
|
| 54 |
-
โ
/upload_logs ์๋ํฌ์ธํธ (executemany)
|
| 55 |
-
```
|
| 56 |
-
|
| 57 |
-
### Dockerfile
|
| 58 |
-
```dockerfile
|
| 59 |
-
โ
Python 3.10-slim
|
| 60 |
-
โ
requirements.txt ์ค์น
|
| 61 |
-
โ
start.py๋ก ์คํ
|
| 62 |
-
โ
ํฌํธ 7860 ๋
ธ์ถ
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
### requirements.txt
|
| 66 |
-
```
|
| 67 |
-
โ
fastapi
|
| 68 |
-
โ
uvicorn
|
| 69 |
-
โ
python-multipart
|
| 70 |
-
โ
oracledb>=2.3
|
| 71 |
-
โ
pydantic
|
| 72 |
-
```
|
| 73 |
-
|
| 74 |
-
---
|
| 75 |
-
|
| 76 |
-
## ๐งช ๋ฐฐํฌ ์ ๋ก์ปฌ ํ
์คํธ
|
| 77 |
-
|
| 78 |
-
### ํ๊ฒฝ ๋ณ์ ์ค์ (๋ก์ปฌ)
|
| 79 |
-
|
| 80 |
-
```bash
|
| 81 |
-
export DB_USER="ADMIN"
|
| 82 |
-
export DB_PASSWORD="your_db_password"
|
| 83 |
-
export DB_TNS_ALIAS="musclecare_high"
|
| 84 |
-
export WALLET_DIR="/Users/gimhyeon-u/workspace/MuscleCare-FastAPI/wallet"
|
| 85 |
-
export WALLET_PASSWORD="your_wallet_password"
|
| 86 |
-
```
|
| 87 |
-
|
| 88 |
-
### ์๋ฒ ์คํ
|
| 89 |
-
|
| 90 |
-
```bash
|
| 91 |
-
python app.py
|
| 92 |
-
```
|
| 93 |
-
|
| 94 |
-
๋๋ start.py๋ก:
|
| 95 |
-
|
| 96 |
-
```bash
|
| 97 |
-
# Wallet zip ํ์ผ ์ค๋น ํ์
|
| 98 |
-
python start.py
|
| 99 |
-
```
|
| 100 |
-
|
| 101 |
-
---
|
| 102 |
-
|
| 103 |
-
## ๐ ๋ฐฐํฌ ๋ช
๋ น์ด
|
| 104 |
-
|
| 105 |
-
### 1. Git ์ํ ํ์ธ
|
| 106 |
-
|
| 107 |
-
```bash
|
| 108 |
-
git status
|
| 109 |
-
```
|
| 110 |
-
|
| 111 |
-
**ํ์ธ:**
|
| 112 |
-
- โ `.env` ์์ด์ผ ํจ
|
| 113 |
-
- โ `wallet/` ์์ด์ผ ํจ
|
| 114 |
-
- โ `wallet_base64.txt` ์์ด์ผ ํจ
|
| 115 |
-
|
| 116 |
-
### 2. Git ์ปค๋ฐ ๋ฐ ํธ์
|
| 117 |
-
|
| 118 |
-
```bash
|
| 119 |
-
git add .
|
| 120 |
-
git commit -m "Deploy to HF with Wallet mTLS"
|
| 121 |
-
git push
|
| 122 |
-
```
|
| 123 |
-
|
| 124 |
-
---
|
| 125 |
-
|
| 126 |
-
## ๐ ๋ฐฐํฌ ํ ํ์ธ
|
| 127 |
-
|
| 128 |
-
### 1. Logs ํ์ธ
|
| 129 |
-
|
| 130 |
-
Hugging Face Space โ **Logs** ํญ
|
| 131 |
-
|
| 132 |
-
**์ฑ๊ณต ๋ฉ์์ง:**
|
| 133 |
-
```
|
| 134 |
-
๐ Wallet ๋์ฝ๋ฉ ์์...
|
| 135 |
-
๐ ์์ ๋๋ ํ ๋ฆฌ ์์ฑ: /tmp/wallet_xxxxx
|
| 136 |
-
โ
Wallet ์์ถ ํด์ ์๋ฃ
|
| 137 |
-
โ
tnsnames.ora ํ์ธ
|
| 138 |
-
INFO: Uvicorn running on http://0.0.0.0:7860
|
| 139 |
-
```
|
| 140 |
-
|
| 141 |
-
### 2. API ํ
์คํธ
|
| 142 |
-
|
| 143 |
-
```bash
|
| 144 |
-
curl https://[username]-musclecare-api.hf.space/health
|
| 145 |
-
```
|
| 146 |
-
|
| 147 |
-
**๊ธฐ๋ ์๋ต:**
|
| 148 |
-
```json
|
| 149 |
-
{"ok": true, "db": 1}
|
| 150 |
-
```
|
| 151 |
-
|
| 152 |
-
### 3. API ๋ฌธ์
|
| 153 |
-
|
| 154 |
-
```
|
| 155 |
-
https://[username]-musclecare-api.hf.space/docs
|
| 156 |
-
```
|
| 157 |
-
|
| 158 |
-
---
|
| 159 |
-
|
| 160 |
-
## ๐ง ๋ฌธ์ ํด๊ฒฐ
|
| 161 |
-
|
| 162 |
-
### "WALLET_ZIP_B64 ํ๊ฒฝ ๋ณ์๊ฐ ์์ต๋๋ค"
|
| 163 |
-
|
| 164 |
-
- [ ] Secrets ์ด๋ฆ ํ์ธ: `WALLET_ZIP_B64` (์ ํํ)
|
| 165 |
-
- [ ] Secret ๊ฐ ํ์ธ: wallet_base64.txt ์ ์ฒด ๋ด์ฉ
|
| 166 |
-
- [ ] Space ์ฌ์์
|
| 167 |
-
|
| 168 |
-
### "Wallet ์์ถ ํด์ ์คํจ"
|
| 169 |
-
|
| 170 |
-
- [ ] Base64 ์ธ์ฝ๋ฉ ์ฌ์๋
|
| 171 |
-
- [ ] Wallet zip ํ์ผ์ด ์์๋์ง ์์๋์ง ํ์ธ
|
| 172 |
-
|
| 173 |
-
### "DB ์ฐ๊ฒฐ ์คํจ"
|
| 174 |
-
|
| 175 |
-
- [ ] Oracle DB ์ํ AVAILABLE ํ์ธ
|
| 176 |
-
- [ ] `DB_PASSWORD` ํ์ธ
|
| 177 |
-
- [ ] `DB_TNS_ALIAS` ํ์ธ
|
| 178 |
-
|
| 179 |
-
---
|
| 180 |
-
|
| 181 |
-
## โ
์ต์ข
์ฒดํฌ
|
| 182 |
-
|
| 183 |
-
- [ ] Dockerfile์ด start.py ์คํํ๋๋ก ์์ ๋จ
|
| 184 |
-
- [ ] .gitignore ์์ฑ๋จ
|
| 185 |
-
- [ ] README.md ์
๋ฐ์ดํธ๋จ
|
| 186 |
-
- [ ] env_example.txt ์์ฑ๋จ
|
| 187 |
-
- [ ] Git์ ๋ฏผ๊ฐ ํ์ผ ์ ์ธ ํ์ธ
|
| 188 |
-
- [ ] 5๊ฐ Secrets ์ค์ ์ค๋น๋จ
|
| 189 |
-
|
| 190 |
-
**๋ชจ๋ ์ค๋น ์๋ฃ!** ๐
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|