File size: 4,505 Bytes
3dbff85 | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | #!/usr/bin/env bash
# Deploy the Riprap inference Space (msradam/riprap-inference) β the
# headless GPU API both UI Spaces (lablab + personal) call into.
#
# Same orphan-branch pattern as deploy_personal_space.sh: the full
# git history of the source repo would trip HF Spaces' binary-file
# gate, so we push a single fresh commit containing only what the
# inference Space needs to run.
set -euo pipefail
REMOTE="inference"
URL="https://huggingface.co/spaces/msradam/riprap-inference"
BRANCH="hf-inference"
LABLAB_NAME_PATTERN="AMD-hackathon|lablab-ai"
guard_against_lablab () {
if echo "$URL" | grep -qE "$LABLAB_NAME_PATTERN"; then
echo "FATAL: URL ($URL) matches the lablab org pattern."
exit 1
fi
final=$(curl -sIL -o /dev/null -w "%{url_effective}" "$URL")
if echo "$final" | grep -qE "$LABLAB_NAME_PATTERN"; then
echo "FATAL: URL ($URL) redirects to a lablab-org URL ($final)"
exit 1
fi
}
if [ "${1:-}" = "--setup" ]; then
guard_against_lablab
if ! git remote | grep -q "^${REMOTE}$"; then
echo "[deploy.inf] adding remote '$REMOTE' β $URL"
git remote add "$REMOTE" "$URL"
fi
echo "[deploy.inf] set the following secrets in the inference Space"
echo " (Settings β Variables and secrets):"
echo " RIPRAP_PROXY_TOKEN <a long random secret>"
echo " HF_TOKEN <your HF token, if any model is gated>"
echo "[deploy.inf] then set the same RIPRAP_PROXY_TOKEN as RIPRAP_LLM_API_KEY"
echo " on both the lablab-org Space and msradam/riprap."
exit 0
fi
guard_against_lablab
DEPLOY_TMP="$(git rev-parse --show-toplevel)/.deploy-tmp-inf"
rm -rf "$DEPLOY_TMP"
git worktree add --detach "$DEPLOY_TMP" HEAD
(
cd "$DEPLOY_TMP"
git checkout --orphan "$BRANCH"
# Strip everything except what the inference container needs.
rm -rf slides/ submission/ docs/ pitch/ research/ corpus/ \
assets/ \
tests/ experiments/ \
data/ \
web/ app/ scripts/ \
Dockerfile Dockerfile.app Dockerfile.l4 \
docker-compose.yml entrypoint.sh entrypoint.l4.sh \
pyproject.toml uv.lock \
agent.py riprap.py helios_nyc.py \
ARCHITECTURE.md METHODOLOGY.md RESEARCH.md \
LICENSE NOTICE README.md requirements*.txt
# Inference Dockerfile + entrypoint + proxy go to the repo root
# (HF Spaces convention β Dockerfile + entrypoint.sh + proxy.py at
# top level).
mv inference/Dockerfile ./Dockerfile
mv inference/entrypoint.sh ./entrypoint.sh
mv inference/proxy.py ./proxy.py
rmdir inference 2>/dev/null || true
chmod +x entrypoint.sh
# The Dockerfile COPYs services/riprap-models/{main.py,requirements.txt}
# so keep that path. Trim everything else under services/.
find services -mindepth 1 -maxdepth 1 -not -name riprap-models -exec rm -rf {} +
find services/riprap-models -mindepth 1 \
-not -name main.py -not -name requirements.txt -exec rm -rf {} +
cat > README.md <<'README'
---
title: Riprap Inference (Headless GPU API)
emoji: π
colorFrom: indigo
colorTo: blue
sdk: docker
pinned: false
short_description: Headless GPU API for Riprap. Bearer-auth proxy on L4.
---
# Riprap Inference Space
Headless GPU API for [Riprap](https://github.com/msradam/riprap-nyc).
Runs Granite 4.1 (Ollama, OpenAI-compatible) and the riprap-models
specialist service (Prithvi-EO 2.0 NYC-Pluvial, TerraMind LULC +
Buildings + Synthesis, Granite TTM r2, Granite Embedding, GLiNER)
behind a single FastAPI bearer-auth proxy on port 7860.
Two UI Spaces consume this:
- `lablab-ai-amd-developer-hackathon/riprap-nyc` β official AMD
hackathon submission (CPU UI).
- `msradam/riprap` β personal mirror (CPU UI).
Both pass `Authorization: Bearer <RIPRAP_PROXY_TOKEN>` and call
`/v1/chat/completions`, `/v1/embeddings`, `/v1/prithvi-pluvial`,
`/v1/terramind`, `/v1/ttm-forecast`, `/v1/gliner-extract`.
Apache 2.0. Source: https://github.com/msradam/riprap-nyc.
README
git add -A
git -c user.email=msrahmanadam@gmail.com -c user.name="Adam Munawar Rahman" \
commit -m "deploy(inference): headless GPU API on L4"
echo "[deploy.inf] pushing $BRANCH β $REMOTE main ..."
git push --force "$REMOTE" "${BRANCH}:main"
)
git worktree remove --force "$DEPLOY_TMP"
git branch -D "$BRANCH" 2>/dev/null || true
echo "[deploy.inf] done. Watch build at: ${URL}"
|