Spaces:
Running
Running
File size: 3,224 Bytes
877add7 | 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 | # Deployment
## Local OpenEnv Validation
```bash
bash scripts/bootstrap_openenv.sh
bash scripts/bootstrap_openenv.sh --runtime-check
```
The first command validates local OpenEnv packaging. The runtime check starts the FastAPI environment service and validates `GET /openapi.json`, `GET /health`, `GET /metadata`, `GET /schema`, `POST /mcp`, and the `/reset`/`/step`/`/state` HTTP contract.
## Hugging Face CLI
Use the repository virtual environment CLI:
```bash
./.venv/bin/hf version
./.venv/bin/hf auth login
./.venv/bin/hf auth whoami
```
The global `hf` command on this workstation currently fails because its installed `huggingface_hub` and Typer versions are incompatible. Do not use it for final deployment.
## Hugging Face Space Deployment
```bash
export HF_SPACE_REPO_ID="Vishwa-docs/polyguard-openenv"
bash scripts/deploy_space.sh --repo-id "$HF_SPACE_REPO_ID"
./.venv/bin/hf spaces info "$HF_SPACE_REPO_ID"
openenv validate --url "https://Vishwa-docs-polyguard-openenv.hf.space"
```
Useful deploy flags:
- `--dry-run`: print commands only.
- `--skip-build`: skip `openenv build`.
- `--skip-validate`: skip local validation.
- `--private`: deploy as a private Space.
- `--create-pr`: push deployment changes as a pull request when supported by the OpenEnv CLI.
Default deploy configuration is in [`configs/deployment.yaml`](/Users/daver/Desktop/Meta_Pytorch_OpenEnv_Scaler/polyguard-rl/configs/deployment.yaml).
## Required Submission Evidence
After deployment, replace `docs/results/hf_space_verification.json` with a successful payload that includes:
- `passed: true`
- HF Space repo id
- HF Space URL
- `hf spaces info` output or summary
- `openenv validate --url ...` result
Strict acceptance mode will continue to fail until this file reports `passed: true`.
## Hugging Face Training Space
Use this path when local Ollama/GPU training is unavailable. It creates a private Docker Space under the authenticated account, starts the Gradio training runner, and uploads outputs/checkpoints to a private artifact repo.
```bash
export HF_TOKEN="<write-token>"
.venv/bin/python scripts/deploy_training_space.py \
--repo-id TheJackBright/polyguard-openenv-training \
--artifact-repo-id TheJackBright/polyguard-openenv-training-artifacts \
--hardware t4-small \
--model-id Qwen/Qwen2.5-0.5B-Instruct
```
The Space executes the notebook-equivalent training loop from `notebooks/09_training_loop.ipynb`, including SFT, GRPO, adapter merge, post-save inference, ablations, and comparison reports. After the Space uploads artifacts, pull them locally and stop paid GPU usage:
```bash
.venv/bin/python scripts/pull_training_artifacts.py \
--artifact-repo-id TheJackBright/polyguard-openenv-training-artifacts
.venv/bin/python scripts/pause_training_space.py \
--repo-id TheJackBright/polyguard-openenv-training \
--mode cpu-basic
```
## Local Services
```bash
bash scripts/run_all_local.sh --quick --skip-train
```
This builds local data/model assets, skips TRL training, starts the environment/API/UI services, and runs smoke checks. Local inference defaults to the HF Transformers path; set `POLYGUARD_ENABLE_OLLAMA=true` only when a local Ollama runtime is intentionally available.
|