e0e362d700
SDK Tests / SDK CI (push) Blocked by required conditions
SDK Tests / changes (push) Successful in 2m29s
Real E2E Tests / changes (push) Successful in 2m29s
SDK Tests / Python SDK Tests (sandbox) (push) Waiting to run
SDK Tests / CLI Quality (push) Waiting to run
SDK Tests / CLI Tests (push) Waiting to run
SDK Tests / Python SDK Quality (code-interpreter) (push) Waiting to run
SDK Tests / Python SDK Quality (sandbox) (push) Waiting to run
SDK Tests / Python SDK Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Go SDK Quality And Tests (push) Waiting to run
Deploy Docs Pages / build (push) Has been cancelled
Deploy Docs Pages / deploy (push) Has been cancelled
Real E2E Tests / JavaScript E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Python E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Java E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / C# E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Go E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Real E2E CI (push) Has been cancelled
54 lines
1.7 KiB
Markdown
54 lines
1.7 KiB
Markdown
---
|
|
title: RL Training
|
|
description: Run a basic reinforcement learning training loop (CartPole + DQN) inside an isolated OpenSandbox container.
|
|
---
|
|
|
|
# Reinforcement Learning Sandbox Example
|
|
|
|
Demonstrates running a basic RL training loop (CartPole + DQN) inside an isolated OpenSandbox container. The example installs RL dependencies in the sandbox, trains a policy, saves a checkpoint, and returns a training summary.
|
|
|
|
## Start OpenSandbox server [local]
|
|
|
|
Start the local OpenSandbox server:
|
|
|
|
```shell
|
|
uv pip install opensandbox-server
|
|
opensandbox-server init-config ~/.sandbox.toml --example docker
|
|
opensandbox-server
|
|
```
|
|
|
|
## Run the Example
|
|
|
|
```shell
|
|
# Install OpenSandbox package
|
|
uv pip install opensandbox
|
|
|
|
# Run the example
|
|
uv run python examples/rl-training/main.py
|
|
```
|
|
|
|
The script provisions a sandbox, installs RL dependencies, trains a DQN agent on CartPole, saves a checkpoint, and prints the JSON training summary.
|
|
|
|

|
|
|
|
## Environment Variables
|
|
|
|
| Variable | Default | Description |
|
|
|----------|---------|-------------|
|
|
| `SANDBOX_DOMAIN` | `localhost:8080` | Sandbox service address |
|
|
| `SANDBOX_API_KEY` | _(optional)_ | API key if your server requires authentication |
|
|
| `SANDBOX_IMAGE` | `sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/code-interpreter:v1.1.0` | Docker image to use |
|
|
| `RL_TIMESTEPS` | `5000` | Training timesteps to run |
|
|
|
|
## TensorBoard
|
|
|
|
The training script logs to `runs/`. To visualize metrics, open a shell in the sandbox and run:
|
|
|
|
```shell
|
|
tensorboard --logdir runs --host 0.0.0.0 --port 6006
|
|
```
|
|
|
|
## References
|
|
|
|
- [Source code on GitHub](https://github.com/opensandbox-group/OpenSandbox/tree/main/examples/rl-training)
|