Skip to content

Commit f39efd5

Browse files
authored
Fixed training sandbox download link bugs and class name. (agentscope-ai#20)
## Description [Describe what this PR does and why] **Related Issue:** Fixes #[issue_number] or Relates to #[issue_number] **Security Considerations:** [If applicable, especially for sandbox changes] ## Type of Change - [x] Bug fix - [ ] New feature - [ ] Breaking change - [x] Documentation - [ ] Refactoring ## Component(s) Affected - [ ] Engine - [x] Sandbox - [ ] Documentation - [ ] Tests - [ ] CI/CD ## Checklist - [x] Pre-commit hooks pass - [x] Tests pass locally - [ ] Documentation updated (if needed) - [ ] Ready for review ## Testing [How to test these changes] ## Additional Notes [Optional: any other context]
1 parent 160d724 commit f39efd5

File tree

6 files changed

+155
-25
lines changed

6 files changed

+155
-25
lines changed

cookbook/en/training_sandbox.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ All Docker images are hosted on Alibaba Cloud Container Registry (ACR) for optim
5858

5959
```bash
6060
# Pull and tag Appworld ARM64 architecture image
61-
docker pull agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm && docker tag agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm agentscope/runtime-sandbox-appworld:latest-arm
61+
docker pull agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm64 && docker tag agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm agentscope/runtime-sandbox-appworld:latest-arm
6262

6363
# Pull and tag Appworld X86_64 architecture image
6464
docker pull agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest && docker tag agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest agentscope/runtime-sandbox-appworld:latest
@@ -89,7 +89,7 @@ For training sandboxes, different datasets use different Dockerfiles, located at
8989
For Appworld:
9090

9191
```bash
92-
docker build -f src/agentscope_runtime/sandbox/box/training_box/environments/appworld/Dockerfile -t agentscope/runtime-sandbox-appworld:v0.0.1 .
92+
docker build -f src/agentscope_runtime/sandbox/box/training_box/environments/appworld/Dockerfile -t agentscope/runtime-sandbox-appworld:latest .
9393
```
9494

9595
## Utilize Training Sample from Sandbox

cookbook/zh/training_sandbox.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pip install "agentscope-runtime[sandbox]"
5050

5151
```bash
5252
# 拉取并标记Appworld ARM64架构镜像
53-
docker pull agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm && docker tag agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm agentscope/runtime-sandbox-appworld:latest-arm
53+
docker pull agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm64 && docker tag agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest-arm agentscope/runtime-sandbox-appworld:latest-arm
5454

5555
# 拉取并标记 Appworld X86_64 架构镜像
5656
docker pull agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest && docker tag agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-appworld:latest agentscope/runtime-sandbox-appworld:latest
@@ -80,7 +80,7 @@ with TrainingSandbox() as box:
8080
以appworld为例:
8181

8282
```bash
83-
docker build -f src/agentscope_runtime/sandbox/box/training_box/environments/appworld/Dockerfile -t agentscope/runtime-sandbox-appworld:v0.0.1 .
83+
docker build -f src/agentscope_runtime/sandbox/box/training_box/environments/appworld/Dockerfile -t agentscope/runtime-sandbox-appworld:latest .
8484
```
8585

8686
## 训练样本使用

src/agentscope_runtime/sandbox/box/training_box/environments/appworld/Dockerfile

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ RUN apt-get update && apt-get install -y \
1919
unzip \
2020
&& rm -rf /var/lib/apt/lists/*
2121

22-
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O /tmp/miniconda.sh && \
22+
# install conda
23+
24+
RUN ARCH=$(uname -m) && \
25+
if [ "$ARCH" = "x86_64" ]; then \
26+
MINICONDA=Miniconda3-latest-Linux-x86_64.sh; \
27+
elif [ "$ARCH" = "aarch64" ]; then \
28+
MINICONDA=Miniconda3-latest-Linux-aarch64.sh; \
29+
else \
30+
echo "Unsupported architecture: $ARCH" && exit 1; \
31+
fi && \
32+
wget https://repo.anaconda.com/miniconda/${MINICONDA} -O /tmp/miniconda.sh && \
2333
chmod +x /tmp/miniconda.sh && \
2434
bash /tmp/miniconda.sh -b -p /opt/conda && \
2535
rm /tmp/miniconda.sh
2636

37+
2738
# Optionally, add conda to PATH
2839
ENV PATH="/opt/conda/bin:${PATH}"
2940

@@ -51,18 +62,19 @@ RUN /opt/conda/envs/appworld/bin/appworld install
5162

5263
ENV APPWORLD_ROOT=/agentscope_runtime/appworld/
5364

54-
RUN /opt/conda/envs/appworld/bin/appworld download data
55-
56-
RUN mv /agentscope_runtime/data /agentscope_runtime/appworld/
65+
#
66+
#RUN /opt/conda/envs/appworld/bin/appworld download data
67+
#
68+
#RUN mv /agentscope_runtime/data /agentscope_runtime/appworld/
5769
# If download fails, you may get the data from this source and move it locally by commenting two lines above and uncommenting the following lines
5870

59-
# RUN wget -O appworld_data.zip "https://dail-wlcb.oss-accelerate.aliyuncs.com/eric.czq/appworld_data.zip"
71+
RUN wget -O appworld_data.zip "https://dail-wlcb.oss-accelerate.aliyuncs.com/eric.czq/appworld_data.zip"
6072

61-
# RUN mkdir -p /agentscope_runtime/appworld && \
62-
# mkdir /tmp/unziptemp && \
63-
# unzip appworld_data.zip -d /tmp/unziptemp && \
64-
# mv /tmp/unziptemp/*/* /agentscope_runtime/appworld && \
65-
# rm -rf /tmp/unziptemp
73+
RUN mkdir -p /agentscope_runtime/appworld && \
74+
mkdir /tmp/unziptemp && \
75+
unzip appworld_data.zip -d /tmp/unziptemp && \
76+
mv /tmp/unziptemp/*/* /agentscope_runtime/appworld && \
77+
rm -rf /tmp/unziptemp
6678

6779

6880
ENV PYTHONPATH=/agentscope_runtime:$PYTHONPATH

src/agentscope_runtime/sandbox/box/training_box/training_box.py

Lines changed: 125 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ def get_image_tag() -> str:
2121
return IMAGE_TAG
2222

2323

24-
@SandboxRegistry.register(
25-
f"agentscope/runtime-sandbox-appworld:{get_image_tag()}",
26-
sandbox_type=SandboxType.APPWORLD,
27-
runtime_config={"shm_size": "5.06gb"},
28-
security_level="medium",
29-
timeout=30,
30-
description="appworld Sandbox",
31-
)
3224
class TrainingSandbox(Sandbox):
3325
"""
3426
Training Sandbox class for managing and executing training-related tasks.
@@ -43,6 +35,7 @@ def __init__(
4335
timeout: int = 3000,
4436
base_url: Optional[str] = None,
4537
bearer_token: Optional[str] = None,
38+
box_type: SandboxType = SandboxType.APPWORLD,
4639
):
4740
"""
4841
Initialize the Training Sandbox.
@@ -58,7 +51,7 @@ def __init__(
5851
timeout,
5952
base_url,
6053
bearer_token,
61-
SandboxType.APPWORLD,
54+
box_type,
6255
)
6356

6457
def create_instance(
@@ -217,3 +210,126 @@ def release_instance(self, instance_id: str):
217210
"instance_id": instance_id,
218211
},
219212
)
213+
214+
215+
@SandboxRegistry.register(
216+
f"agentscope/runtime-sandbox-appworld:{get_image_tag()}",
217+
sandbox_type=SandboxType.APPWORLD,
218+
runtime_config={"shm_size": "5.06gb"},
219+
security_level="medium",
220+
timeout=30,
221+
description="appworld Sandbox",
222+
)
223+
class APPWorldSandbox(TrainingSandbox):
224+
"""
225+
Training Sandbox class for managing and executing training-related tasks.
226+
227+
This class provides methods to create, manage, and interact with
228+
training environment instances using specialized tool calls.
229+
"""
230+
231+
def __init__(
232+
self,
233+
sandbox_id: Optional[str] = None,
234+
timeout: int = 3000,
235+
base_url: Optional[str] = None,
236+
bearer_token: Optional[str] = None,
237+
):
238+
"""
239+
Initialize the Training Sandbox.
240+
241+
Args:
242+
sandbox_id (Optional[str]): Unique identifier for the sandbox.
243+
timeout (int): Maximum time allowed for sandbox operations.
244+
base_url (Optional[str]): Base URL for sandbox API.
245+
bearer_token (Optional[str]): Authentication token for API access.
246+
"""
247+
super().__init__(
248+
sandbox_id,
249+
timeout,
250+
base_url,
251+
bearer_token,
252+
SandboxType.APPWORLD,
253+
)
254+
255+
256+
@SandboxRegistry.register(
257+
f"agentscope/runtime-sandbox-bfcl:{get_image_tag()}",
258+
sandbox_type=SandboxType.BFCL,
259+
runtime_config={"shm_size": "5.06gb"},
260+
security_level="medium",
261+
timeout=30,
262+
description="bfcl Sandbox",
263+
)
264+
class BFCLSandbox(TrainingSandbox):
265+
"""
266+
Training Sandbox class for managing and executing training-related tasks.
267+
268+
This class provides methods to create, manage, and interact with
269+
training environment instances using specialized tool calls.
270+
"""
271+
272+
def __init__(
273+
self,
274+
sandbox_id: Optional[str] = None,
275+
timeout: int = 3000,
276+
base_url: Optional[str] = None,
277+
bearer_token: Optional[str] = None,
278+
):
279+
"""
280+
Initialize the Training Sandbox.
281+
282+
Args:
283+
sandbox_id (Optional[str]): Unique identifier for the sandbox.
284+
timeout (int): Maximum time allowed for sandbox operations.
285+
base_url (Optional[str]): Base URL for sandbox API.
286+
bearer_token (Optional[str]): Authentication token for API access.
287+
"""
288+
super().__init__(
289+
sandbox_id,
290+
timeout,
291+
base_url,
292+
bearer_token,
293+
SandboxType.BFCL,
294+
)
295+
296+
297+
@SandboxRegistry.register(
298+
f"agentscope/runtime-sandbox-webshop:{get_image_tag()}",
299+
sandbox_type=SandboxType.BFCL,
300+
runtime_config={"shm_size": "5.06gb"},
301+
security_level="medium",
302+
timeout=30,
303+
description="webshop Sandbox",
304+
)
305+
class WebShopSandbox(TrainingSandbox):
306+
"""
307+
Training Sandbox class for managing and executing training-related tasks.
308+
309+
This class provides methods to create, manage, and interact with
310+
training environment instances using specialized tool calls.
311+
"""
312+
313+
def __init__(
314+
self,
315+
sandbox_id: Optional[str] = None,
316+
timeout: int = 3000,
317+
base_url: Optional[str] = None,
318+
bearer_token: Optional[str] = None,
319+
):
320+
"""
321+
Initialize the Training Sandbox.
322+
323+
Args:
324+
sandbox_id (Optional[str]): Unique identifier for the sandbox.
325+
timeout (int): Maximum time allowed for sandbox operations.
326+
base_url (Optional[str]): Base URL for sandbox API.
327+
bearer_token (Optional[str]): Authentication token for API access.
328+
"""
329+
super().__init__(
330+
sandbox_id,
331+
timeout,
332+
base_url,
333+
bearer_token,
334+
SandboxType.BFCL,
335+
)

src/agentscope_runtime/sandbox/enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ class SandboxType(DynamicEnum):
6666
BROWSER = "browser"
6767
FILESYSTEM = "filesystem"
6868
APPWORLD = "appworld"
69+
BFCL = "bfcl"
70+
WEBSHOP = "webshop"

tests/unit/test_appworld.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- coding: utf-8 -*-
22

33
from agentscope_runtime.sandbox.box.training_box.training_box import (
4-
TrainingSandbox,
4+
APPWorldSandbox,
55
)
66

7-
with TrainingSandbox() as box:
7+
with APPWorldSandbox() as box:
88
profile_list = box.get_env_profile(env_type="appworld", split="train")
99
init_response = box.create_instance(
1010
env_type="appworld",

0 commit comments

Comments
 (0)