Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
|
Download docs/SETUP.md from PrismScienceOrg/PLUG-challenge: direct link, hf CLI and curl.
- Browser
- Download file 8.31 kB
-
https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge/resolve/main/docs/SETUP.md
- Command line
-
hf download hf://spaces/PrismScienceOrg/PLUG-challenge/docs/SETUP.md
-
curl -L -o SETUP.md https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge/resolve/main/docs/SETUP.md
8.31 kB
| # Standing up the PLUG challenge | |
| Runbook for taking this repository from a fresh checkout to a live, scoring Space. It | |
| follows the shape of OpenADMET's `docs/SETUP.md` but has no AWS, no OpenTofu and no | |
| container registry β the whole backend is two Hugging Face dataset repos. | |
| Everything you need: a Hugging Face account with rights to create datasets in the | |
| `PrismScienceOrg` namespace, a write token, a local checkout of plug with its benchmark data | |
| downloaded, and the Lo-Hi split directory it wrote (the one holding `splits/`, `nodes/` and | |
| `provenance.json`). | |
| --- | |
| ## 1. Create the two dataset repos | |
| ```bash | |
| huggingface-cli login # a write token | |
| huggingface-cli repo create plug-challenge-data --type dataset --organization PrismScienceOrg | |
| huggingface-cli repo create plug-challenge-private --type dataset --organization PrismScienceOrg --private | |
| ``` | |
| The private one must be **private**: it holds every label the Space scores against and | |
| participants' contact details. Double-check that before the first submission arrives. | |
| If you name them differently, set `PLUG_PRIVATE_REPO` / `PLUG_PUBLIC_REPO` as Space | |
| variables to match (defaults are in `plug_challenge/store.py`). | |
| ## 2. Build the data | |
| From this repo (plug's loaders need only the standard library and pandas): | |
| ```bash | |
| python scripts/build_challenge_data.py \ | |
| --plug /path/to/plug \ | |
| --split /path/to/lohi | |
| ``` | |
| That writes, per benchmark, into `.challenge-data/` | |
| (gitignored): | |
| ``` | |
| public/<benchmark>/manifest.parquet every row: datapoint_id, row_index, protein id(s), | |
| [position], Lo-Hi split β no labels | |
| public/<benchmark>/proteins.csv protein -> Lo-Hi split | |
| private/ground_truth/<benchmark>.parquet every row with its labels and split | |
| ``` | |
| and refreshes the committed `data/<benchmark>/proteins.csv` lists and | |
| `data/lohi_provenance.json`. It refuses a benchmark whose loader no longer yields as many | |
| rows as the split file has lines, since the two are matched by position. | |
| **Only ids and splits go public.** Not every benchmark's licence allows redistributing its | |
| labels β LP-PDBBind's does not β so participants read the rows from the original sources | |
| through plug's loaders, and `row_index` is a row's position there. | |
| Run it for a subset while iterating: `... build_challenge_data.py megascale fireprot`. | |
| A `datapoint_id` is a row's position in plug's loader (plus the residue for the per-residue | |
| benchmarks), so it is stable for as long as the loader and its source data are. **A | |
| rebuilt split, or a loader change that reorders rows, is not**: it moves the test rows and | |
| invalidates every stored score. Rebuild the leaderboard (step 6) if that happens | |
| mid-challenge, or better, don't. | |
| ## 3. Upload it | |
| ```bash | |
| huggingface-cli upload PrismScienceOrg/plug-challenge-data \ | |
| .challenge-data/public . --repo-type dataset | |
| huggingface-cli upload PrismScienceOrg/plug-challenge-private \ | |
| .challenge-data/private . --repo-type dataset | |
| ``` | |
| Check the private repo is private *before* this second command, not after. | |
| ## 4. Configure the Space | |
| This repository **is** the Space, so there is no deploy pipeline to set up β but the | |
| Space needs its secrets. On | |
| [huggingface.co/spaces/PrismScienceOrg/PLUG-challenge/settings](https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge/settings): | |
| | Kind | Name | Value | | |
| |---|---|---| | |
| | **Secret** | `HF_TOKEN` | A write token that can read both dataset repos and write the private one | | |
| | Variable | `CURRENT_PHASE` | `0` until you are ready to open; `1` to open submissions; `2` to close | | |
| | Variable | `PLUG_PRIVATE_REPO` | Only if you renamed the private repo | | |
| | Variable | `PLUG_PUBLIC_REPO` | Only if you renamed the public repo | | |
| | Variable | `BOOTSTRAP_SAMPLES` | Leave unset (`0`). See [`scoring.md`](scoring.md) | | |
| The Space's hardware only needs CPU basic β scoring is a handful of NumPy passes, not a | |
| model forward. Keep the Space **private** while you test, then make it public. | |
| ## 5. Work through the TODOs, then deploy | |
| ```bash | |
| grep -rn "TODO" config.py docs/ | |
| ``` | |
| `config.py` is where every challenge-specific string lives: the dates in | |
| `HEADER_MARKDOWN` and `ABOUT_MD`, the announcement/tutorial links, `COMMUNITY_LINK`, and | |
| the acknowledgements. Then: | |
| ```bash | |
| pytest tests/ # synthetic data; test_real_data.py needs step 2 | |
| CURRENT_PHASE=1 python app.py # check it locally first | |
| git push origin main # deploys | |
| ``` | |
| Watch the Space's build log for the first deploy β the `sdk` changed from `static` to | |
| `docker`, so the first build is a full image build. | |
| ### Smoke-test the full path before announcing | |
| With the Space open (`CURRENT_PHASE=1`) and the data uploaded, submit a junk-but-valid | |
| bundle under your own account and confirm it appears on the board: | |
| ```bash | |
| plug-challenge template ./smoke --track supervised --data-dir .challenge-data/public | |
| python - <<'PY' | |
| # Replace the zeros with noise: a constant column is rejected on the ten | |
| # rank-scored benchmarks, and cafa5's template is header-only by design (you | |
| # choose which GO terms to predict), so it needs a row or two to be scorable. | |
| import glob, numpy as np, pandas as pd | |
| rng = np.random.default_rng(0) | |
| for path in glob.glob("smoke/*.csv"): | |
| frame = pd.read_csv(path) | |
| if "cafa5" in path: | |
| manifest = pd.read_parquet(".challenge-data/public/cafa5/manifest.parquet") | |
| manifest = manifest[manifest["split"] == "test"] | |
| pd.DataFrame({ | |
| "datapoint_id": manifest["datapoint_id"], | |
| "aspect": "bp", | |
| "term": "GO:0008150", # "biological_process", the BP root | |
| "score": rng.uniform(size=len(manifest)).round(3), | |
| }).to_csv(path, index=False) | |
| continue | |
| for column in frame.columns: | |
| if column.startswith("pred"): | |
| frame[column] = rng.normal(size=len(frame)) | |
| frame.to_csv(path, index=False) | |
| PY | |
| cd smoke && zip ../smoke.zip *.csv && cd .. | |
| plug-challenge validate smoke.zip --track supervised --data-dir .challenge-data/public | |
| plug-challenge score smoke.zip --track supervised \ | |
| --ground-truth .challenge-data/private/ground_truth | |
| ``` | |
| That should report a PLUG Score near 0 β chance is 0 after normalisation, and the ten | |
| rank-scored benchmarks land there by construction, which is exactly the check: a pipeline | |
| that is wired up wrong tends to score well away from 0. (`cafa5` is the exception; a single-term submission's Fmax reflects | |
| that term's prevalence rather than chance ranking.) `pytest tests/test_real_data.py` makes | |
| the same check automatically, plus the stricter one that echoing the labels back scores | |
| exactly 1.0 in both tracks. | |
| Then submit `smoke.zip` through the Space itself to exercise the storage path, and delete | |
| the row afterwards: remove `submissions/<you>/<id>/` and `scores/<you>/<id>/` from the | |
| private repo and run step 6. | |
| ## 6. Maintenance | |
| **Rebuild the leaderboard** β the leaderboard CSV is derived; the per-submission | |
| `scores/**/scores.json` files are the source of truth. If two submissions race and one | |
| row is lost, or you remove a submission: | |
| ```bash | |
| HF_TOKEN=... plug-challenge rebuild | |
| ``` | |
| **Rescore everything** after a metric change: download the bundles from the private | |
| repo and re-run `plug-challenge score` over each, then rebuild. There is no automated | |
| path for this on purpose β a metric change mid-challenge is a decision, not a routine. | |
| **Block an account**: add it to `BANNED_USERNAMES` in `utils.py` and push. | |
| **Close the challenge**: set `CURRENT_PHASE=2`. Submissions are refused and the | |
| leaderboard is relabelled as the final standings. Nothing is deleted. | |
| ## 7. Teardown | |
| Far less than the template's, since there is no cloud account involved: | |
| 1. Archive what matters: `huggingface-cli download PrismScienceOrg/plug-challenge-private --repo-type dataset --local-dir ./archive`. | |
| 2. Decide what to publish. The labels are not ours to release β LP-PDBBind's licence | |
| does not allow redistribution, and the others are each under their own source's | |
| terms β so `ground_truth/` stays private. The splits, the scores and the method links | |
| are the public record. | |
| 3. Leave the Space up with `CURRENT_PHASE=2`; a frozen leaderboard is the record. Only | |
| delete it if you mean to erase the results. | |