You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+112Lines changed: 112 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,6 +143,118 @@ To use an environment:
143
143
144
144
See example scripts in `examples/` directory.
145
145
146
+
### Deploying Environments to Hugging Face Spaces
147
+
148
+
The OpenEnv CLI provides a self-service workflow for publishing environments to Hugging Face Spaces. This enables community members to share environments without requiring adding them as examples to this repo.
149
+
150
+
#### Installation
151
+
152
+
The CLI is installed as part of the OpenEnv package:
153
+
154
+
```bash
155
+
pip install -e .
156
+
```
157
+
158
+
#### Push Environment
159
+
160
+
Push an environment to Hugging Face Spaces:
161
+
162
+
```bash
163
+
openenv push <env_name> [options]
164
+
```
165
+
166
+
**Arguments:**
167
+
-`env_name`: Name of the environment to push (e.g., `echo_env`, `coding_env`)
168
+
169
+
**Options:**
170
+
-`--repo-id <repo_id>`: Hugging Face repository ID in format `namespace/space-name`. If not provided, uses `{username}/{env_name}`.
171
+
-`--private`: Create a private space (default: public)
172
+
-`--base-image <image>`: Base Docker image to use (default: `ghcr.io/meta-pytorch/openenv-base:latest`)
173
+
-`--dry-run`: Prepare files but don't upload to Hugging Face
The `openenv push` command performs the following steps:
200
+
201
+
1.**Validation**: Checks that the environment exists in `src/envs/<env_name>/`
202
+
2.**Authentication**: Ensures you're authenticated with Hugging Face via interactive login (prompts if needed)
203
+
3.**Space Provisioning**: Determines the target Space repository ID (uses `--repo-id` if provided, otherwise `{username}/{env_name}`). Creates the Docker Space if needed (using `exist_ok=True` to handle existing spaces automatically)
204
+
4.**Build Process**:
205
+
- Creates a staging directory
206
+
- Copies core and environment files
207
+
- Generates/modifies Dockerfile with web interface enabled
208
+
- Prepares README: If the environment's README already has Hugging Face front matter (starts and ends with `---`), uses it as-is. Otherwise, generates front matter with random emoji and colors from approved options
209
+
5.**Deployment**: Uploads all files to the Hugging Face Space
210
+
6.**Cleanup**: Removes staging directory after successful upload
211
+
212
+
All pushed environments automatically include the web interface, available at `/web` on deployed spaces.
213
+
214
+
For more details on the CLI architecture and development, see [`src/openenv_cli/README.md`](src/openenv_cli/README.md).
215
+
216
+
## CLI Troubleshooting
217
+
218
+
### Authentication Issues
219
+
220
+
**Problem**: "Failed to retrieve token after login" or authentication errors
221
+
222
+
**Solution**:
223
+
- Check that `huggingface_hub` is properly installed: `pip install --upgrade huggingface_hub`
224
+
- Try logging in via the Hugging Face CLI: `huggingface-cli login`
225
+
- Clear cached credentials if needed (credentials are stored by `huggingface_hub`)
226
+
- Ensure you have "write" permissions on the namespace where you're pushing
227
+
228
+
### Space Creation Fails
229
+
230
+
**Problem**: "Failed to create space" or "Permission denied"
231
+
232
+
**Solution**:
233
+
- Check that namespace/username is correct
234
+
- Verify you have permission to create spaces in that namespace
235
+
- If the space already exists, `exist_ok=True` handles it automatically (you may see a warning from the Hub CLI)
236
+
- For authentication errors, see "Authentication Issues" above
237
+
238
+
### Upload Fails
239
+
240
+
**Problem**: "Failed to upload to space"
241
+
242
+
**Solution**:
243
+
- Check internet connection
244
+
- Verify you're still authenticated (may need to log in again)
245
+
- Try `--dry-run` first to check file preparation
246
+
- Check staging directory exists and has files
247
+
- Verify you have write permissions on the target space
248
+
249
+
### Environment Not Found
250
+
251
+
**Problem**: "Environment 'xyz' not found"
252
+
253
+
**Solution**:
254
+
- Verify environment exists in `src/envs/<env_name>/`
255
+
- Check spelling of environment name
256
+
- Ensure environment directory has required structure (models.py, server/, etc.)
257
+
146
258
## Design Principles
147
259
148
260
1.**Separation of Concerns**: Clear client-server boundaries
0 commit comments