2424 - [ Installation] ( #installing )
2525 - [ Prediction] ( #predict )
2626 - [ Web API (Optional)] ( #web-api-optional )
27+ - [ Vercel Deployment (Optional)] ( #vercel-deployment-optional )
2728 - [ Reproducibility] ( #reproduce )
2829- [ Acknowledgements] ( #acknw )
2930- [ License] ( #license )
@@ -126,6 +127,7 @@ By default, the API is hardened for service use:
126127- ` input_file` requests are disabled (use ` input_rows` instead).
127128- request-time overrides of ` repo_root` / ` python_executable` are disabled.
128129- ` results_dir` is constrained under ` CATPRED_API_RESULTS_ROOT` .
130+ - for local backend (and modal requests with fallback enabled), ` checkpoint_dir` must resolve under ` CATPRED_API_CHECKPOINT_ROOT` .
129131
130132Minimal ` POST /predict` example for local inference using ` input_rows` :
131133
@@ -134,7 +136,7 @@ curl -X POST http://127.0.0.1:8000/predict \
134136 -H " Content-Type: application/json" \
135137 -d ' {
136138 "parameter": "kcat",
137- "checkpoint_dir": "../data/pretrained/reproduce_checkpoints/ kcat",
139+ "checkpoint_dir": "kcat",
138140 "input_rows": [
139141 {"SMILES": "CCO", "sequence": "ACDEFGHIK", "pdbpath": "seq_a"},
140142 {"SMILES": "CCN", "sequence": "LMNPQRSTV", "pdbpath": "seq_b"}
@@ -154,6 +156,7 @@ export CATPRED_MODAL_FALLBACK_TO_LOCAL=1
154156` ` `
155157
156158Use ` " backend" : " modal" ` in ` /predict` requests to route through Modal. If fallback is enabled (env var above or request field ` fallback_to_local` ), failed modal requests can automatically reroute to local inference.
159+ For local backend requests, place local checkpoints under ` CATPRED_API_CHECKPOINT_ROOT` and pass a path relative to that root (for example, ` " checkpoint_dir" : " kcat" ` ).
157160
158161Optional API environment variables:
159162
@@ -183,6 +186,93 @@ export CATPRED_TRUSTED_DESERIALIZATION_ROOTS="/srv/catpred:/srv/catpred-data"
183186export CATPRED_ALLOW_UNSAFE_DESERIALIZATION=1
184187` ` `
185188
189+ # ## ▲ Vercel Deployment (Optional) <a name="vercel-deployment-optional"></a>
190+
191+ This repository includes a Vercel-ready ASGI entrypoint at ` api/index.py` and a ` vercel.json` route config.
192+
193+ 1. Push this repository to GitHub.
194+ 2. In Vercel, create a new project from that repo.
195+ 3. Set Environment Variables in Vercel Project Settings:
196+
197+ ` ` ` bash
198+ # Use remote inference backend in serverless deployments
199+ CATPRED_DEFAULT_BACKEND=modal
200+ CATPRED_MODAL_ENDPOINT=https://< your-modal-endpoint>
201+ CATPRED_MODAL_TOKEN=< optional-token>
202+ CATPRED_MODAL_FALLBACK_TO_LOCAL=0
203+ ` ` `
204+
205+ Notes:
206+ - Serverless filesystems are ephemeral/read-only except ` /tmp` ; this app auto-uses ` /tmp/catpred` on Vercel.
207+ - Local checkpoint-based inference is not recommended on Vercel serverless due runtime/dependency limits.
208+ - If ` CATPRED_MODAL_ENDPOINT` is not configured, the UI still loads but prediction requests will be limited by backend readiness.
209+
210+ # ### Deploy a Modal endpoint for Vercel
211+
212+ This repo includes ` modal_app.py` , a Modal ` POST` endpoint compatible with CatPred' s `/predict` modal backend contract.
213+
214+ 1. Install and authenticate Modal CLI:
215+
216+ ```bash
217+ pip install modal
218+ modal setup
219+ ```
220+
221+ 2. Create/upload checkpoints into a Modal Volume (one-time):
222+
223+ ```bash
224+ modal volume create catpred-checkpoints
225+ modal volume put catpred-checkpoints ./checkpoints/kcat kcat
226+ modal volume put catpred-checkpoints ./checkpoints/km km
227+ modal volume put catpred-checkpoints ./checkpoints/ki ki
228+ ```
229+
230+ 3. (Recommended) create a secret token for endpoint auth:
231+
232+ ```bash
233+ modal secret create catpred-modal-auth CATPRED_MODAL_AUTH_TOKEN="<your-token>"
234+ ```
235+
236+ 4. Deploy:
237+
238+ ```bash
239+ modal deploy modal_app.py
240+ ```
241+
242+ After deploy, copy the printed endpoint URL (for function `predict`) and set Vercel variables:
243+
244+ ```bash
245+ CATPRED_DEFAULT_BACKEND=modal
246+ CATPRED_MODAL_ENDPOINT=https://<your-modal-endpoint>
247+ CATPRED_MODAL_TOKEN=<your-token>
248+ CATPRED_MODAL_FALLBACK_TO_LOCAL=0
249+ ```
250+
251+ #### CI/CD (GitHub Actions + Vercel + Modal)
252+
253+ This repo includes two GitHub Actions workflows:
254+
255+ - `.github/workflows/ci.yml`
256+ - Runs on every PR and push to `main`.
257+ - Installs minimal API dependencies, compiles all Python files, and smoke-tests API entrypoints.
258+ - `.github/workflows/deploy-modal.yml`
259+ - Runs on push to `main` when backend files change (and manually via `workflow_dispatch`).
260+ - Deploys `modal_app.py` automatically.
261+
262+ To enable automatic Modal deploys from GitHub Actions, add repository secrets:
263+
264+ - `MODAL_TOKEN_ID`
265+ - `MODAL_TOKEN_SECRET`
266+
267+ Create these from Modal:
268+
269+ 1. Go to [https://modal.com/settings/tokens](https://modal.com/settings/tokens).
270+ 2. Create a token with deploy permissions for your workspace.
271+ 3. Copy token ID and secret into GitHub repo settings:
272+ `Settings -> Secrets and variables -> Actions -> New repository secret`.
273+
274+ Vercel deployment remains automatic from the connected GitHub branch (`main`).
275+
186276### 🧪 Fine-Tuning On Custom Data
187277
188278You can fine-tune CatPred on your own regression targets using `train.py`.
0 commit comments