rl-rock 0.2.1.dev1__tar.gz → 0.2.1.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rl_rock-0.2.1.dev1/rl_rock.egg-info → rl_rock-0.2.1.dev2}/PKG-INFO +27 -7
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/README.md +26 -6
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/pyproject.toml +1 -1
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2/rl_rock.egg-info}/PKG-INFO +27 -7
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rl_rock.egg-info/SOURCES.txt +6 -3
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/__init__.py +0 -4
- rl_rock-0.2.1.dev2/rock/actions/sandbox/request.py +66 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/entrypoints/sandbox_api.py +10 -13
- rl_rock-0.2.1.dev1/rock/admin/entrypoints/sandbox_read_api.py → rl_rock-0.2.1.dev2/rock/admin/entrypoints/sandbox_proxy_api.py +27 -31
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/main.py +8 -8
- rl_rock-0.2.1.dev2/rock/admin/proto/request.py +97 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/cli/command/admin.py +15 -14
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/cli/config.py +9 -5
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/config.py +20 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/config.py +11 -1
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/docker.py +10 -0
- rl_rock-0.2.1.dev2/rock/deployments/sandbox_validator.py +27 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/env_vars.py +6 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/__init__.py +1 -1
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/core/envhub.py +78 -13
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/server.py +1 -1
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/local_api.py +6 -6
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/local_sandbox.py +9 -46
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/gem_manager.py +1 -1
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/remote_sandbox.py +6 -6
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/sandbox_actor.py +7 -8
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/sandbox_manager.py +32 -33
- rl_rock-0.2.1.dev1/rock/sandbox/service/sandbox_read_service.py → rl_rock-0.2.1.dev2/rock/sandbox/service/sandbox_proxy_service.py +29 -19
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/builder/swe_rebench.py +3 -3
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/builder/terminal_bench.py +3 -3
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/sandbox/client.py +109 -66
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/__init__.py +11 -1
- rl_rock-0.2.1.dev2/rock/utils/database.py +14 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/docker.py +11 -0
- rl_rock-0.2.1.dev2/rock/utils/retry.py +45 -0
- rl_rock-0.2.1.dev1/rock/actions/sandbox/request.py +0 -178
- rl_rock-0.2.1.dev1/rock/admin/proto/request.py +0 -167
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/LICENSE +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/MANIFEST.in +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/envs/base.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/envs/request.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/envs/response.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/response.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/sandbox/base.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/sandbox/config.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/actions/sandbox/response.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/core/db_provider.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/core/ray_service.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/core/redis_key.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/core/sandbox_table.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/core/schema.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/entrypoints/warmup_api.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/gem/api.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/metrics/constants.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/metrics/decorator.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/metrics/monitor.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/proto/response.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/admin/proto/task.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/cli/command/command.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/cli/loader.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/cli/main.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/abstract.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/constants.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/hooks/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/hooks/abstract.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/local.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/manager.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/ray.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/remote.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/runtime_env.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/deployments/status.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/api/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/api/schemas.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/core/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/database/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/database/base.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/envhub/database/docker_env.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/logger.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/__main__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/exceptions.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/local_files/docker_run.sh +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/local_files/docker_run_with_pip.sh +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/local_files/docker_run_with_uv.sh +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/rocklet/server.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/base_actor.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/base_manager.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/gem_actor.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/job/warmup_actor.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/service/sandbox_meta.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sandbox/service/warmup_service.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/builder/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/builder/base.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/builder/provider/docker.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/builder/provider/dockerfile_builder.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/common/constants.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/envhub/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/envhub/client.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/envhub/schema.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/envs/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/envs/registration.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/envs/rock_env.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/sdk/sandbox/config.py +0 -0
- /rl_rock-0.2.1.dev1/rock/utils/concurrent.py → /rl_rock-0.2.1.dev2/rock/utils/concurrent_helper.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/data.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/exception.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/http.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/importer.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/providers/__init__.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/providers/nacos_provider.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/providers/redis_provider.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock/utils/system.py +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/rock-conf/rock-local.yml +0 -0
- {rl_rock-0.2.1.dev1 → rl_rock-0.2.1.dev2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rl-rock
|
|
3
|
-
Version: 0.2.1.
|
|
3
|
+
Version: 0.2.1.dev2
|
|
4
4
|
Summary: ROCK-Reinforcement Open Construction Kit
|
|
5
5
|
Author: chatos@alibaba
|
|
6
6
|
Requires-Python: <4.0,>=3.10
|
|
@@ -89,7 +89,7 @@ ROCK adopts a client-server architecture, supports different levels of isolation
|
|
|
89
89
|
[API References](https://alibaba.github.io/ROCK/docs/api)
|
|
90
90
|
|
|
91
91
|
---
|
|
92
|
-
|
|
92
|
+
**Recommended**: Install from source (using uv). Alternatively, install from PyPI. Start the local admin server:
|
|
93
93
|
|
|
94
94
|
```bash
|
|
95
95
|
# Clone repository
|
|
@@ -109,6 +109,22 @@ source .venv/bin/activate
|
|
|
109
109
|
rock admin start
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
### PyPI Installation (Recommended for simple testing)
|
|
113
|
+
|
|
114
|
+
To install ROCK from PyPI (recommended only for simple testing):
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Install from PyPI
|
|
118
|
+
pip install rl-rock
|
|
119
|
+
|
|
120
|
+
# If using the pip runtime environment (for sandbox dependency installation),
|
|
121
|
+
# you may need to set runtime environment type to pip:
|
|
122
|
+
export ROCK_WORKER_ENV_TYPE=pip
|
|
123
|
+
|
|
124
|
+
# Start admin server
|
|
125
|
+
rock admin start
|
|
126
|
+
```
|
|
127
|
+
|
|
112
128
|
**Notes**: ROCK depends on Docker and uv tools for environment management.
|
|
113
129
|
|
|
114
130
|
1. **Python Environment Configuration**: To ensure ROCK can correctly mount the project and virtual environment along with its base Python interpreter, it is strongly recommended to use uv-managed Python environments to create virtual environments rather than system Python. This can be achieved through the `--python-preference only-managed` parameter.
|
|
@@ -117,7 +133,9 @@ rock admin start
|
|
|
117
133
|
|
|
118
134
|
3. **Dependency Management**: Use the `uv` command to install all dependency groups, ensuring consistency between development, testing, and production environments.
|
|
119
135
|
|
|
120
|
-
4. **
|
|
136
|
+
4. **Pip Source Installation**: For pip source installation (e.g., `pip install rl-rock`), you need to set the `ROCK_WORKER_ENV_TYPE=pip` environment variable and ensure network access for the sandbox to install dependencies. See [Configuration Documentation](docs/rock/configuration.md) for more details on runtime environment options and environment variables.
|
|
137
|
+
|
|
138
|
+
5. **OS Support**: ROCK recommends managing environments on the same operating system, such as managing Linux image environments on a Linux system. However, it also supports cross-operating system level image management, for example, launching Ubuntu images on MacOS.
|
|
121
139
|
|
|
122
140
|
### Using Env Protocol
|
|
123
141
|
ROCK is fully compatible with the GEM protocol, providing standardized environment interfaces:
|
|
@@ -231,8 +249,8 @@ observation, reward, terminated, truncated, info = env.step(action)
|
|
|
231
249
|
# Activate virtual environment
|
|
232
250
|
source .venv/bin/activate
|
|
233
251
|
|
|
234
|
-
# Start Rock service, local startup
|
|
235
|
-
admin
|
|
252
|
+
# Start Rock service, default local startup
|
|
253
|
+
rock admin start
|
|
236
254
|
```
|
|
237
255
|
|
|
238
256
|
> **Service Information**: The ROCK Local Admin service runs by default on `http://127.0.0.1:8080`. You can access this address through your browser to view the management interface.
|
|
@@ -286,7 +304,7 @@ Special thanks to:
|
|
|
286
304
|
|
|
287
305
|
---
|
|
288
306
|
|
|
289
|
-
## 🤝 About [ROCK
|
|
307
|
+
## 🤝 About [ROCK & ROLL Team]
|
|
290
308
|
ROCK is a project jointly developed by Taotian Future Living Lab and Alibaba AI Engine Team, with a strong emphasis on pioneering the future of Reinforcement Learning (RL). Our mission is to explore and shape innovative forms of future living powered by advanced RL technologies. If you are passionate about the future of RL and want to be part of its evolution, we warmly welcome you to join us!
|
|
291
309
|
|
|
292
310
|
For more information about **ROLL**, please visit:
|
|
@@ -298,7 +316,9 @@ Learn more about the ROCK & ROLL Team through our official channels below👇
|
|
|
298
316
|
<a href="./assets/rock_wechat.png" target="_blank">
|
|
299
317
|
<img src="https://img.shields.io/badge/WeChat-green?logo=wechat" alt="WeChat QR">
|
|
300
318
|
</a>
|
|
301
|
-
|
|
319
|
+
<a href="./assets/future_lab.png" target="_blank">
|
|
320
|
+
<img src="https://img.shields.io/twitter/follow/FutureLab2025?style=social" alt="X QR">
|
|
321
|
+
</a>
|
|
302
322
|
|
|
303
323
|
---
|
|
304
324
|
|
|
@@ -36,7 +36,7 @@ ROCK adopts a client-server architecture, supports different levels of isolation
|
|
|
36
36
|
[API References](https://alibaba.github.io/ROCK/docs/api)
|
|
37
37
|
|
|
38
38
|
---
|
|
39
|
-
|
|
39
|
+
**Recommended**: Install from source (using uv). Alternatively, install from PyPI. Start the local admin server:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
# Clone repository
|
|
@@ -56,6 +56,22 @@ source .venv/bin/activate
|
|
|
56
56
|
rock admin start
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### PyPI Installation (Recommended for simple testing)
|
|
60
|
+
|
|
61
|
+
To install ROCK from PyPI (recommended only for simple testing):
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Install from PyPI
|
|
65
|
+
pip install rl-rock
|
|
66
|
+
|
|
67
|
+
# If using the pip runtime environment (for sandbox dependency installation),
|
|
68
|
+
# you may need to set runtime environment type to pip:
|
|
69
|
+
export ROCK_WORKER_ENV_TYPE=pip
|
|
70
|
+
|
|
71
|
+
# Start admin server
|
|
72
|
+
rock admin start
|
|
73
|
+
```
|
|
74
|
+
|
|
59
75
|
**Notes**: ROCK depends on Docker and uv tools for environment management.
|
|
60
76
|
|
|
61
77
|
1. **Python Environment Configuration**: To ensure ROCK can correctly mount the project and virtual environment along with its base Python interpreter, it is strongly recommended to use uv-managed Python environments to create virtual environments rather than system Python. This can be achieved through the `--python-preference only-managed` parameter.
|
|
@@ -64,7 +80,9 @@ rock admin start
|
|
|
64
80
|
|
|
65
81
|
3. **Dependency Management**: Use the `uv` command to install all dependency groups, ensuring consistency between development, testing, and production environments.
|
|
66
82
|
|
|
67
|
-
4. **
|
|
83
|
+
4. **Pip Source Installation**: For pip source installation (e.g., `pip install rl-rock`), you need to set the `ROCK_WORKER_ENV_TYPE=pip` environment variable and ensure network access for the sandbox to install dependencies. See [Configuration Documentation](docs/rock/configuration.md) for more details on runtime environment options and environment variables.
|
|
84
|
+
|
|
85
|
+
5. **OS Support**: ROCK recommends managing environments on the same operating system, such as managing Linux image environments on a Linux system. However, it also supports cross-operating system level image management, for example, launching Ubuntu images on MacOS.
|
|
68
86
|
|
|
69
87
|
### Using Env Protocol
|
|
70
88
|
ROCK is fully compatible with the GEM protocol, providing standardized environment interfaces:
|
|
@@ -178,8 +196,8 @@ observation, reward, terminated, truncated, info = env.step(action)
|
|
|
178
196
|
# Activate virtual environment
|
|
179
197
|
source .venv/bin/activate
|
|
180
198
|
|
|
181
|
-
# Start Rock service, local startup
|
|
182
|
-
admin
|
|
199
|
+
# Start Rock service, default local startup
|
|
200
|
+
rock admin start
|
|
183
201
|
```
|
|
184
202
|
|
|
185
203
|
> **Service Information**: The ROCK Local Admin service runs by default on `http://127.0.0.1:8080`. You can access this address through your browser to view the management interface.
|
|
@@ -233,7 +251,7 @@ Special thanks to:
|
|
|
233
251
|
|
|
234
252
|
---
|
|
235
253
|
|
|
236
|
-
## 🤝 About [ROCK
|
|
254
|
+
## 🤝 About [ROCK & ROLL Team]
|
|
237
255
|
ROCK is a project jointly developed by Taotian Future Living Lab and Alibaba AI Engine Team, with a strong emphasis on pioneering the future of Reinforcement Learning (RL). Our mission is to explore and shape innovative forms of future living powered by advanced RL technologies. If you are passionate about the future of RL and want to be part of its evolution, we warmly welcome you to join us!
|
|
238
256
|
|
|
239
257
|
For more information about **ROLL**, please visit:
|
|
@@ -245,7 +263,9 @@ Learn more about the ROCK & ROLL Team through our official channels below👇
|
|
|
245
263
|
<a href="./assets/rock_wechat.png" target="_blank">
|
|
246
264
|
<img src="https://img.shields.io/badge/WeChat-green?logo=wechat" alt="WeChat QR">
|
|
247
265
|
</a>
|
|
248
|
-
|
|
266
|
+
<a href="./assets/future_lab.png" target="_blank">
|
|
267
|
+
<img src="https://img.shields.io/twitter/follow/FutureLab2025?style=social" alt="X QR">
|
|
268
|
+
</a>
|
|
249
269
|
|
|
250
270
|
---
|
|
251
271
|
|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
authors = [{ name = "chatos@alibaba" }]
|
|
8
8
|
requires-python = "<4.0,>=3.10"
|
|
9
9
|
name = "rl-rock"
|
|
10
|
-
version = "0.2.1.
|
|
10
|
+
version = "0.2.1.dev2"
|
|
11
11
|
description = "ROCK-Reinforcement Open Construction Kit"
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
dependencies = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rl-rock
|
|
3
|
-
Version: 0.2.1.
|
|
3
|
+
Version: 0.2.1.dev2
|
|
4
4
|
Summary: ROCK-Reinforcement Open Construction Kit
|
|
5
5
|
Author: chatos@alibaba
|
|
6
6
|
Requires-Python: <4.0,>=3.10
|
|
@@ -89,7 +89,7 @@ ROCK adopts a client-server architecture, supports different levels of isolation
|
|
|
89
89
|
[API References](https://alibaba.github.io/ROCK/docs/api)
|
|
90
90
|
|
|
91
91
|
---
|
|
92
|
-
|
|
92
|
+
**Recommended**: Install from source (using uv). Alternatively, install from PyPI. Start the local admin server:
|
|
93
93
|
|
|
94
94
|
```bash
|
|
95
95
|
# Clone repository
|
|
@@ -109,6 +109,22 @@ source .venv/bin/activate
|
|
|
109
109
|
rock admin start
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
### PyPI Installation (Recommended for simple testing)
|
|
113
|
+
|
|
114
|
+
To install ROCK from PyPI (recommended only for simple testing):
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Install from PyPI
|
|
118
|
+
pip install rl-rock
|
|
119
|
+
|
|
120
|
+
# If using the pip runtime environment (for sandbox dependency installation),
|
|
121
|
+
# you may need to set runtime environment type to pip:
|
|
122
|
+
export ROCK_WORKER_ENV_TYPE=pip
|
|
123
|
+
|
|
124
|
+
# Start admin server
|
|
125
|
+
rock admin start
|
|
126
|
+
```
|
|
127
|
+
|
|
112
128
|
**Notes**: ROCK depends on Docker and uv tools for environment management.
|
|
113
129
|
|
|
114
130
|
1. **Python Environment Configuration**: To ensure ROCK can correctly mount the project and virtual environment along with its base Python interpreter, it is strongly recommended to use uv-managed Python environments to create virtual environments rather than system Python. This can be achieved through the `--python-preference only-managed` parameter.
|
|
@@ -117,7 +133,9 @@ rock admin start
|
|
|
117
133
|
|
|
118
134
|
3. **Dependency Management**: Use the `uv` command to install all dependency groups, ensuring consistency between development, testing, and production environments.
|
|
119
135
|
|
|
120
|
-
4. **
|
|
136
|
+
4. **Pip Source Installation**: For pip source installation (e.g., `pip install rl-rock`), you need to set the `ROCK_WORKER_ENV_TYPE=pip` environment variable and ensure network access for the sandbox to install dependencies. See [Configuration Documentation](docs/rock/configuration.md) for more details on runtime environment options and environment variables.
|
|
137
|
+
|
|
138
|
+
5. **OS Support**: ROCK recommends managing environments on the same operating system, such as managing Linux image environments on a Linux system. However, it also supports cross-operating system level image management, for example, launching Ubuntu images on MacOS.
|
|
121
139
|
|
|
122
140
|
### Using Env Protocol
|
|
123
141
|
ROCK is fully compatible with the GEM protocol, providing standardized environment interfaces:
|
|
@@ -231,8 +249,8 @@ observation, reward, terminated, truncated, info = env.step(action)
|
|
|
231
249
|
# Activate virtual environment
|
|
232
250
|
source .venv/bin/activate
|
|
233
251
|
|
|
234
|
-
# Start Rock service, local startup
|
|
235
|
-
admin
|
|
252
|
+
# Start Rock service, default local startup
|
|
253
|
+
rock admin start
|
|
236
254
|
```
|
|
237
255
|
|
|
238
256
|
> **Service Information**: The ROCK Local Admin service runs by default on `http://127.0.0.1:8080`. You can access this address through your browser to view the management interface.
|
|
@@ -286,7 +304,7 @@ Special thanks to:
|
|
|
286
304
|
|
|
287
305
|
---
|
|
288
306
|
|
|
289
|
-
## 🤝 About [ROCK
|
|
307
|
+
## 🤝 About [ROCK & ROLL Team]
|
|
290
308
|
ROCK is a project jointly developed by Taotian Future Living Lab and Alibaba AI Engine Team, with a strong emphasis on pioneering the future of Reinforcement Learning (RL). Our mission is to explore and shape innovative forms of future living powered by advanced RL technologies. If you are passionate about the future of RL and want to be part of its evolution, we warmly welcome you to join us!
|
|
291
309
|
|
|
292
310
|
For more information about **ROLL**, please visit:
|
|
@@ -298,7 +316,9 @@ Learn more about the ROCK & ROLL Team through our official channels below👇
|
|
|
298
316
|
<a href="./assets/rock_wechat.png" target="_blank">
|
|
299
317
|
<img src="https://img.shields.io/badge/WeChat-green?logo=wechat" alt="WeChat QR">
|
|
300
318
|
</a>
|
|
301
|
-
|
|
319
|
+
<a href="./assets/future_lab.png" target="_blank">
|
|
320
|
+
<img src="https://img.shields.io/twitter/follow/FutureLab2025?style=social" alt="X QR">
|
|
321
|
+
</a>
|
|
302
322
|
|
|
303
323
|
---
|
|
304
324
|
|
|
@@ -24,7 +24,7 @@ rock/admin/core/redis_key.py
|
|
|
24
24
|
rock/admin/core/sandbox_table.py
|
|
25
25
|
rock/admin/core/schema.py
|
|
26
26
|
rock/admin/entrypoints/sandbox_api.py
|
|
27
|
-
rock/admin/entrypoints/
|
|
27
|
+
rock/admin/entrypoints/sandbox_proxy_api.py
|
|
28
28
|
rock/admin/entrypoints/warmup_api.py
|
|
29
29
|
rock/admin/gem/api.py
|
|
30
30
|
rock/admin/metrics/constants.py
|
|
@@ -48,6 +48,7 @@ rock/deployments/manager.py
|
|
|
48
48
|
rock/deployments/ray.py
|
|
49
49
|
rock/deployments/remote.py
|
|
50
50
|
rock/deployments/runtime_env.py
|
|
51
|
+
rock/deployments/sandbox_validator.py
|
|
51
52
|
rock/deployments/status.py
|
|
52
53
|
rock/deployments/hooks/__init__.py
|
|
53
54
|
rock/deployments/hooks/abstract.py
|
|
@@ -79,7 +80,7 @@ rock/sandbox/sandbox_actor.py
|
|
|
79
80
|
rock/sandbox/sandbox_manager.py
|
|
80
81
|
rock/sandbox/job/warmup_actor.py
|
|
81
82
|
rock/sandbox/service/sandbox_meta.py
|
|
82
|
-
rock/sandbox/service/
|
|
83
|
+
rock/sandbox/service/sandbox_proxy_service.py
|
|
83
84
|
rock/sandbox/service/warmup_service.py
|
|
84
85
|
rock/sdk/__init__.py
|
|
85
86
|
rock/sdk/builder/__init__.py
|
|
@@ -98,12 +99,14 @@ rock/sdk/envs/rock_env.py
|
|
|
98
99
|
rock/sdk/sandbox/client.py
|
|
99
100
|
rock/sdk/sandbox/config.py
|
|
100
101
|
rock/utils/__init__.py
|
|
101
|
-
rock/utils/
|
|
102
|
+
rock/utils/concurrent_helper.py
|
|
102
103
|
rock/utils/data.py
|
|
104
|
+
rock/utils/database.py
|
|
103
105
|
rock/utils/docker.py
|
|
104
106
|
rock/utils/exception.py
|
|
105
107
|
rock/utils/http.py
|
|
106
108
|
rock/utils/importer.py
|
|
109
|
+
rock/utils/retry.py
|
|
107
110
|
rock/utils/system.py
|
|
108
111
|
rock/utils/providers/__init__.py
|
|
109
112
|
rock/utils/providers/nacos_provider.py
|
|
@@ -7,13 +7,11 @@ from .sandbox.config import LocalSandboxRuntimeConfig, RemoteSandboxRuntimeConfi
|
|
|
7
7
|
from .sandbox.request import (
|
|
8
8
|
Action,
|
|
9
9
|
BashAction,
|
|
10
|
-
BashInterruptAction,
|
|
11
10
|
CloseBashSessionRequest,
|
|
12
11
|
CloseSessionRequest,
|
|
13
12
|
Command,
|
|
14
13
|
CreateBashSessionRequest,
|
|
15
14
|
CreateSessionRequest,
|
|
16
|
-
InitDockerEnvRequest,
|
|
17
15
|
ReadFileRequest,
|
|
18
16
|
UploadRequest,
|
|
19
17
|
WriteFileRequest,
|
|
@@ -59,12 +57,10 @@ __all__ = [
|
|
|
59
57
|
"CloseSessionResponse",
|
|
60
58
|
"CreateSessionRequest",
|
|
61
59
|
"BashAction",
|
|
62
|
-
"BashInterruptAction",
|
|
63
60
|
"Action",
|
|
64
61
|
"WriteFileRequest",
|
|
65
62
|
"CloseBashSessionRequest",
|
|
66
63
|
"CloseSessionRequest",
|
|
67
|
-
"InitDockerEnvRequest",
|
|
68
64
|
"ReadFileRequest",
|
|
69
65
|
"UploadRequest",
|
|
70
66
|
"IsAliveResponse",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from typing import Annotated, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Command(BaseModel):
|
|
7
|
+
session_type: Literal["bash"] = "bash"
|
|
8
|
+
command: str | list[str]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CreateBashSessionRequest(BaseModel):
|
|
12
|
+
session_type: Literal["bash"] = "bash"
|
|
13
|
+
session: str = "default"
|
|
14
|
+
startup_source: list[str] = []
|
|
15
|
+
env_enable: bool = False
|
|
16
|
+
env: dict[str, str] | None = Field(default=None)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
CreateSessionRequest = Annotated[CreateBashSessionRequest, Field(discriminator="session_type")]
|
|
20
|
+
"""Union type for all create session requests. Do not use this directly."""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BashAction(BaseModel):
|
|
24
|
+
action_type: Literal["bash"] = "bash"
|
|
25
|
+
command: str
|
|
26
|
+
session: str = "default"
|
|
27
|
+
timeout: float | None = None
|
|
28
|
+
check: Literal["silent", "raise", "ignore"] = "raise"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Action = Annotated[BashAction, Field(discriminator="action_type")]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class WriteFileRequest(BaseModel):
|
|
35
|
+
content: str
|
|
36
|
+
path: str
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CloseBashSessionRequest(BaseModel):
|
|
40
|
+
session_type: Literal["bash"] = "bash"
|
|
41
|
+
session: str = "default"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
CloseSessionRequest = Annotated[CloseBashSessionRequest, Field(discriminator="session_type")]
|
|
45
|
+
"""Union type for all close session requests. Do not use this directly."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ReadFileRequest(BaseModel):
|
|
49
|
+
path: str
|
|
50
|
+
"""File path to read from."""
|
|
51
|
+
|
|
52
|
+
encoding: str | None = None
|
|
53
|
+
"""Text encoding to use when reading the file. None uses default encoding.
|
|
54
|
+
This corresponds to the `encoding` parameter of `Path.read_text()`."""
|
|
55
|
+
|
|
56
|
+
errors: str | None = None
|
|
57
|
+
"""Error handling strategy when reading the file. None uses default handling.
|
|
58
|
+
This corresponds to the `errors` parameter of `Path.read_text()`."""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class UploadRequest(BaseModel):
|
|
62
|
+
source_path: str
|
|
63
|
+
"""Local file path to upload from."""
|
|
64
|
+
|
|
65
|
+
target_path: str
|
|
66
|
+
"""Remote file path to upload to."""
|
|
@@ -38,20 +38,20 @@ def set_sandbox_manager(service: SandboxManager):
|
|
|
38
38
|
|
|
39
39
|
@sandbox_router.post("/start")
|
|
40
40
|
@handle_exceptions(error_message="start sandbox failed")
|
|
41
|
-
async def start(
|
|
42
|
-
sandbox_start_response = await sandbox_manager.start(DockerDeploymentConfig
|
|
41
|
+
async def start(request: SandboxStartRequest) -> RockResponse[SandboxStartResponse]:
|
|
42
|
+
sandbox_start_response = await sandbox_manager.start(DockerDeploymentConfig.from_request(request))
|
|
43
43
|
return RockResponse(result=sandbox_start_response)
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
@sandbox_router.post("/start_async")
|
|
47
47
|
@handle_exceptions(error_message="async start sandbox failed")
|
|
48
48
|
async def start_async(
|
|
49
|
-
|
|
49
|
+
request: SandboxStartRequest,
|
|
50
50
|
x_user_id: str | None = Header(default="default", alias="X-User-Id"),
|
|
51
51
|
x_experiment_id: str | None = Header(default="default", alias="X-Experiment-Id"),
|
|
52
52
|
) -> RockResponse[SandboxStartResponse]:
|
|
53
53
|
sandbox_start_response = await sandbox_manager.start_async(
|
|
54
|
-
DockerDeploymentConfig
|
|
54
|
+
DockerDeploymentConfig.from_request(request),
|
|
55
55
|
user_info={"user_id": x_user_id, "experiment_id": x_experiment_id},
|
|
56
56
|
)
|
|
57
57
|
return RockResponse(result=sandbox_start_response)
|
|
@@ -84,37 +84,37 @@ async def get_status(sandbox_id: str):
|
|
|
84
84
|
@sandbox_router.post("/execute")
|
|
85
85
|
@handle_exceptions(error_message="execute command failed")
|
|
86
86
|
async def execute(command: SandboxCommand) -> RockResponse[CommandResponse]:
|
|
87
|
-
return RockResponse(result=await sandbox_manager.execute(command
|
|
87
|
+
return RockResponse(result=await sandbox_manager.execute(command))
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
@sandbox_router.post("/create_session")
|
|
91
91
|
@handle_exceptions(error_message="create session failed")
|
|
92
92
|
async def create_session(request: SandboxCreateBashSessionRequest) -> RockResponse[CreateBashSessionResponse]:
|
|
93
|
-
return RockResponse(result=await sandbox_manager.create_session(request
|
|
93
|
+
return RockResponse(result=await sandbox_manager.create_session(request))
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
@sandbox_router.post("/run_in_session")
|
|
97
97
|
@handle_exceptions(error_message="run in session failed")
|
|
98
98
|
async def run(action: SandboxBashAction) -> RockResponse[BashObservation]:
|
|
99
|
-
return RockResponse(result=await sandbox_manager.run_in_session(action
|
|
99
|
+
return RockResponse(result=await sandbox_manager.run_in_session(action))
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
@sandbox_router.post("/close_session")
|
|
103
103
|
@handle_exceptions(error_message="close session failed")
|
|
104
104
|
async def close_session(request: SandboxCloseBashSessionRequest) -> RockResponse[CloseBashSessionResponse]:
|
|
105
|
-
return RockResponse(result=await sandbox_manager.close_session(request
|
|
105
|
+
return RockResponse(result=await sandbox_manager.close_session(request))
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
@sandbox_router.post("/read_file")
|
|
109
109
|
@handle_exceptions(error_message="read file failed")
|
|
110
110
|
async def read_file(request: SandboxReadFileRequest) -> RockResponse[ReadFileResponse]:
|
|
111
|
-
return RockResponse(result=await sandbox_manager.read_file(request
|
|
111
|
+
return RockResponse(result=await sandbox_manager.read_file(request))
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
@sandbox_router.post("/write_file")
|
|
115
115
|
@handle_exceptions(error_message="write file failed")
|
|
116
116
|
async def write_file(request: SandboxWriteFileRequest) -> RockResponse[WriteFileResponse]:
|
|
117
|
-
return RockResponse(result=await sandbox_manager.write_file(request
|
|
117
|
+
return RockResponse(result=await sandbox_manager.write_file(request))
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
@sandbox_router.post("/upload")
|
|
@@ -122,11 +122,8 @@ async def write_file(request: SandboxWriteFileRequest) -> RockResponse[WriteFile
|
|
|
122
122
|
async def upload(
|
|
123
123
|
file: UploadFile = File(...),
|
|
124
124
|
target_path: str = Form(...),
|
|
125
|
-
container_name: str | None = Form(None),
|
|
126
125
|
sandbox_id: str | None = Form(None),
|
|
127
126
|
) -> RockResponse[UploadResponse]:
|
|
128
|
-
if container_name:
|
|
129
|
-
return RockResponse(result=await sandbox_manager.upload(file, target_path, container_name))
|
|
130
127
|
return RockResponse(result=await sandbox_manager.upload(file, target_path, sandbox_id))
|
|
131
128
|
|
|
132
129
|
|
|
@@ -22,85 +22,81 @@ from rock.admin.proto.request import (
|
|
|
22
22
|
SandboxReadFileRequest,
|
|
23
23
|
SandboxWriteFileRequest,
|
|
24
24
|
)
|
|
25
|
-
from rock.sandbox.service.
|
|
25
|
+
from rock.sandbox.service.sandbox_proxy_service import SandboxProxyService
|
|
26
26
|
from rock.utils import handle_exceptions
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
sandbox_proxy_router = APIRouter()
|
|
29
|
+
sandbox_proxy_service: SandboxProxyService
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def
|
|
33
|
-
global
|
|
34
|
-
|
|
32
|
+
def set_sandbox_proxy_service(service: SandboxProxyService):
|
|
33
|
+
global sandbox_proxy_service
|
|
34
|
+
sandbox_proxy_service = service
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
@
|
|
37
|
+
@sandbox_proxy_router.post("/execute")
|
|
38
38
|
@handle_exceptions(error_message="execute command failed")
|
|
39
39
|
async def execute(command: SandboxCommand) -> RockResponse[CommandResponse]:
|
|
40
|
-
return RockResponse(result=await
|
|
40
|
+
return RockResponse(result=await sandbox_proxy_service.execute(command))
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
@
|
|
43
|
+
@sandbox_proxy_router.post("/create_session")
|
|
44
44
|
@handle_exceptions(error_message="create session failed")
|
|
45
45
|
async def create_session(request: SandboxCreateBashSessionRequest) -> RockResponse[CreateBashSessionResponse]:
|
|
46
|
-
return RockResponse(result=await
|
|
46
|
+
return RockResponse(result=await sandbox_proxy_service.create_session(request))
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
@
|
|
49
|
+
@sandbox_proxy_router.post("/run_in_session")
|
|
50
50
|
@handle_exceptions(error_message="run in session failed")
|
|
51
51
|
async def run(action: SandboxBashAction) -> RockResponse[BashObservation]:
|
|
52
|
-
result = await
|
|
52
|
+
result = await sandbox_proxy_service.run_in_session(action)
|
|
53
53
|
if result.exit_code is not None and result.exit_code == -1:
|
|
54
54
|
return RockResponse(status=ResponseStatus.FAILED, error=result.failure_reason)
|
|
55
55
|
return RockResponse(result=result)
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
@
|
|
58
|
+
@sandbox_proxy_router.post("/close_session")
|
|
59
59
|
@handle_exceptions(error_message="close session failed")
|
|
60
60
|
async def close_session(request: SandboxCloseBashSessionRequest) -> RockResponse[CloseBashSessionResponse]:
|
|
61
|
-
return RockResponse(result=await
|
|
61
|
+
return RockResponse(result=await sandbox_proxy_service.close_session(request))
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
@
|
|
64
|
+
@sandbox_proxy_router.get("/is_alive")
|
|
65
65
|
@handle_exceptions(error_message="get sandbox is alive failed")
|
|
66
66
|
async def is_alive(sandbox_id: str):
|
|
67
|
-
return RockResponse(result=await
|
|
67
|
+
return RockResponse(result=await sandbox_proxy_service.is_alive(sandbox_id))
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
@
|
|
70
|
+
@sandbox_proxy_router.post("/read_file")
|
|
71
71
|
@handle_exceptions(error_message="read file failed")
|
|
72
72
|
async def read_file(request: SandboxReadFileRequest) -> RockResponse[ReadFileResponse]:
|
|
73
|
-
return RockResponse(result=await
|
|
73
|
+
return RockResponse(result=await sandbox_proxy_service.read_file(request))
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
@
|
|
76
|
+
@sandbox_proxy_router.post("/write_file")
|
|
77
77
|
@handle_exceptions(error_message="write file failed")
|
|
78
78
|
async def write_file(request: SandboxWriteFileRequest) -> RockResponse[WriteFileResponse]:
|
|
79
|
-
return RockResponse(result=await
|
|
79
|
+
return RockResponse(result=await sandbox_proxy_service.write_file(request))
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
@
|
|
82
|
+
@sandbox_proxy_router.post("/upload")
|
|
83
83
|
@handle_exceptions(error_message="upload file failed")
|
|
84
84
|
async def upload(
|
|
85
85
|
file: UploadFile = File(...),
|
|
86
86
|
target_path: str = Form(...),
|
|
87
|
-
container_name: str | None = Form(None),
|
|
88
87
|
sandbox_id: str | None = Form(None),
|
|
89
88
|
) -> RockResponse[UploadResponse]:
|
|
90
|
-
|
|
91
|
-
return RockResponse(result=await sandbox_read_service.upload(file, target_path, container_name))
|
|
92
|
-
else:
|
|
93
|
-
return RockResponse(result=await sandbox_read_service.upload(file, target_path, sandbox_id))
|
|
89
|
+
return RockResponse(result=await sandbox_proxy_service.upload(file, target_path, sandbox_id))
|
|
94
90
|
|
|
95
91
|
|
|
96
|
-
@
|
|
97
|
-
@
|
|
92
|
+
@sandbox_proxy_router.websocket("/sandboxes/{id}/proxy/ws")
|
|
93
|
+
@sandbox_proxy_router.websocket("/sandboxes/{id}/proxy/ws/{path:path}")
|
|
98
94
|
async def websocket_proxy(websocket: WebSocket, id: str, path: str = ""):
|
|
99
95
|
await websocket.accept()
|
|
100
96
|
sandbox_id = id
|
|
101
97
|
logging.info(f"Client connected to WebSocket proxy: {sandbox_id}, path: {path}")
|
|
102
98
|
try:
|
|
103
|
-
await
|
|
99
|
+
await sandbox_proxy_service.websocket_proxy(websocket, sandbox_id, path)
|
|
104
100
|
except WebSocketDisconnect:
|
|
105
101
|
logging.info(f"Client disconnected from WebSocket proxy: {sandbox_id}")
|
|
106
102
|
except Exception as e:
|
|
@@ -108,8 +104,8 @@ async def websocket_proxy(websocket: WebSocket, id: str, path: str = ""):
|
|
|
108
104
|
await websocket.close(code=1011, reason=f"Proxy error: {str(e)}")
|
|
109
105
|
|
|
110
106
|
|
|
111
|
-
@
|
|
107
|
+
@sandbox_proxy_router.get("/get_token")
|
|
112
108
|
@handle_exceptions(error_message="get oss sts token failed")
|
|
113
109
|
async def get_token():
|
|
114
|
-
result = await asyncio.to_thread(
|
|
110
|
+
result = await asyncio.to_thread(sandbox_proxy_service.gen_oss_sts_token)
|
|
115
111
|
return RockResponse(result=result)
|
|
@@ -13,20 +13,20 @@ from starlette.responses import JSONResponse
|
|
|
13
13
|
from rock import env_vars
|
|
14
14
|
from rock.admin.core.ray_service import RayService
|
|
15
15
|
from rock.admin.entrypoints.sandbox_api import sandbox_router, set_sandbox_manager
|
|
16
|
-
from rock.admin.entrypoints.
|
|
16
|
+
from rock.admin.entrypoints.sandbox_proxy_api import sandbox_proxy_router, set_sandbox_proxy_service
|
|
17
17
|
from rock.admin.entrypoints.warmup_api import set_warmup_service, warmup_router
|
|
18
18
|
from rock.admin.gem.api import gem_router, set_env_service
|
|
19
19
|
from rock.config import RockConfig
|
|
20
20
|
from rock.logger import init_logger
|
|
21
21
|
from rock.sandbox.gem_manager import GemManager
|
|
22
|
-
from rock.sandbox.service.
|
|
22
|
+
from rock.sandbox.service.sandbox_proxy_service import SandboxProxyService
|
|
23
23
|
from rock.sandbox.service.warmup_service import WarmupService
|
|
24
24
|
from rock.utils import sandbox_id_ctx_var
|
|
25
25
|
from rock.utils.providers import RedisProvider
|
|
26
26
|
|
|
27
27
|
parser = argparse.ArgumentParser()
|
|
28
28
|
parser.add_argument("--env", type=str, default="local")
|
|
29
|
-
parser.add_argument("--role", type=str, default="
|
|
29
|
+
parser.add_argument("--role", type=str, default="admin", choices=["admin", "proxy"])
|
|
30
30
|
parser.add_argument("--port", type=int, default=8080)
|
|
31
31
|
|
|
32
32
|
args = parser.parse_args()
|
|
@@ -58,7 +58,7 @@ async def lifespan(app: FastAPI):
|
|
|
58
58
|
await redis_provider.init_pool()
|
|
59
59
|
|
|
60
60
|
# init sandbox service
|
|
61
|
-
if args.role == "
|
|
61
|
+
if args.role == "admin":
|
|
62
62
|
# init service
|
|
63
63
|
if rock_config.runtime.enable_auto_clear:
|
|
64
64
|
sandbox_manager = GemManager(
|
|
@@ -82,8 +82,8 @@ async def lifespan(app: FastAPI):
|
|
|
82
82
|
|
|
83
83
|
RayService(rock_config.ray).init()
|
|
84
84
|
else:
|
|
85
|
-
sandbox_manager =
|
|
86
|
-
|
|
85
|
+
sandbox_manager = SandboxProxyService(rock_config=rock_config, redis_provider=redis_provider)
|
|
86
|
+
set_sandbox_proxy_service(sandbox_manager)
|
|
87
87
|
|
|
88
88
|
logger.info("rock-admin start")
|
|
89
89
|
|
|
@@ -163,10 +163,10 @@ async def log_requests_and_responses(request: Request, call_next):
|
|
|
163
163
|
|
|
164
164
|
def main():
|
|
165
165
|
# config router
|
|
166
|
-
if args.role == "
|
|
166
|
+
if args.role == "admin":
|
|
167
167
|
app.include_router(sandbox_router, prefix="/apis/envs/sandbox/v1", tags=["sandbox"])
|
|
168
168
|
else:
|
|
169
|
-
app.include_router(
|
|
169
|
+
app.include_router(sandbox_proxy_router, prefix="/apis/envs/sandbox/v1", tags=["sandbox"])
|
|
170
170
|
app.include_router(warmup_router, prefix="/apis/envs/sandbox/v1", tags=["warmup"])
|
|
171
171
|
app.include_router(gem_router, prefix="/apis/v1/envs/gem", tags=["gem"])
|
|
172
172
|
|