UdasriHasindu commited on
Commit
75e2d01
·
1 Parent(s): 491f8d0

add actions to deploy on HF spaces

Browse files
.github/workflows/deploy-hf-space.yml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to Hugging Face Space
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: Configure Git
19
+ run: |
20
+ git config user.name "github-actions[bot]"
21
+ git config user.email "github-actions[bot]@users.noreply.github.com"
22
+
23
+ - name: Push to Hugging Face Space
24
+ env:
25
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
26
+ run: |
27
+ if [ -z "${HF_TOKEN}" ]; then
28
+ echo "HF_TOKEN secret is missing"
29
+ exit 1
30
+ fi
31
+
32
+ git remote add hf "https://oauth2:${HF_TOKEN}@huggingface.co/spaces/xplorers/GAIT_API"
33
+ git push --force hf HEAD:main
scripts/start.sh ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env sh
2
+ set -eu
3
+
4
+ PORT="${PORT:-7860}"
5
+ CLEANUP_INTERVAL_SECONDS="${CLEANUP_INTERVAL_SECONDS:-1800}"
6
+ RUNS_MAX_AGE_MINUTES="${RUNS_MAX_AGE_MINUTES:-30}"
7
+
8
+ mkdir -p /app/runs/outputs
9
+
10
+ cleanup_loop() {
11
+ while true; do
12
+ python /app/scripts/cleanup_runs.py \
13
+ --path /app/runs \
14
+ --max-age-minutes "${RUNS_MAX_AGE_MINUTES}" || true
15
+ sleep "${CLEANUP_INTERVAL_SECONDS}"
16
+ done
17
+ }
18
+
19
+ cleanup_loop &
20
+
21
+ exec uvicorn app:app --host 0.0.0.0 --port "${PORT}"