CartPole walkthrough
Run the quickstart example files: serve CartPole-v1, connect a sampled-action evaluator, and swap environments by flag.
The Quickstart has the shortest copy-and-paste version. This page runs the example files from the RLMesh repository. Clone it and run these commands from its root; they do not run from an installed Python package alone.
Serve CartPole
From the repository root, start the server in one terminal:
uv run python examples/python/quickstart/serve_gymnasium.py
serve_gymnasium.py makes the Gymnasium environment and hands it to
EnvServer, which inspects the spaces, binds the endpoint, and keeps Gymnasium
inside the server process. The client never imports it. See
Serving Environments for the server API.
Connect a client
In a second terminal:
uv run python examples/python/quickstart/eval.py
eval.py connects a RemoteEnv and drives the Gymnasium loop with sampled
actions. RemoteEnv learns observation_space and action_space from the
server on connect, so the sampled-action loop runs without any
environment-specific imports. Remote Clients
covers the client side.
Swap environments
serve_gymnasium.py takes any Gymnasium registration through --env-id:
uv run python examples/python/quickstart/serve_gymnasium.py --env-id Acrobot-v1
To run several servers side by side, give each its own --address:
uv run python examples/python/quickstart/serve_gymnasium.py --address 127.0.0.1:5556
eval.py only needs the matching --address; nothing else about the loop
changes.
For a server with no Gymnasium dependency, serve.py serves a tiny
Gymnasium-shaped CounterEnv defined in the same directory:
uv run python examples/python/quickstart/serve.py