Spaces:
Build error
Build error
File size: 2,085 Bytes
c8e832f | 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 | # 02. Using Environments
Source:
- https://meta-pytorch.org/OpenEnv/auto_getting_started/plot_02_using_environments.html
## Main idea
This page is about how users consume an existing OpenEnv environment.
The docs highlight three connection methods:
1. from Hugging Face Hub
2. from Docker image
3. from direct base URL
## Connection methods
### 1. From Hugging Face Hub
The easiest route for end users.
Typical flow:
- pull the image from the HF registry
- start the container locally
- connect to it
- clean it up on close
The docs show the pattern conceptually as:
```python
MyEnv.from_hub("owner/env-name")
```
## 2. From Docker image
Useful when:
- you already built the image locally
- you want reproducible local runs
- you do not want to depend on a live remote Space
Typical pattern:
```python
MyEnv.from_docker_image("my-env:latest")
```
## 3. Direct URL connection
Useful when:
- the server is already running
- you want to connect to localhost or a deployed Space
Typical pattern:
```python
MyEnv(base_url="http://localhost:8000")
```
## WebSocket model
The docs emphasize that OpenEnv uses WebSocket-backed sessions for persistent environment interaction.
Why this matters:
- lower overhead than stateless HTTP on every step
- cleaner session management
- better fit for multi-step RL loops
## Environment loop
The intended use pattern is:
1. connect
2. reset
3. repeatedly call `step(action)`
4. inspect `reward`, `done`, and `observation`
5. close cleanly
## What this means for `python_env`
Your environment should be easy to consume in all three modes:
- local URL
- local Docker image
- HF Space
That means the most important user-facing checks are:
- `reset()` works
- `step()` works
- the client can parse the observation correctly
- Docker image starts cleanly
- deployed Space responds on `/health`, `/docs`, and session routes
For hackathon validation, this page is basically the “user experience” standard you need to match.
|