Fix simple_client docker flow and documentation
This commit is contained in:
committed by
uzhilinsky
parent
098d387c8e
commit
fc7b7bc694
@@ -29,4 +29,4 @@ RUN uv venv --python 3.7 $UV_PROJECT_ENVIRONMENT
|
|||||||
RUN uv pip sync /tmp/requirements.txt /tmp/openpi-client/pyproject.toml
|
RUN uv pip sync /tmp/requirements.txt /tmp/openpi-client/pyproject.toml
|
||||||
ENV PYTHONPATH=/app:/app/src:/app/packages/openpi-client/src
|
ENV PYTHONPATH=/app:/app/src:/app/packages/openpi-client/src
|
||||||
|
|
||||||
CMD ["/bin/bash", "-c", "source /.venv/bin/activate && python examples/simple_client/main.py"]
|
CMD /bin/bash -c "source /.venv/bin/activate && python examples/simple_client/main.py $SERVER_ARGS"
|
||||||
|
|||||||
@@ -2,10 +2,16 @@
|
|||||||
|
|
||||||
A minimal client that sends observations to the server and prints the inference rate.
|
A minimal client that sends observations to the server and prints the inference rate.
|
||||||
|
|
||||||
|
You can specifiy which runtime environment to use using the `--env` flag. You can see the available options by running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv run examples/simple_client/main.py --help
|
||||||
|
```
|
||||||
|
|
||||||
## With Docker
|
## With Docker
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export SERVER_ARGS="--example aloha"
|
export SERVER_ARGS="--env ALOHA_SIM"
|
||||||
docker compose -f examples/simple_client/compose.yml up --build
|
docker compose -f examples/simple_client/compose.yml up --build
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -14,11 +20,11 @@ docker compose -f examples/simple_client/compose.yml up --build
|
|||||||
Terminal window 1:
|
Terminal window 1:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
uv run examples/simple_client/main.py
|
uv run examples/simple_client/main.py --env DROID
|
||||||
```
|
```
|
||||||
|
|
||||||
Terminal window 2:
|
Terminal window 2:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
uv run scripts/serve_policy.py
|
uv run scripts/serve_policy.py --env DROID
|
||||||
```
|
```
|
||||||
@@ -13,6 +13,8 @@ services:
|
|||||||
network_mode: host
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
- $PWD:/app
|
- $PWD:/app
|
||||||
|
environment:
|
||||||
|
- SERVER_ARGS
|
||||||
|
|
||||||
openpi_server:
|
openpi_server:
|
||||||
image: openpi_server
|
image: openpi_server
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import dataclasses
|
import dataclasses
|
||||||
|
import enum
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -7,21 +8,32 @@ from openpi_client import websocket_client_policy as _websocket_client_policy
|
|||||||
import tyro
|
import tyro
|
||||||
|
|
||||||
|
|
||||||
|
class EnvMode(enum.Enum):
|
||||||
|
"""Supported environments."""
|
||||||
|
|
||||||
|
ALOHA = "aloha"
|
||||||
|
ALOHA_SIM = "aloha_sim"
|
||||||
|
DROID = "droid"
|
||||||
|
CALVIN = "calvin"
|
||||||
|
LIBERO = "libero"
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class Args:
|
class Args:
|
||||||
host: str = "0.0.0.0"
|
host: str = "0.0.0.0"
|
||||||
port: int = 8000
|
port: int = 8000
|
||||||
|
|
||||||
example: str = "droid"
|
env: EnvMode = EnvMode.ALOHA_SIM
|
||||||
|
|
||||||
|
|
||||||
def main(args: Args) -> None:
|
def main(args: Args) -> None:
|
||||||
obs_fn = {
|
obs_fn = {
|
||||||
"aloha": _random_observation_aloha,
|
EnvMode.ALOHA: _random_observation_aloha,
|
||||||
"droid": _random_observation_droid,
|
EnvMode.ALOHA_SIM: _random_observation_aloha,
|
||||||
"calvin": _random_observation_calvin,
|
EnvMode.DROID: _random_observation_droid,
|
||||||
"libero": _random_observation_libero,
|
EnvMode.CALVIN: _random_observation_calvin,
|
||||||
}[args.example]
|
EnvMode.LIBERO: _random_observation_libero,
|
||||||
|
}[args.env]
|
||||||
|
|
||||||
policy = _websocket_client_policy.WebsocketClientPolicy(
|
policy = _websocket_client_policy.WebsocketClientPolicy(
|
||||||
host=args.host,
|
host=args.host,
|
||||||
|
|||||||
Reference in New Issue
Block a user