process_parameter / DEPLOY.md
Bingdo's picture
update report
7718432
|
Raw History Blame Contribute Delete
2.64 kB

A newer version of the Streamlit SDK is available: 1.67.0

Upgrade

部署到 Hugging Face Spaces 指南

前置需求

  1. 擁有 Hugging Face 帳號
  2. 取得 Access Token: https://huggingface.co/settings/tokens
  3. 已建立 Space: https://huggingface.co/spaces/Bingdo/process_parameter

部署步驟

1. 進入專案目錄

cd /Users/bingdo/Documents/deep_research/process_parameter_hf

2. 初始化 Git(僅首次需要)

git init
git remote add origin https://huggingface.co/spaces/Bingdo/process_parameter

3. 新增所有報告資料

# 複製所有完整報告(含 07_final_output.json 的資料夾)
for dir in /Users/bingdo/Documents/deep_research/process_param_outputs/*/; do
  if [ -f "${dir}07_final_output.json" ]; then
    cp -r "$dir" reports/
  fi
done

4. 提交變更

git add .
git commit -m "Add all reports"

5. 推送到 Hugging Face

方法 A: 使用 Token 認證(推薦)

# 將 YOUR_HF_TOKEN 替換為你的 token
git remote set-url origin https://YOUR_USERNAME:YOUR_HF_TOKEN@huggingface.co/spaces/Bingdo/process_parameter
git push origin main

方法 B: 使用 huggingface-cli 登入

# 安裝 huggingface_hub
pip install huggingface_hub

# 登入(會提示輸入 token)
huggingface-cli login

# 推送
git push origin main

6. 清除 Token(安全考量)

推送完成後,移除 URL 中的 token:

git remote set-url origin https://huggingface.co/spaces/Bingdo/process_parameter

強制覆蓋遠端

如果遠端已有內容需要覆蓋:

git push origin main --force

驗證部署

  1. 訪問 Space: https://huggingface.co/spaces/Bingdo/process_parameter
  2. 等待狀態變為 "Running"(約 1-2 分鐘)
  3. 確認報告選擇器顯示所有報告

常見問題

Q: 推送時出現 "could not read Username" 錯誤

A: 使用 Token 認證方式,將 token 加入 remote URL

Q: Space 顯示 "Building" 很久

A: 檢查 requirements.txt 是否有問題,或查看 Build logs

Q: App 不顯示,只看到 "You can now view your Streamlit app"

A: 確認 .streamlit/config.toml 沒有設定 port(HF Spaces 只允許 port 8501)


檔案結構

process_parameter_hf/
├── app.py                 # Streamlit 應用程式
├── requirements.txt       # Python 相依套件
├── README.md              # HF Spaces metadata
├── .streamlit/
│   └── config.toml        # Streamlit 設定(不可設定 port)
└── reports/               # 報告資料
    └── {material}_{date}_{time}/
        └── 07_final_output.json